|
SlHelpers
|
Various helpers on strings. More...
#include <String.h>
Classes | |
| struct | Eq |
| Equality test for string and string_view to be used in containers. More... | |
| struct | Hash |
| Hash for string and string_view to be used in hashing containers. More... | |
Public Member Functions | |
| template<std::ranges::input_range Range, typename Output > | |
| requires | requires (std::ostream &out, Output output, std::ranges::range_reference_t< Range > e) |
Join iterable into out using separator sep, calling output. More... | |
Static Public Member Functions | |
| template<typename I = unsigned> | |
| requires static std::is_integral_v< I > std::optional< I > | toNum (std::string_view str, int base=10) noexcept |
Convert str to a number. | |
| static bool constexpr | iEqual (unsigned char a, unsigned char b) noexcept |
| Compare two characters ignoring case. | |
| static constexpr std::string_view::size_type | iFind (std::string_view str, std::string_view sub) noexcept |
| Like string::find() but ignoring case. More... | |
| static constexpr bool | iStartsWith (std::string_view str, std::string_view prefix) noexcept |
| Like string::starts_with() but ignoring case. More... | |
| static constexpr bool | iEndsWith (std::string_view str, std::string_view suffix) noexcept |
| Like string::ends_with() but ignoring case. More... | |
| static void | eraseAllOf (std::string &s, std::string_view what) |
Erase any of characters in what from s. More... | |
| static void | replaceAll (std::string &s, std::string_view from, std::string_view to) |
Replace all occurrences of from in s with to. More... | |
| static std::vector< std::string_view > | splitSV (std::string_view str, std::string_view delim, std::optional< char > comment=std::nullopt) noexcept |
Split str by delim into a vector, ignoring everything after comment. More... | |
| template<typename T > | |
| static constexpr T | trim (const T &line) noexcept |
| Trim string (remove surrounding whitespace) More... | |
| static constexpr bool | isHex (std::string_view s) noexcept |
| Is the string consisting of hex number? More... | |
| static void | join (std::ostream &out, Range &&iterable, Output output, std::string_view sep=", ") |
| template<std::ranges::input_range Range> | |
| static void | join (std::ostream &out, Range &&iterable, std::string_view sep=", ", std::string_view quote="") |
Join iterable into out using separator sep and quoting quote. More... | |
Static Public Attributes | |
| static constinit const auto | npos = std::string_view::npos |
| A local alias for std::string_view::npos. | |
Various helpers on strings.
|
inlinestatic |
Erase any of characters in what from s.
| s | String to modify |
| what | Characters to erase |
|
inlinestaticnoexcept |
Like string::ends_with() but ignoring case.
| str | string to search in |
| suffix | string to search for |
str ends with suffix, false otherwise
|
inlinestaticnoexcept |
Like string::find() but ignoring case.
| str | string to search in |
| sub | string to search for |
sub in str if found, npos otherwise
|
inlinestaticnoexcept |
Is the string consisting of hex number?
| s | String to inspect |
|
inlinestaticnoexcept |
Like string::starts_with() but ignoring case.
| str | string to search in |
| prefix | string to search for |
str starts with prefix, false otherwise
|
inlinestatic |
Join iterable into out using separator sep and quoting quote.
| out | Output stream |
| iterable | Input container |
| sep | Separator |
| quote | Quoting string, it is put before and after each value in iterable |
|
inlinestatic |
|
inline |
Join iterable into out using separator sep, calling output.
| out | Output stream |
| iterable | Input container |
| output | Called for every member; it should output the member to out |
| sep | Separator |
|
inlinestaticnoexcept |
Split str by delim into a vector, ignoring everything after comment.
| str | String to parse |
| delim | Delimeter to split by |
| comment | Ignore string after character |
str.Note str must outlive the use of the return value!
|
inlinestaticnoexcept |