29 void trim(std::string& _str,
bool _left,
bool _right)
32 _str.erase(_str.find_last_not_of(
" \t\r") + 1);
34 _str.erase(0, _str.find_first_not_of(
" \t\r"));
37 const std::string&
toString(
const std::string& _value)
75 template<
typename ReturnType,
typename InputType = ReturnType>
76 std::vector<ReturnType>
split(
const InputType& _source,
const InputType& _delims)
78 std::vector<ReturnType> result;
80 std::string_view source{_source};
81 std::string_view delims{_delims};
83 size_t start = source.find_first_not_of(delims);
85 while (start != std::string_view::npos)
87 const auto end = source.find_first_of(delims, start);
89 if (end == std::string_view::npos)
91 result.emplace_back(source.substr(start));
95 result.emplace_back(source.substr(start, end - start));
96 start = source.find_first_not_of(delims, end + 1);
104 std::vector<std::string>
split(std::string_view _source, std::string_view _delims)
109 bool startWith(std::string_view _source, std::string_view _value)
111#if __cplusplus >= 202002L
112 return _source.starts_with(_value);
114 size_t count = _value.size();
115 if (_source.size() < count)
117 for (
size_t index = 0; index < count; ++index)
119 if (_source[index] != _value[index])
126 bool endWith(std::string_view _source, std::string_view _value)
128#if __cplusplus >= 202002L
129 return _source.ends_with(_value);
131 size_t count = _value.size();
132 if (_source.size() < count)
134 size_t offset = _source.size() - count;
135 for (
size_t index = 0; index < count; ++index)
137 if (_source[index + offset] != _value[index])
std::vector< ReturnType > split(const InputType &_source, const InputType &_delims)
unsigned int parseUInt(std::string_view _value)
bool endWith(std::string_view _source, std::string_view _value)
bool parseBool(std::string_view _value)
float parseFloat(std::string_view _value)
T parseValue(std::string_view value)
size_t parseSizeT(std::string_view _value)
__attribute__((visibility("default"))) void trim(std std::string toString(T _value)
void trim(std::string &_str, bool _left, bool _right)
bool startWith(std::string_view _source, std::string_view _value)
std::vector< std::string > split(std::string_view _source, std::string_view _delims)
int parseInt(std::string_view _value)
double parseDouble(std::string_view _value)