mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::json: Safer unquote for json::string constructions; specify constructions.
This commit is contained in:
parent
2b2725f7c1
commit
a441c77b6b
1 changed files with 20 additions and 4 deletions
|
@ -50,11 +50,27 @@ namespace ircd::json
|
|||
struct ircd::json::string
|
||||
:string_view
|
||||
{
|
||||
string(const string_view &s)
|
||||
:string_view{unquote(s)}
|
||||
{}
|
||||
|
||||
string() = default;
|
||||
string(json::string &&) = default;
|
||||
string(const json::string &) = default;
|
||||
string(const string_view &s)
|
||||
:string_view
|
||||
{
|
||||
surrounds(s, '"')?
|
||||
unquote(s):
|
||||
s
|
||||
}{}
|
||||
|
||||
string &operator=(json::string &&) = default;
|
||||
string &operator=(const json::string &) = default;
|
||||
string &operator=(const string_view &s)
|
||||
{
|
||||
*static_cast<string_view *>(this) = surrounds(s, '"')?
|
||||
unquote(s):
|
||||
s;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/// Alternative to `json::strung` which uses a fixed array rather than an
|
||||
|
|
Loading…
Reference in a new issue