Various helpers on strings.
More...
#include <String.h>
|
| 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...
|
| |
|
| 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...
|
| |
|
|
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 constexpr std::string_view::size_type | iFind (std::string_view str, std::string_view sub) noexcept |
| | Like string::find() but ignoring case. More...
|
| |
| static std::vector< std::string > | split (std::string str, const std::string &delim, const std::optional< char > &comment=std::nullopt) noexcept |
| | Split a string into vector of strings, DO NOT USE THIS. 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 constinit const auto | npos = std::string_view::npos |
| | A local alias for std::string_view::npos.
|
| |
Various helpers on strings.
◆ iFind()
| static constexpr std::string_view::size_type SlHelpers::String::iFind |
( |
std::string_view |
str, |
|
|
std::string_view |
sub |
|
) |
| |
|
inlinestaticnoexcept |
Like string::find() but ignoring case.
- Parameters
-
| str | string to search in |
| sub | string to search for |
- Returns
- position of
sub in str if found, npos otherwise
◆ isHex()
| static constexpr bool SlHelpers::String::isHex |
( |
std::string_view |
s | ) |
|
|
inlinestaticnoexcept |
Is the string consisting of hex number?
- Parameters
-
- Returns
- true if all characters are hex numbers
◆ join()
template<std::ranges::input_range Range>
| static void SlHelpers::String::join |
( |
std::ostream & |
out, |
|
|
Range && |
iterable, |
|
|
std::string_view |
sep = ", ", |
|
|
std::string_view |
quote = "" |
|
) |
| |
|
inlinestatic |
Join iterable into out using separator sep and quoting quote.
- Parameters
-
| out | Output stream |
| iterable | Input container |
| sep | Separator |
| quote | Quoting string, it is put before and after each value in iterable |
◆ requires()
template<std::ranges::input_range Range, typename Output >
| requires SlHelpers::String::requires |
( |
std::ostream & |
out, |
|
|
Output |
output, |
|
|
std::ranges::range_reference_t< Range > |
e |
|
) |
| |
|
inline |
Join iterable into out using separator sep, calling output.
- Parameters
-
| out | Output stream |
| iterable | Input container |
| output | Called for every member; it should output the member to out |
| sep | Separator |
◆ split()
| static std::vector<std::string> SlHelpers::String::split |
( |
std::string |
str, |
|
|
const std::string & |
delim, |
|
|
const std::optional< char > & |
comment = std::nullopt |
|
) |
| |
|
inlinestaticnoexcept |
Split a string into vector of strings, DO NOT USE THIS.
- Parameters
-
- Returns
◆ splitSV()
| static std::vector<std::string_view> SlHelpers::String::splitSV |
( |
std::string_view |
str, |
|
|
std::string_view |
delim, |
|
|
std::optional< char > |
comment = std::nullopt |
|
) |
| |
|
inlinestaticnoexcept |
Split str by delim into a vector, ignoring everything after comment.
- Parameters
-
| str | String to parse |
| delim | Delimeter to split by |
| comment | Ignore string after character |
- Returns
- Vector built of
str.
Note str must outlive the use of the return value!
◆ trim()
template<typename T >
| static constexpr T SlHelpers::String::trim |
( |
const T & |
line | ) |
|
|
inlinestaticnoexcept |
Trim string (remove surrounding whitespace)
- Parameters
-
- Returns
- Trimmed string.
The documentation for this class was generated from the following file:
- /home/abuild/rpmbuild/BUILD/slhelpers-20260428.f233ce9/include/helpers/String.h