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 struct NumMatch; 37 struct EccNum; 38 class ParserUtil { 39 public: 40 int ParserPdpProfileJson(std::vector<PdpProfile> &vec); 41 void ParserPdpProfileInfos(std::vector<PdpProfile> &vec, Json::Value &root); 42 void ParserPdpProfileToValuesBucket(NativeRdb::ValuesBucket &value, const PdpProfile &bean); 43 bool ParseFromCustomSystem(std::vector<OpKey> &vec); 44 int ParserOpKeyJson(std::vector<OpKey> &vec, const char *path); 45 void ParserOpKeyInfos(std::vector<OpKey> &vec, Json::Value &root); 46 void ParserOpKeyToValuesBucket(NativeRdb::ValuesBucket &value, const OpKey &bean); 47 int ParserNumMatchJson(std::vector<NumMatch> &vec); 48 void ParserNumMatchInfos(std::vector<NumMatch> &vec, Json::Value &root); 49 void ParserNumMatchToValuesBucket(NativeRdb::ValuesBucket &value, const NumMatch &bean); 50 int ParserEccDataJson(std::vector<EccNum> &vec); 51 void ParserEccDataInfos(std::vector<EccNum> &vec, Json::Value &root); 52 void ParserEccDataToValuesBucket(NativeRdb::ValuesBucket &value, const EccNum &bean); 53 54 public: 55 enum class RuleID { 56 RULE_EMPTY = 0x0, 57 RULE_MCCMNC = 0x1, 58 RULE_ICCID = 0x2, 59 RULE_IMSI = 0x4, 60 RULE_SPN = 0x8, 61 RULE_GID1 = 0x10, 62 RULE_GID2 = 0x20, 63 }; 64 65 private: 66 std::string ParseString(const Json::Value &value); 67 int LoaderJsonFile(char *&content, const char *path) const; 68 int CloseFile(FILE *f) const; 69 int GetRuleId(OpKey &bean); 70 std::string GetCustFile(const char *&file, const char *key); 71 }; 72 } // namespace Telephony 73 } // namespace OHOS 74 #endif // DATA_STORAGE_PDP_OPERATOR_PARSER_UTIL_H 75