mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd: Add surrounds() lexical util.
This commit is contained in:
parent
e71d650d83
commit
8efa3ca438
1 changed files with 16 additions and 0 deletions
|
@ -186,6 +186,8 @@ namespace ircd
|
|||
template<class It> bool endswith_any(const string_view &str, const It &begin, const It &end);
|
||||
bool startswith(const string_view &str, const string_view &val);
|
||||
bool startswith(const string_view &str, const char &val);
|
||||
bool surrounds(const string_view &str, const string_view &val);
|
||||
bool surrounds(const string_view &str, const char &val);
|
||||
string_view unquote(string_view str);
|
||||
std::string unquote(std::string &&);
|
||||
}
|
||||
|
@ -214,6 +216,20 @@ ircd::unquote(string_view str)
|
|||
return str;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::surrounds(const string_view &str,
|
||||
const char &val)
|
||||
{
|
||||
return str.size() >= 2 && str.front() == val && str.back() == val;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::surrounds(const string_view &str,
|
||||
const string_view &val)
|
||||
{
|
||||
return startswith(str, val) && endswith(str, val);
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::startswith(const string_view &str,
|
||||
const char &val)
|
||||
|
|
Loading…
Reference in a new issue