11 inline bool StringUtils::IsBlankInternal(
char ch)
13 return std::isspace(ch);
18 return IsBlankInternal(ch);
21 inline char StringUtils::ToLowerInternal(
char ch)
23 return (
char)std::tolower(ch);
28 return ToLowerInternal(ch);
31 inline char StringUtils::ToUpperInternal(
char ch)
33 return (
char)std::toupper(ch);
38 return ToUpperInternal(ch);
43 std::string result(str);
50 std::string result(str);
57 std::transform(str.begin(), str.end(), str.begin(), ToLowerInternal);
63 std::transform(str.begin(), str.end(), str.begin(), ToUpperInternal);
74 std::string result(str);
81 str.erase(std::remove_if(str.begin(), str.end(), IsBlankInternal), str.end());
87 return (str.find(ch) != std::string::npos);
92 return (str.find(substr) != std::string::npos);
97 return (str.find(substr) != std::string::npos);
102 return (str.size() >= prefix.size()) && (str.compare(0, prefix.size(), prefix) == 0);
107 return (str.size() >= suffix.size()) && (str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0);
110 template <
typename T>
113 std::ostringstream ss;
121 std::ostringstream ss;
122 ss << (int32_t)value;
129 std::ostringstream ss;
130 ss << (uint32_t)value;
134 template <
typename T>
138 std::istringstream(std::string(str)) >> result;
146 std::istringstream(std::string(str)) >> result;
147 return (int8_t)result;
154 std::istringstream(std::string(str)) >> result;
155 return (uint8_t)result;
161 return std::string(str);
static std::string & Trim(std::string &str)
Trims space characters from the both sides of the given string.
static std::string & Lower(std::string &str)
Convert the given string to lower case.
static bool StartsWith(std::string_view str, std::string_view prefix)
Checks the given string for specific prefix.
static std::string & LTrim(std::string &str)
Trims space characters from the start of the given string.
static std::string ToString(const T &value)
Converts arbitrary datatypes into string using std::ostringstream.
static T FromString(std::string_view str)
Converts strings to arbitrary datatypes using std::istringstream.
static char ToLower(char ch)
Convert the given character to lower case.
static std::string & RTrim(std::string &str)
Trims space characters from the end of the given string.
static char ToUpper(char ch)
Convert the given character to UPPER case.
static bool IsBlank(char ch)
Is the given character blank (empty or contains only space characters)?
static bool Contains(std::string_view str, const char ch)
Is the given string contains the given character?
static std::string & Upper(std::string &str)
Convert the given string to UPPER case.
static bool EndsWith(std::string_view str, std::string_view suffix)
Checks the given string for specific suffix.
static std::string RemoveBlank(std::string_view str)
Remove blank characters from the given string.
C++ Common project definitions.