|
static bool | replace (std::string &s, std::string_view from, std::string_view to, std::size_t *pos_p=nullptr) |
| A std::string_view overload. More...
|
|
static void | replace (std::string &s, char from, char to) |
| Replaces all 'from' characters with 'to'. More...
|
|
static void | replace (StringArray &, char from, char to) |
| Replaces 'from' characters with 'to' in all the strings in the array. More...
|
|
static unsigned int | replaceAll (std::string &s, std::string_view from, std::string_view to) |
| Does a global replace on string 's', replacing all occurrences of sub-string 'from' with 'to'. More...
|
|
static std::string | replaced (const std::string &s, char from, char to) |
| Returns the string 's' with all occurrences of 'from' replaced by 'to'. More...
|
|
static void | removeAll (std::string &, char) |
| Removes all occurrences of the character from the string. See also only(). More...
|
|
static std::string | removedAll (const std::string &, char) |
| Removes all occurrences of the character from the string and returns the result. More...
|
|
static std::string & | trimLeft (std::string &s, std::string_view ws, std::size_t limit=0U) |
| Trims the lhs of s, taking off up to 'limit' of the 'ws' characters. More...
|
|
static std::string_view | trimLeftView (std::string_view, std::string_view ws, std::size_t limit=0U) noexcept |
| Trims the lhs of s, taking off up to 'limit' of the 'ws' characters. More...
|
|
static std::string & | trimRight (std::string &s, std::string_view ws, std::size_t limit=0U) |
| Trims the rhs of s, taking off up to 'limit' of the 'ws' characters. More...
|
|
static std::string_view | trimRightView (std::string_view sv, std::string_view ws, std::size_t limit=0U) noexcept |
| Trims the rhs of s, taking off up to 'limit' of the 'ws' characters. More...
|
|
static std::string & | trim (std::string &s, std::string_view ws) |
| Trims both ends of s, taking off any of the 'ws' characters. More...
|
|
static std::string | trimmed (const std::string &s, std::string_view ws) |
| Returns a trim()med version of s. More...
|
|
static std::string_view | trimmedView (std::string_view s, std::string_view ws) noexcept |
| Returns a trim()med view of the input view. More...
|
|
static bool | isNumeric (std::string_view s, bool allow_minus_sign=false) noexcept |
| Returns true if every character is a decimal digit. More...
|
|
static bool | isHex (std::string_view s) noexcept |
| Returns true if every character is a hexadecimal digit. More...
|
|
static bool | isPrintableAscii (std::string_view s) noexcept |
| Returns true if every character is between 0x20 and 0x7e inclusive. More...
|
|
static bool | isPrintable (std::string_view s) noexcept |
| Returns true if every character is 0x20 or above but not 0x7f. More...
|
|
static bool | isSimple (std::string_view s) noexcept |
| Returns true if every character is alphanumeric or "-" or "_". More...
|
|
static bool | isUShort (std::string_view s) noexcept |
| Returns true if the string can be converted into an unsigned short without throwing an exception. More...
|
|
static bool | isUInt (std::string_view s) noexcept |
| Returns true if the string can be converted into an unsigned integer without throwing an exception. More...
|
|
static bool | isULong (std::string_view s) noexcept |
| Returns true if the string can be converted into an unsigned long without throwing an exception. More...
|
|
static bool | isInt (std::string_view s) noexcept |
| Returns true if the string can be converted into an integer without throwing an exception. More...
|
|
static std::string | fromBool (bool b) |
| Converts boolean 'b' to a string. More...
|
|
static std::string | fromDouble (double d) |
| Converts double 'd' to a string. More...
|
|
static std::string | fromInt (int i) |
| Converts int 'i' to a string. More...
|
|
static std::string | fromLong (long l) |
| Converts long 'l' to a string. More...
|
|
static std::string | fromShort (short s) |
| Converts short 's' to a string. More...
|
|
static std::string | fromUInt (unsigned int ui) |
| Converts unsigned int 'ui' to a string. More...
|
|
static std::string | fromULong (unsigned long ul) |
| Converts unsigned long 'ul' to a string. More...
|
|
static std::string | fromUShort (unsigned short us) |
| Converts unsigned short 'us' to a string. More...
|
|
static std::string | fromULong (unsigned long, const Hex &) |
| Converts an unsigned value to a lower-case hex string with no leading zeros. More...
|
|
static std::string | fromULongLong (unsigned long long, const Hex &) |
| Converts an unsigned value to a lower-case hex string with no leading zeros. More...
|
|
static std::string_view | fromULongToHex (unsigned long, char *out) noexcept |
| Low-level conversion from an unsigned value to a lower-case hex string with no leading zeros. More...
|
|
static std::string_view | fromULongLongToHex (unsigned long long, char *out) noexcept |
| Low-level conversion from an unsigned value to a lower-case hex string with no leading zeros. More...
|
|
static bool | toBool (std::string_view s) |
| Converts string 's' to a bool. More...
|
|
static double | toDouble (const std::string &s) |
| Converts string 's' to a double. More...
|
|
static float | toFloat (const std::string &s) |
| Converts string 's' to a float. More...
|
|
static int | toInt (std::string_view s) |
| Converts string 's' to an int. More...
|
|
static long | toLong (std::string_view s) |
| Converts string 's' to a long. More...
|
|
static short | toShort (std::string_view s) |
| Converts string 's' to a short. More...
|
|
static unsigned int | toUInt (std::string_view s) |
| Converts string 's' to an unsigned int. More...
|
|
static int | toInt (std::string_view s1, std::string_view s2) |
| Overload that converts the first string if it can be converted without throwing, or otherwise the second string. More...
|
|
static unsigned int | toUInt (std::string_view s, Limited) |
| Converts string 's' to an unsigned int. More...
|
|
static unsigned int | toUInt (std::string_view s1, std::string_view s2) |
| Overload that converts the first string if it can be converted without throwing, or otherwise the second string. More...
|
|
static unsigned int | toUInt (std::string_view s1, unsigned int default_) noexcept |
| Overload that converts the string if it can be converted without throwing, or otherwise returns the default value. More...
|
|
static unsigned long | toULong (std::string_view s, Limited) |
| Converts string 's' to an unsigned long. More...
|
|
static unsigned long | toULong (std::string_view s, Hex) |
| An overload for hexadecimal strings. More...
|
|
static unsigned long | toULong (std::string_view s, Hex, Limited) |
| An overload for hexadecimal strings where overflow results in the return of the maximum value. More...
|
|
template<typename T > |
static T | toUnsigned (const char *p, const char *end, bool &overflow, bool &invalid) noexcept |
| Low-level conversion from an unsigned decimal string to a number. More...
|
|
template<typename T > |
static T | toUnsigned (const char *&p, const char *end, bool &overflow) noexcept |
| Low-level conversion from an unsigned decimal string to a number. More...
|
|
static unsigned long | toULong (std::string_view s) |
| Converts string 's' to an unsigned long. More...
|
|
static unsigned long | toULong (std::string_view s1, std::string_view s2) |
| Overload that converts the first string if it can be converted without throwing, or otherwise the second string. More...
|
|
static unsigned short | toUShort (std::string_view s, Limited) |
| Converts string 's' to an unsigned short. More...
|
|
static unsigned short | toUShort (std::string_view s) |
| Converts string 's' to an unsigned short. More...
|
|
static void | toUpper (std::string &s) |
| Replaces all seven-bit lower-case characters in string 's' by upper-case characters. More...
|
|
static void | toLower (std::string &s) |
| Replaces all seven-bit upper-case characters in string 's' by lower-case characters. More...
|
|
static std::string | upper (std::string_view) |
| Returns a copy of 's' in which all seven-bit lower-case characters have been replaced by upper-case characters. More...
|
|
static std::string | lower (std::string_view) |
| Returns a copy of 's' in which all seven-bit upper-case characters have been replaced by lower-case characters. More...
|
|
static std::string | toPrintableAscii (const std::string &in, char escape='\\') |
| Returns a 7-bit printable representation of the given input string. More...
|
|
static std::string | toPrintableAscii (const std::wstring &in, wchar_t escape=L'\\') |
| Returns a 7-bit printable representation of the given input string. More...
|
|
static std::string | printable (const std::string &in, char escape='\\') |
| Returns a printable representation of the given input string, using chacter code ranges 0x20 to 0x7e and 0xa0 to 0xfe inclusive. More...
|
|
static std::string | printable (std::string_view in, char escape='\\') |
| Returns a printable representation of the given input string, using chacter code ranges 0x20 to 0x7e and 0xa0 to 0xfe inclusive. More...
|
|
static std::string | only (std::string_view allow_chars, std::string_view s) |
| Returns the 's' with all occurrences of the characters not appearing in the first string deleted. More...
|
|
static void | escape (std::string &s, char c_escape, std::string_view specials_in, std::string_view specials_out) |
| Prefixes each occurrence of one of the special-in characters with the escape character and its corresponding special-out character. More...
|
|
static void | escape (std::string &s) |
| Overload for 'normal' backslash escaping of whitespace. More...
|
|
static std::string | escaped (std::string_view, char c_escape, std::string_view specials_in, std::string_view specials_out) |
| Returns the escape()d string. More...
|
|
static std::string | escaped (std::string_view) |
| Returns the escape()d string. More...
|
|
static void | unescape (std::string &s, char c_escape, std::string_view specials_in, std::string_view specials_out) |
| Unescapes the string by replacing e-e with e, e-special-in with special-out, and e-other with other. More...
|
|
static void | unescape (std::string &s) |
| Overload for 'normal' unescaping where the string has backslash escaping of whitespace. More...
|
|
static std::string | unescaped (const std::string &s) |
| Returns the unescape()d version of s. More...
|
|
static std::string_view | meta () noexcept |
| Returns a list of shell meta-characters with a tilde as the first character. More...
|
|
static std::string | readLineFrom (std::istream &stream, std::string_view eol={}) |
| Reads a line from the stream using the given line terminator. More...
|
|
static std::istream & | readLine (std::istream &stream, std::string &result, std::string_view eol={}, bool pre_erase_result=true, std::size_t limit=0U) |
| Reads a line from the stream using the given line terminator, which may be multi-character. More...
|
|
static std::istream & | readLine (std::istream &stream, std::string &result, Eol, bool pre_erase_result=true, std::size_t limit=0U) |
| An overload where lines are terminated with some enumerated combination of CR, LF or CRLF. More...
|
|
static void | splitIntoTokens (const std::string &in, StringArray &out, std::string_view ws, char esc='\0') |
| Splits the string into 'ws'-delimited tokens. More...
|
|
static StringArray | splitIntoTokens (const std::string &in, std::string_view ws=Str::ws(), char esc='\0') |
| Overload that returns by value. More...
|
|
static void | splitIntoFields (std::string_view in, StringArray &out, char sep, char escape='\0', bool remove_escapes=true) |
| Splits the string into fields. More...
|
|
static StringArray | splitIntoFields (std::string_view in, char sep) |
| Overload that returns by value. More...
|
|
static std::string | dequote (const std::string &, char qq='\"' , char esc = '\\' , std::string_view ws = Str::ws() , std::string_view nbws = Str::ws() ) |
| Dequotes a string by removing unescaped quotes and escaping quoted whitespace, so "qq-aaa-esc-qq-bbb-ws-ccc-qq" becomes "aaa-qq-bbb-esc-ws-ccc". More...
|
|
static std::string | join (std::string_view sep, const StringArray &strings) |
| Concatenates an array of strings with separators. More...
|
|
static std::string | join (std::string_view sep, std::string_view s1, std::string_view s2, std::string_view s3={}, std::string_view s4={}, std::string_view s5={}, std::string_view s6={}, std::string_view s7={}, std::string_view s8={}, std::string_view s9={}) |
| Concatenates a small number of strings with separators. More...
|
|
static std::string | join (std::string_view sep, const StringMap &, std::string_view eq, std::string_view tail={}) |
| Concatenates entries in a map, where an entry is "<key><eq><value><tail>". More...
|
|
static StringArray | keys (const StringMap &string_map) |
| Extracts the keys from a map of strings. More...
|
|
static std::string | head (std::string_view in, std::size_t pos, std::string_view default_={}) |
| Returns the first part of the string up to just before the given position. More...
|
|
static std::string | head (std::string_view, std::string_view sep, bool default_empty=true) |
| Overload taking a separator string, and with the default as either the input string or the empty string. More...
|
|
static std::string_view | headView (std::string_view in, std::size_t pos, std::string_view default_={}) noexcept |
| Like head() but returning a view into the input string. More...
|
|
static std::string_view | headView (std::string_view in, std::string_view sep, bool default_empty=true) noexcept |
| Like head() but returning a view into the input string. More...
|
|
static std::string | tail (std::string_view in, std::size_t pos, std::string_view default_={}) |
| Returns the last part of the string after the given position. More...
|
|
static std::string | tail (std::string_view in, std::string_view sep, bool default_empty=true) |
| Overload taking a separator string, and with the default as either the input string or the empty string. More...
|
|
static std::string_view | tailView (std::string_view in, std::size_t pos, std::string_view default_={}) noexcept |
| Like tail() but returning a view into the input string. More...
|
|
static std::string_view | tailView (std::string_view in, std::string_view sep, bool default_empty=true) noexcept |
| Like tail() but returning a view into the input string. More...
|
|
static bool | match (std::string_view, std::string_view) noexcept |
| Returns true if the two strings are the same. More...
|
|
static bool | iless (std::string_view, std::string_view) noexcept |
| Returns true if the first string is lexicographically less than the first, after seven-bit lower-case letters have been folded to upper-case. More...
|
|
static bool | imatch (char, char) noexcept |
| Returns true if the two characters are the same, ignoring seven-bit case. More...
|
|
static bool | imatch (std::string_view, std::string_view) noexcept |
| Returns true if the two strings are the same, ignoring seven-bit case. More...
|
|
static std::size_t | ifind (std::string_view s, std::string_view key) |
| Returns the position of the key in 's' using a seven-bit case-insensitive search. More...
|
|
static std::size_t | ifindat (std::string_view s, std::string_view key, std::size_t pos) |
| Returns the position of the key in 's' at of after position 'pos' using a seven-bit case-insensitive search. More...
|
|
static bool | tailMatch (std::string_view in, std::string_view ending) noexcept |
| Returns true if the string has the given ending (or the given ending is empty). More...
|
|
static bool | headMatch (std::string_view in, std::string_view head) noexcept |
| Returns true if the string has the given start (or head is empty). More...
|
|
static std::string_view | ws () noexcept |
| Returns a string of standard whitespace characters. More...
|
|
static std::string_view | alnum () noexcept |
| Returns a string of seven-bit alphanumeric characters, ie A-Z, a-z and 0-9. More...
|
|
static std::string_view | alnum_ () noexcept |
| Returns alnum() with an additional trailing underscore character. More...
|
|
static std::string | positive () |
| Returns a default positive string. See isPositive(). More...
|
|
static std::string | negative () |
| Returns a default negative string. See isNegative(). More...
|
|
static bool | isPositive (std::string_view) noexcept |
| Returns true if the string has a positive meaning, such as "1", "true", "yes". More...
|
|
static bool | isNegative (std::string_view) noexcept |
| Returns true if the string has a negative meaning, such as "0", "false", "no". More...
|
|
static std::string | unique (const std::string &s, char c, char r) |
| Returns a string with repeated 'c' characters replaced by one 'r' character. More...
|
|
static std::string | unique (const std::string &s, char c) |
| An overload that replaces repeated 'c' characters by one 'c' character. More...
|
|
static errno_t | strncpy_s (char *dst, std::size_t n_dst, const char *src, std::size_t count) noexcept |
| Does the same as windows strncpy_s(). More...
|
|