15 #ifndef BORNAGAIN_FIT_TOOLS_STRINGUTILS_H
16 #define BORNAGAIN_FIT_TOOLS_STRINGUTILS_H
29 bool matchesPattern(
const std::string& text,
const std::string& wildcardPattern);
31 std::string
padRight(
const std::string& name,
size_t length);
34 std::vector<std::string>
split(
const std::string& text,
const std::string& delimeter);
38 const std::string& replacement =
"");
41 std::string
join(
const std::vector<std::string>& joinable,
const std::string& joint);
44 std::string
removeSubstring(
const std::string& text,
const std::string& substr);
47 template <
typename T> std::string
scientific(
const T value,
int n = 10);
50 std::string
to_lower(std::string text);
56 std::ostringstream out;
Utility functions to analyze or modify strings.
std::string removeSubstring(const std::string &text, const std::string &substr)
Removes multiple occurences of given substring from a string and returns result.
std::string join(const std::vector< std::string > &joinable, const std::string &joint)
Returns string obtain by joining vector elements.
bool matchesPattern(const std::string &text, const std::string &wildcardPattern)
Returns true if text matches pattern with wildcards '*' and '?'.
std::string to_lower(std::string text)
Returns new string which is lower case of text.
void replaceItemsFromString(std::string &text, const std::vector< std::string > &items, const std::string &replacement="")
Replaces all occurences of items from string text with delimiter.
std::string scientific(const T value, int n=10)
Returns scientific string representing given value of any numeric type.
std::string padRight(const std::string &name, size_t length)
Returns string right-padded with blanks.
std::vector< std::string > split(const std::string &text, const std::string &delimeter)
Split string into vector of string using delimeter.