0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-15 17:16:49 +01:00

ircd: Add unquote() for rvalue references to strings (won't copy).

This commit is contained in:
Jason Volk 2017-03-30 15:50:54 -07:00
parent 61e6f0dada
commit acf948ef8f

View file

@ -181,9 +181,21 @@ template<class It> bool endswith_any(const string_view &str, const It &begin, co
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);
std::string unquote(std::string &&);
} // namespace ircd
inline std::string
ircd::unquote(std::string &&str)
{
if(endswith(str, '"'))
str.pop_back();
if(startswith(str, '"'))
str = str.substr(1);
return std::move(str);
}
inline ircd::string_view
ircd::unquote(string_view str)