• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DATA_STORAGE_PDP_OPERATOR_PARSER_UTIL_H
17 #define DATA_STORAGE_PDP_OPERATOR_PARSER_UTIL_H
18 
19 #include <json/json.h>
20 
21 #include "iosfwd"
22 #include "rdb_store.h"
23 #include "string"
24 
25 namespace Json {
26 class Value;
27 }
28 
29 namespace OHOS {
30 namespace NativeRdb {
31 class ValuesBucket;
32 }
33 namespace Telephony {
34 struct OpKey;
35 struct PdpProfile;
36 class ParserUtil {
37 public:
38     int ParserPdpProfileJson(std::vector<PdpProfile> &vec);
39     void ParserPdpProfileInfos(std::vector<PdpProfile> &vec, Json::Value &root);
40     void ParserPdpProfileToValuesBucket(NativeRdb::ValuesBucket &value, const PdpProfile &bean);
41     bool ParseFromCustomSystem(std::vector<OpKey> &vec);
42     int ParserOpKeyJson(std::vector<OpKey> &vec, const char *path);
43     void ParserOpKeyInfos(std::vector<OpKey> &vec, Json::Value &root);
44     void ParserOpKeyToValuesBucket(NativeRdb::ValuesBucket &value, const OpKey &bean);
45 
46 public:
47     enum class RuleID {
48         RULE_EMPTY = 0x0,
49         RULE_MCCMNC = 0x1,
50         RULE_ICCID = 0x2,
51         RULE_IMSI = 0x4,
52         RULE_SPN = 0x8,
53         RULE_GID1 = 0x10,
54         RULE_GID2 = 0x20,
55     };
56 
57 private:
58     int LoaderJsonFile(char *&content, const char *path) const;
59     int CloseFile(FILE *f) const;
60 };
61 } // namespace Telephony
62 } // namespace OHOS
63 #endif // DATA_STORAGE_PDP_OPERATOR_PARSER_UTIL_H
64