16 #error no need to expose this header to Swig
20 #ifndef BORNAGAIN_BASE_UTIL_STRINGUTILS_H
21 #define BORNAGAIN_BASE_UTIL_STRINGUTILS_H
32 std::string
padRight(
const std::string& name,
size_t length);
35 std::vector<std::string>
split(
const std::string& text,
const std::string& delimiter);
39 const std::string& replacement =
"");
42 std::string
join(
const std::vector<std::string>& joinable,
const std::string& joint);
49 std::string
to_lower(std::string text);
61 bool to_int(
const std::string& str,
int* result);
64 std::string
trim(
const std::string& str,
const std::string& whitespace =
" \t");
67 std::string
trimFront(
const std::string& str,
const std::string& whitespace =
" \t");
70 bool startsWith(
const std::string& str,
const std::string& substr);
77 std::ostringstream out;
Utility functions to analyze or modify strings.
std::vector< std::string > split(const std::string &text, const std::string &delimiter)
Split string into vector of string using delimiter.
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(T value, int n=10)
Returns scientific string representing given value of any numeric type.
std::string join(const std::vector< std::string > &joinable, const std::string &joint)
Returns string obtain by joining vector elements.
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.
bool to_int(const std::string &str, int *result)
Interprets the contained text as an integer and returns it in result. Space chars at its begin and en...
std::string trimFront(const std::string &str, const std::string &whitespace=" \t")
Cuts any of the chars given in whitespace from start.
std::string to_lower(std::string text)
Returns new string which is lower case of text.
bool startsWith(const std::string &str, const std::string &substr)
True if the string starts with substr. The comparison is case sensitive.
std::string padRight(const std::string &name, size_t length)
Returns string right-padded with blanks.
std::string scientific(T value, int n=10)
Returns scientific string representing given value of any numeric type.