16 #error no need to expose this header to Swig
20 #ifndef BORNAGAIN_BASE_UTILS_STRINGUTILS_H
21 #define BORNAGAIN_BASE_UTILS_STRINGUTILS_H
33 bool matchesPattern(
const std::string& text,
const std::string& wildcardPattern);
35 std::string
padRight(
const std::string&
name,
size_t length);
38 std::vector<std::string>
split(
const std::string& text,
const std::string& delimeter);
42 const std::string& replacement =
"");
45 std::string
join(
const std::vector<std::string>& joinable,
const std::string& joint);
48 std::string
removeSubstring(
const std::string& text,
const std::string& substr);
51 template <
typename T> std::string
scientific(
const T value,
int n = 10);
54 std::string
to_lower(std::string text);
57 std::string
trim(
const std::string& str,
const std::string& whitespace =
" \t");
63 std::ostringstream out;
QString const & name(EShape k)
Utility functions to analyze or modify strings.
std::string removeSubstring(const std::string &text, const std::string &substr)
Removes multiple occurrences 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 trim(const std::string &str, const std::string &whitespace=" \t")
Cuts any of the chars given in whitespace from start and end of str.
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 occurrences 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.
std::string scientific(const T value, int n=10)
Returns scientific string representing given value of any numeric type.