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 #ifndef STRING_UTILS_H 16 #define STRING_UTILS_H 17 #include <string> 18 #include <vector> 19 #include "singleton.h" 20 namespace OHOS { 21 namespace HiviewDFX { 22 class StringUtils : public Singleton<StringUtils> { 23 public: 24 StringUtils(); 25 ~StringUtils(); 26 StringUtils(StringUtils const &) = delete; 27 void operator=(StringUtils const &) = delete; 28 29 void StringSplit(const std::string &str, const std::string &split, std::vector<std::string> &result); 30 bool IsBegin(const std::string &content, const std::string &begin); 31 bool IsEnd(const std::string &content, const std::string &end); 32 bool IsContain(const std::string &content, const std::string &contain); 33 bool IsSameStr(const std::string &first, const std::string &second); 34 void ReplaceAll(std::string &str, const std::string &oldValue, const std::string &newValue); 35 bool IsNum(std::string str); 36 bool Compare(const std::string &str, const std::vector<std::string> &strs); 37 void HexToDec(const std::string &str, uint64_t &value); 38 void SetWidth(const int &width, const char &fileStr, const bool &left, std::string &str); 39 char GetBlank(); 40 char GetSeparator(); 41 42 private: 43 const int HEX_STR = 16; 44 const int DEC_STR = 10; 45 }; 46 } // namespace HiviewDFX 47 } // namespace OHOS 48 #endif