0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::json: Stub a canonize() function which isn't complete yet.

This commit is contained in:
Jason Volk 2017-11-30 10:48:30 -08:00
parent 14f348f900
commit d354991c68
2 changed files with 26 additions and 0 deletions

View file

@ -78,6 +78,10 @@ namespace ircd::json
// Validate JSON - checks if canonical value.
bool valid(const string_view &, std::nothrow_t) noexcept;
void valid(const string_view &);
// Convert to canonical JSON
string_view canonize(const mutable_buffer &out, const string_view &in);
std::string canonize(const string_view &in);
}
/// Strong type representing quoted strings in JSON (which may be unquoted

View file

@ -1486,6 +1486,28 @@ ircd::json::operator==(const value &a, const value &b)
// json.h
//
std::string
ircd::json::canonize(const string_view &in)
{
std::string ret(size(in), char{});
ret.resize(size(canonize(mutable_buffer{ret}, in)));
return ret;
}
ircd::string_view
ircd::json::canonize(const mutable_buffer &out,
const string_view &in)
try
{
//TODO: XXX
assert(0);
return in;
}
catch(const qi::expectation_failure<const char *> &e)
{
throw expectation_failure(begin(in), e);
}
bool
ircd::json::valid(const string_view &s,
std::nothrow_t)