0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::json: Stub an unescape().

This commit is contained in:
Jason Volk 2019-08-01 22:18:57 -07:00
parent 181ed12bd7
commit af48bdfa6e
3 changed files with 36 additions and 20 deletions

View file

@ -14,6 +14,13 @@
namespace ircd::json
{
struct string;
// note: in is not a json::string; all characters viewed are candidate
string escape(const mutable_buffer &out, const string_view &in);
// note: in is a json::string and return is a const_buffer to force
// explicit conversions because this operation generates binary data.
const_buffer unescape(const mutable_buffer &out, const string &in);
}
/// Strong type representing quoted strings in JSON (which may be unquoted

View file

@ -35,9 +35,6 @@ namespace ircd::json
// (Internal) validates output
void valid_output(const string_view &, const size_t &expected);
// Transforms input into escaped output only
string_view escape(const mutable_buffer &out, const string_view &in);
}
/// Alternative to `json::strung` which uses a fixed array rather than an

View file

@ -3176,6 +3176,35 @@ ircd::json::operator==(const member &a, const string_view &b)
return string_view{a.first.string, a.first.len} == b;
}
///////////////////////////////////////////////////////////////////////////////
//
// json/string.h
//
ircd::const_buffer
ircd::json::unescape(const mutable_buffer &buf,
const string &in)
{
throw ircd::not_implemented{};
}
ircd::json::string
ircd::json::escape(const mutable_buffer &buf,
const string_view &in)
{
static const printer::rule<string_view> characters
{
*(printer.character)
};
mutable_buffer out{buf};
printer(out, characters, in);
return string_view
{
data(buf), data(out)
};
}
///////////////////////////////////////////////////////////////////////////////
//
// json/value.h
@ -3913,23 +3942,6 @@ static_assert
ircd::json::undefined_number != 0
);
ircd::string_view
ircd::json::escape(const mutable_buffer &buf,
const string_view &in)
{
static const printer::rule<string_view> characters
{
*(printer.character)
};
mutable_buffer out{buf};
printer(out, characters, in);
return string_view
{
data(buf), data(out)
};
}
std::string
ircd::json::why(const string_view &s)
try