0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

ircd: Add unquote() util for quoted string views.

This commit is contained in:
Jason Volk 2017-03-17 20:26:04 -07:00
parent 8ef0b50131
commit 6a8393ec02

View file

@ -181,15 +181,21 @@ bool endswith(const string_view &str, const char &val);
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);
string_view unquote(string_view str);
} // namespace ircd
template<class T>
ircd::string_view
ircd::lex_cast(const T &t)
inline ircd::string_view
ircd::unquote(string_view str)
{
return lex_cast<T>(t, nullptr, 0);
if(startswith(str, '"'))
str = { str.data() + 1, str.data() + str.size() };
if(endswith(str, '"'))
str = { str.data(), str.data() + str.size() - 1 };
return str;
}
inline bool