0
0
Fork 0
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:
Jason Volk 2017-09-15 12:04:52 -07:00
parent e71d650d83
commit 8efa3ca438

View file

@ -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)