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 26namespace OHOS { 27namespace DistributedHardware { 28std::string GetAnonyString(const std::string &value); 29std::string GetAnonyInt32(const int32_t value); 30bool IsNumberString(const std::string &inputString); 31bool IsString(const nlohmann::json &jsonObj, const std::string &key); 32bool IsInt32(const nlohmann::json &jsonObj, const std::string &key); 33bool IsUint32(const nlohmann::json &jsonObj, const std::string &key); 34bool IsInt64(const nlohmann::json &jsonObj, const std::string &key); 35bool IsArray(const nlohmann::json &jsonObj, const std::string &key); 36bool IsBool(const nlohmann::json &jsonObj, const std::string &key); 37std::string ConvertMapToJsonString(const std::map<std::string, std::string> ¶mMap); 38void ParseMapFromJsonString(const std::string &jsonStr, std::map<std::string, std::string> ¶mMap); 39bool IsInvalidPeerTargetId(const PeerTargetId &targetId); 40std::string ConvertCharArray2String(const char *srcData, uint32_t srcLen); 41int32_t StringToInt(const std::string &str, int32_t base); 42int64_t StringToInt64(const std::string &str, int32_t base); 43void VersionSplitToInt(const std::string &str, const char split, std::vector<int32_t> &numVec); 44bool CompareVecNum(const std::vector<int32_t> &srcVecNum, const std::vector<int32_t> &sinkVecNum); 45bool CompareVersion(const std::string &remoteVersion, const std::string &oldVersion); 46} // namespace DistributedHardware 47} // namespace OHOS 48#endif // OHOS_DM_ANONYMOUS_H 49