55 s.erase(s.begin(), find_if(s.begin(), s.end(), [](
unsigned char ch) {
69 s.erase(find_if(s.rbegin(), s.rend(), [](
unsigned char ch) {
145 std::string
replaceAllCopy(std::string str,
const std::string& from,
const std::string& to)
147 size_t start_pos = 0;
148 while ((start_pos = str.find(from, start_pos)) != string::npos)
150 str.replace(start_pos, from.length(), to);
151 start_pos += to.length();
166 void replaceAll(std::string& str,
const std::string& from,
const std::string& to)
168 size_t start_pos = 0;
169 while ((start_pos = str.find(from, start_pos)) != string::npos)
171 str.replace(start_pos, from.length(), to);
172 start_pos += to.length();
193 return ((str1.size() == str2.size()) &&
194 equal(str1.cbegin(), str1.cend(), str2.cbegin(),
195 [](
const unsigned char& c1,
const unsigned char& c2) {
196 return (c1 == c2 || toupper(c1) == toupper(c2)); }));
239 #if defined(__cpp_lib_char8_t)
246 std::string from_u8string(
const std::u8string &s)
248 return string(s.begin(), s.end());
269 istringstream ss(iso8601);
271 ss >> std::get_time(&t,
"%Y-%m-%dT%H:%M:%S");
277 istringstream ss(iso8601);
279 ss >> std::get_time(&t,
"%Y%m%dT%H%M%S");
285 istringstream ss(iso8601);
287 ss >> std::get_time(&t,
"%Y-%m-%dT%H:%M:%SZ");
293 istringstream ss(iso8601);
295 ss >> std::get_time(&t,
"%Y%m%dT%H%M%SZ");
Common definitions for libxcks.
constexpr std::time_t Invalid_DateTime
Invalid date/time.
void replaceAll(std::string &str, const std::string &from, const std::string &to)
Replace in-place all occurrences of a substring by another in a string.
void ltrim(std::string &s)
Trim from start (in place).
void rtrim(std::string &s)
Trim from end (in place).
std::string trim_copy(std::string s)
Trim from both ends (copying).
std::string rtrim_copy(std::string s)
Trim from end (copying).
void trim(std::string &s)
Trim from both ends (in place).
bool stringICompare(const std::string &str1, const std::string &str2)
Case-insensitive comparison of two strings.
time_t parseISO8601(const std::string &iso8601)
Parse ISO 8601 date/time.
std::string from_u8string(const std::string &s)
Returns an UTF-8 encoded string in an object of type std::string (C++17).
std::string escapeForXML(const std::string &str)
Escapes a string for writing it in a XML stream.
std::string ltrim_copy(std::string s)
Trim from start (copying).
std::string replaceAllCopy(std::string str, const std::string &from, const std::string &to)
Replace all occurrences of a substring by another in a string.