mirror of
https://github.com/matrix-construct/construct
synced 2025-03-14 05:20:17 +01:00
ircd::stringops: Add stripa() w/ default std::isspace() dict.
This commit is contained in:
parent
7d713e19ab
commit
3eec22db69
1 changed files with 11 additions and 3 deletions
|
@ -25,11 +25,10 @@ namespace ircd
|
|||
using string_views = vector_view<const string_view>;
|
||||
size_t indexof(const string_view &, const string_views &) noexcept;
|
||||
|
||||
// return view without any trailing characters contained in c
|
||||
// return view without any {l=leading,r=trailing} characters contained in c
|
||||
string_view rstripa(const string_view &str, const string_view &c);
|
||||
|
||||
// return view without any leading characters contained in c
|
||||
string_view lstripa(const string_view &str, const string_view &c);
|
||||
string_view stripa(const string_view &str, const string_view &dict = "\t\n\v\f\r\x20");
|
||||
|
||||
// return view without leading occurrences of c
|
||||
string_view lstrip(const string_view &str, const char &c = ' ');
|
||||
|
@ -536,6 +535,15 @@ ircd::lstrip(const string_view &str,
|
|||
string_view{str.data(), size_t{0}};
|
||||
}
|
||||
|
||||
/// Strip any of the leading and trailing characters in the dictionary.
|
||||
/// The default dictionary is std::isspace/whitespace.
|
||||
inline ircd::string_view
|
||||
ircd::stripa(const string_view &str,
|
||||
const string_view &dict)
|
||||
{
|
||||
return rstripa(lstripa(str, dict), dict);
|
||||
}
|
||||
|
||||
/// Remove leading instances of any character in c from the returned view
|
||||
inline ircd::string_view
|
||||
ircd::lstripa(const string_view &str,
|
||||
|
|
Loading…
Add table
Reference in a new issue