• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #pragma once
18 #include <json/json.h>
19 #include <iostream>
20 
21 #include "common/libs/utils/result.h"
22 
23 #define GENERATE_MVP_FLAGS_ONLY true
24 
25 namespace cuttlefish {
26 
27 Result<void> ValidateTypo(const Json::Value& root,
28                           const std::map<std::string, Json::ValueType>& map);
29 
30 Result<void> ValidateIntConfig(
31     const Json::Value& instances, const std::string& group,
32     const std::string& json_flag,
33     std::function<Result<void>(int)> validate_config);
34 
35 Result<void> ValidateIntConfigSubGroup(
36     const Json::Value& instances, const std::string& group,
37     const std::string& subgroup, const std::string& json_flag,
38     std::function<Result<void>(int)> validate_config);
39 
40 Result<void> ValidateStringConfig(
41     const Json::Value& instances, const std::string& group,
42     const std::string& json_flag,
43     std::function<Result<void>(const std::string&)> validate_config);
44 
45 Result<void> ValidateStringConfigSubGroup(
46     const Json::Value& instances, const std::string& group,
47     const std::string& subgroup, const std::string& json_flag,
48     std::function<Result<void>(const std::string&)> validate_config);
49 
50 void InitIntConfig(Json::Value& instances, const std::string& group,
51                    const std::string& json_flag, int default_value);
52 
53 void InitIntConfigSubGroup(Json::Value& instances, const std::string& group,
54                            const std::string& subgroup,
55                            const std::string& json_flag, int default_value);
56 
57 void InitIntConfigSubGroupVector(Json::Value& instances,
58                                  const std::string& group,
59                                  const std::string& subgroup,
60                                  const std::string& json_flag,
61                                  int default_value);
62 
63 void InitStringConfig(Json::Value& instances, const std::string& group,
64                       const std::string& json_flag, const std::string& default_value);
65 
66 void InitStringConfigSubGroup(Json::Value& instances, const std::string& group,
67                               const std::string& subgroup, const std::string& json_flag,
68                               const std::string& default_value);
69 
70 void InitBoolConfig(Json::Value& instances, const std::string& group,
71                     const std::string& json_flag, const bool default_value);
72 
73 void InitBoolConfigSubGroup(Json::Value& instances, const std::string& group,
74                             const std::string& subgroup,
75                             const std::string& json_flag,
76                             const bool default_value);
77 
78 std::string GenerateGflag(const Json::Value& instances,
79                           const std::string& gflag_name,
80                           const std::string& group,
81                           const std::string& json_flag);
82 
83 std::string GenerateGflagSubGroup(const Json::Value& instances,
84                                   const std::string& gflag_name,
85                                   const std::string& group,
86                                   const std::string& subgroup,
87                                   const std::string& json_flag);
88 
89 std::vector<std::string> MergeResults(std::vector<std::string> first_list,
90                                       std::vector<std::string> scond_list);
91 
92 void MergeTwoJsonObjs(Json::Value& dst, const Json::Value& src);
93 
94 }  // namespace cuttlefish
95