blob: f798c6a7351f6337cf9e4178e6029999f221b282 [file] [log] [blame]
Tao Baoc3901232018-05-21 16:05:56 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "private/commands.h"
18
19#include <string>
20
21#include <android-base/logging.h>
22
23Command::Type Command::ParseType(const std::string& type_str) {
24 if (type_str == "zero") {
25 return Type::ZERO;
26 } else if (type_str == "new") {
27 return Type::NEW;
28 } else if (type_str == "erase") {
29 return Type::ERASE;
30 } else if (type_str == "move") {
31 return Type::MOVE;
32 } else if (type_str == "bsdiff") {
33 return Type::BSDIFF;
34 } else if (type_str == "imgdiff") {
35 return Type::IMGDIFF;
36 } else if (type_str == "stash") {
37 return Type::STASH;
38 } else if (type_str == "free") {
39 return Type::FREE;
40 }
41 LOG(ERROR) << "Invalid type: " << type_str;
42 return Type::LAST;
43};