General Utility Library for C++14
2.11
|
The General Utility Library provides a number of utility functions and classes to help with strings.
equals_nocase(): Determine if two strings are equal, making no distinction between upper and lower case ASCII characters.
contains(), contains_nocase(): Check if a string contains a certain string or character.
ends_with(), ends_with_nocase(): Check if a string ends with a certain string or character.
starts_with(), starts_with_nocase(): Check if a string starts with a certain string or character.
cat(): Efficiently concatenate an arbitrary number of std::strings, C strings, string_views, or numbers.
join(): Concatenate all strings in a range, placing a delimiter between them.
repeat(): Repeat a string N times.
split(), split_sv(): Split a string at all occurrences of a delimiter string or regular expression, returning a vector of string or string_view tokens. split(" hi ", " ")
returns {"", "hi", ""}
.
tokenize(), tokenize_sv(): Split a string at delimiter characters, returning a vector of string or string_view tokens. tokenize(" hi ")
returns {"hi"}
.
replace(): Replace all occurrences of a string in another string.
replace_inplace(): Replace all occurrences of a string in another string in-place.
trim(), trim_left(), trim_right() etc.: Trim leading and/or trailing whitespace (or a custom set of characters) from a string, returning a new std::string or a string_view.
escape(), unescape(): Replace non-ASCII characters in a string so that it looks like a C string literal (and vice versa).
lowercase_ascii(), uppercase_ascii(): Return the ASCII lowercase/uppercase equivalent of a given string or character. Non-ASCII characters are not modified.
lowercase_ascii_inplace(), uppercase_ascii_inplace(): Replace all ASCII characters in a string by their lowercase/uppercase equivalents.
hex_string(): Convert an integer or a range of integers into their hexadecimal ASCII representation.
to_number(): Convert an ASCII string_view into an integer or floating-point number.
safe_string(): Safely create a std::string from a char pointer and a length.
string_view: A view to a contiguous sequence of chars. The GUL version is a backport of std::string_view from libc++ for C++17.