1 /* 2 * Copyright (c) 2022 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 OHOS_DM_ANONYMOUS_H 17 #define OHOS_DM_ANONYMOUS_H 18 19 #include <map> 20 #include <string> 21 22 #include "dm_device_info.h" 23 24 #include "nlohmann/json.hpp" 25 26 namespace OHOS { 27 namespace DistributedHardware { 28 std::string GetAnonyString(const std::string &value); 29 std::string GetAnonyInt32(const int32_t value); 30 bool IsNumberString(const std::string &inputString); 31 bool IsString(const nlohmann::json &jsonObj, const std::string &key); 32 bool IsInt32(const nlohmann::json &jsonObj, const std::string &key); 33 bool IsUint32(const nlohmann::json &jsonObj, const std::string &key); 34 bool IsInt64(const nlohmann::json &jsonObj, const std::string &key); 35 bool IsArray(const nlohmann::json &jsonObj, const std::string &key); 36 bool IsBool(const nlohmann::json &jsonObj, const std::string &key); 37 std::string ConvertMapToJsonString(const std::map<std::string, std::string> ¶mMap); 38 void ParseMapFromJsonString(const std::string &jsonStr, std::map<std::string, std::string> ¶mMap); 39 bool IsInvalidPeerTargetId(const PeerTargetId &targetId); 40 std::string ConvertCharArray2String(const char *srcData, uint32_t srcLen); 41 void VersionSplitToInt(const std::string &str, const char split, std::vector<int32_t> &numVec); 42 bool CompareVecNum(const std::vector<int32_t> &srcVecNum, const std::vector<int32_t> &sinkVecNum); 43 int32_t StringToInt(const std::string &str, int32_t base); 44 } // namespace DistributedHardware 45 } // namespace OHOS 46 #endif // OHOS_DM_ANONYMOUS_H 47