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 VCARD_UTILS_H 17 #define VCARD_UTILS_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace Telephony { 24 class VCardUtils { 25 public: 26 static bool EqualsIgnoreCase(const std::string &str1, const std::string &str2); 27 static std::vector<std::string> Split(const std::string &input, const std::string &delimiter); 28 static std::string Trim(std::string &str); 29 static std::string ToUpper(const std::string &str); 30 static bool StartWith(const std::string &str, const std::string &prefix); 31 static bool EndWith(const std::string &fullString, const std::string &ending); 32 static std::string EncodeBase64(const std::string &from); 33 static std::string DecodeBase64(const std::string &encoded); 34 static std::string DecodeBase64NoWrap(const std::string &input); 35 static std::string ConvertCharset( 36 const std::string &input, const std::string &fromCharset, const std::string &toCharset, int32_t &errorCode); 37 static std::string ConvertCharset( 38 const std::string &decodedBytes, const std::string &targetCharset, int32_t &errorCode); 39 static std::string GetBytes(const std::string &str, const std::string &charset); 40 static std::string CreateFileName(); 41 static void SaveFile(const std::string &fileStr, const std::string &path); 42 static bool IsPrintableAscii(std::vector<std::string> strs); 43 static bool IsPrintableAscii(const std::string &str); 44 static bool IsPrintableAscii(char c); 45 static bool IsWrapPrintableAscii(std::vector<std::string> strs); 46 static std::string GetTypeFromImLabelId(std::string labelId); 47 static std::vector<std::string> GetTypeFromPhoneLabelId(std::string labelId); 48 static std::string GetImageType(std::string bytes); 49 static bool IsNum(const std::string &str); 50 static std::string TrimListToString(const std::vector<std::string> &strs); 51 static std::vector<std::string> ConstructListFromValue(const std::string &value, std::string vcardType); 52 static void GetPhoneTypeFromStrings( 53 const std::vector<std::string> &types, std::string number, std::tuple<int32_t, std::string> &result); 54 static int32_t VcardtypeToInt(const std::string &vcardType); 55 static std::string FormatNumber(std::string source); 56 static int32_t GetPhoneNumberFormat(const int32_t vcardType); 57 static bool IsAllEmpty(std::vector<std::string> values); 58 static int32_t GetLabelIdFromImType(std::string type); 59 static std::string HandleCh(char nextCh, std::string vcardType); 60 static void HandleTypeAndLabel(int32_t &type, std::string &label, std::string number, std::string typeStringOrg); 61 }; 62 } // namespace Telephony 63 } // namespace OHOS 64 #endif /* VCARD_UTILS_H */ 65