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:
parent
61e6f0dada
commit
acf948ef8f
1 changed files with 12 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue