13#ifndef ROOT_StringUtils
14#define ROOT_StringUtils
25std::vector<std::string>
Split(std::string_view str, std::string_view delims,
bool skipEmpty =
false);
34template <
class StringCollection_t>
35std::string
Join(
const std::string &sep, StringCollection_t &&strings)
39 return std::accumulate(std::next(std::begin(strings)), std::end(strings), strings[0],
40 [&sep](
auto const &
a,
auto const &
b) {
return a + sep +
b; });
43std::string
Round(
double value,
double error,
unsigned int cutoff = 1, std::string_view delim =
"#pm");
45inline bool StartsWith(std::string_view
string, std::string_view prefix)
47 return string.size() >= prefix.size() &&
string.substr(0, prefix.size()) == prefix;
50inline bool EndsWith(std::string_view
string, std::string_view suffix)
52 return string.size() >= suffix.size() &&
string.substr(
string.
size() - suffix.size(), suffix.size()) == suffix;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool EndsWith(std::string_view string, std::string_view suffix)
std::string Join(const std::string &sep, StringCollection_t &&strings)
Concatenate a list of strings with a separator.
bool StartsWith(std::string_view string, std::string_view prefix)
std::string Round(double value, double error, unsigned int cutoff=1, std::string_view delim="#pm")
Convert (round) a value and its uncertainty to string using one or two significant digits of the erro...
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.