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:
parent
8ef0b50131
commit
6a8393ec02
1 changed files with 10 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue