28 constexpr
char const *
to_string(
bool iValue) {
return iValue ?
"true" :
"false"; }
38 template<
typename Out>
39 void splitString(
const std::string &iString,
char iDelimiter, Out oResult,
bool iSkipEmptyEntries =
false)
41 std::stringstream ss(iString);
43 while(std::getline(ss, item, iDelimiter))
45 if(!item.empty() || !iSkipEmptyEntries)
48 if(!iSkipEmptyEntries)
50 if(!iString.empty() && iString[iString.size() - 1] == iDelimiter)
62 std::vector<std::string>
splitString(
const std::string &iString,
char iDelimiter,
bool iSkipEmptyEntries =
false);
69 template<
typename TFloat>
72 char *endPtr =
nullptr;
73 auto value = static_cast<TFloat>(strtod(iString.c_str(), &endPtr));
74 if(endPtr == iString.c_str())
89 template<
typename TFloat>
92 char *endPtr =
nullptr;
93 auto value = static_cast<TFloat>(strtod(iString.c_str(), &endPtr));
94 if(endPtr == iString.c_str())
102 template<
typename TFloat>
103 std::vector<TFloat>
splitFloats(
const std::string &iString,
char iDelimiter,
bool iSkipEmptyEntries =
false)
105 static auto f = [] (
const std::string &iString) -> TFloat {
return stringToFloat<TFloat>(iString); };
107 std::vector<TFloat> res{};
109 auto strings =
splitString(iString, iDelimiter, iSkipEmptyEntries);
113 res.reserve(strings.size());
115 std::transform(strings.cbegin(), strings.cend(), std::back_inserter(res), f);
std::vector< TFloat > splitFloats(const std::string &iString, char iDelimiter, bool iSkipEmptyEntries=false)
Converts the string to a an array of floats.
Definition: StringUtils.h:103
Definition: CircularBuffer.h:25
std::vector< std::string > splitString(const std::string &iString, char iDelimiter, bool iSkipEmptyEntries)
Split a string according to a delimiter and returns a vector.
Definition: StringUtils.cpp:30
bool stringToFloat(const std::string &iString, TFloat &oValue)
Converts the string to a TFloat (float or double)
Definition: StringUtils.h:70
constexpr std::array< U, N > transform(std::array< T, N > const &a, F &&f)
Transforms an array containing elements of type T into an array containing elements of type U by appl...
Definition: stl.h:40
constexpr char const * to_string(bool iValue)
Convenient call to convert a boolean into a string.
Definition: StringUtils.h:28