Lines Matching refs:str
50 bool IsValidHexString(const std::string& str) { in IsValidHexString() argument
51 return std::find_if_not(str.begin(), str.end(), IsHexDigit{}) == str.end(); in IsValidHexString()
54 std::optional<std::vector<uint8_t>> FromHexString(const std::string& str) { in FromHexString() argument
55 if (str.size() % 2 != 0) { in FromHexString()
56 LOG_DEBUG("str size is not divisible by 2, size is %zu", str.size()); in FromHexString()
59 if (std::find_if_not(str.begin(), str.end(), IsHexDigit{}) != str.end()) { in FromHexString()
64 value.reserve(str.size() / 2); in FromHexString()
65 for (size_t i = 0; i < str.size(); i += 2) { in FromHexString()
67 auto ret = std::from_chars(str.c_str() + i, str.c_str() + i + 2, v, 16); in FromHexString()
77 std::string StringTrim(std::string str) { in StringTrim() argument
78 str.erase(str.begin(), std::find_if_not(str.begin(), str.end(), IsSpace{})); in StringTrim()
79 str.erase(std::find_if_not(str.rbegin(), str.rend(), IsSpace{}).base(), str.end()); in StringTrim()
80 return str; in StringTrim()
83 std::vector<std::string> StringSplit(const std::string& str, const std::string& delim, size_t max_t… in StringSplit() argument
88 auto index_of_delim = str.find(delim); in StringSplit()
90 tokens.push_back(str.substr(starting_index, index_of_delim - starting_index)); in StringSplit()
92 index_of_delim = str.find(delim, starting_index); in StringSplit()
95 if (starting_index < (str.size() + 1)) { in StringSplit()
96 tokens.push_back(str.substr(starting_index)); in StringSplit()
109 return ss.str(); in StringJoin()
112 std::optional<int64_t> Int64FromString(const std::string& str) { in Int64FromString() argument
115 int64_t value = std::strtoll(str.c_str(), &ptr, 10); in Int64FromString()
117 LOG_DEBUG("cannot parse string '%s' with error '%s'", str.c_str(), strerror(errno)); in Int64FromString()
120 if (ptr == str.c_str()) { in Int64FromString()
121 LOG_DEBUG("string '%s' is empty or has wrong format", str.c_str()); in Int64FromString()
124 if (ptr != (str.c_str() + str.size())) { in Int64FromString()
125 LOG_DEBUG("cannot parse whole string '%s'", str.c_str()); in Int64FromString()
135 std::optional<uint64_t> Uint64FromString(const std::string& str) { in Uint64FromString() argument
136 if (str.find('-') != std::string::npos) { in Uint64FromString()
137 LOG_DEBUG("string '%s' contains minus sign, this function is for unsigned", str.c_str()); in Uint64FromString()
142 uint64_t value = std::strtoull(str.c_str(), &ptr, 10); in Uint64FromString()
144 LOG_DEBUG("cannot parse string '%s' with error '%s'", str.c_str(), strerror(errno)); in Uint64FromString()
147 if (ptr == str.c_str()) { in Uint64FromString()
148 LOG_DEBUG("string '%s' is empty or has wrong format", str.c_str()); in Uint64FromString()
151 if (ptr != (str.c_str() + str.size())) { in Uint64FromString()
152 LOG_DEBUG("cannot parse whole string '%s'", str.c_str()); in Uint64FromString()
162 std::optional<bool> BoolFromString(const std::string& str) { in BoolFromString() argument
163 if (str == "true") { in BoolFromString()
165 } else if (str == "false") { in BoolFromString()
168 LOG_DEBUG("string '%s' is neither true nor false", str.c_str()); in BoolFromString()