0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-14 00:34:18 +01:00

ircd: Add strip(n) proxy overloads to interface.

This commit is contained in:
Jason Volk 2020-07-23 12:54:52 -07:00
parent 1cf03d8608
commit 238a473b08

View file

@ -46,6 +46,8 @@ namespace ircd
// return view without leading and trailing occurrences of c
string_view strip(const string_view &str, const char &c = ' ');
string_view strip(const string_view &str, const string_view &c);
string_view strip(const string_view &str, const string_view &c, const size_t n);
string_view strip(const string_view &str, const char &c, const size_t n);
// split view on first match of delim; delim not included; if no delim then .second empty
std::pair<string_view, string_view> split(const string_view &str, const char &delim = ' ');
@ -437,6 +439,24 @@ ircd::split(const string_view &str,
pair { str, string_view{} };
}
/// Remove n leading and trailing instances of c from the returned view
inline ircd::string_view
ircd::strip(const string_view &str,
const string_view &c,
const size_t n)
{
return lstrip(rstrip(str, c, n), c, n);
}
/// Remove n leading and trailing instances of c from the returned view
inline ircd::string_view
ircd::strip(const string_view &str,
const char &c,
const size_t n)
{
return lstrip(rstrip(str, c, n), c, n);
}
/// Remove leading and trailing instances of c from the returned view
inline ircd::string_view
ircd::strip(const string_view &str,