mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::json: Move these outside of value class.
This commit is contained in:
parent
e4863aa073
commit
ac27005cd7
2 changed files with 23 additions and 25 deletions
|
@ -26,10 +26,17 @@ namespace ircd::json
|
|||
{
|
||||
struct value;
|
||||
|
||||
using values = std::initializer_list<value>;
|
||||
|
||||
extern const string_view literal_null;
|
||||
extern const string_view literal_true;
|
||||
extern const string_view literal_false;
|
||||
extern const string_view empty_string;
|
||||
extern const string_view empty_object;
|
||||
extern const string_view empty_array;
|
||||
|
||||
size_t serialized(const bool &);
|
||||
size_t serialized(const value *const &begin, const value *const &end);
|
||||
|
||||
using values = std::initializer_list<value>;
|
||||
size_t serialized(const values &);
|
||||
|
||||
string_view stringify(mutable_buffer &, const value *const &begin, const value *const &end);
|
||||
|
@ -82,14 +89,6 @@ struct ircd::json::value
|
|||
uint64_t alloc : 1; ///< indicates the pointer for type is owned
|
||||
uint64_t floats : 1; ///< for NUMBER type, integer or floating
|
||||
|
||||
static const string_view literal_null;
|
||||
static const string_view literal_true;
|
||||
static const string_view literal_false;
|
||||
static const string_view empty_string;
|
||||
static const string_view empty_number;
|
||||
static const string_view empty_object;
|
||||
static const string_view empty_array;
|
||||
|
||||
using create_string_closure = std::function<void (const mutable_buffer &)>;
|
||||
void create_string(const size_t &len, const create_string_closure &);
|
||||
|
||||
|
|
29
ircd/json.cc
29
ircd/json.cc
|
@ -857,8 +857,8 @@ ircd::json::stringify(mutable_buffer &buf,
|
|||
{
|
||||
if(string_view{v}.empty())
|
||||
{
|
||||
consume(buf, copy(buf, value::empty_array));
|
||||
return value::empty_array;
|
||||
consume(buf, copy(buf, empty_array));
|
||||
return empty_array;
|
||||
}
|
||||
|
||||
consume(buf, copy(buf, string_view{v}));
|
||||
|
@ -1000,13 +1000,12 @@ const
|
|||
// json/value.h
|
||||
//
|
||||
|
||||
const ircd::string_view ircd::json::value::literal_null {"null"};
|
||||
const ircd::string_view ircd::json::value::literal_true {"true"};
|
||||
const ircd::string_view ircd::json::value::literal_false {"false"};
|
||||
const ircd::string_view ircd::json::value::empty_string {"\"\""};
|
||||
const ircd::string_view ircd::json::value::empty_number {"0"};
|
||||
const ircd::string_view ircd::json::value::empty_object {"{}"};
|
||||
const ircd::string_view ircd::json::value::empty_array {"[]"};
|
||||
const ircd::string_view ircd::json::literal_null { "null" };
|
||||
const ircd::string_view ircd::json::literal_true { "true" };
|
||||
const ircd::string_view ircd::json::literal_false { "false" };
|
||||
const ircd::string_view ircd::json::empty_string { "\"\"" };
|
||||
const ircd::string_view ircd::json::empty_object { "{}" };
|
||||
const ircd::string_view ircd::json::empty_array { "[]" };
|
||||
|
||||
std::ostream &
|
||||
ircd::json::operator<<(std::ostream &s, const value &v)
|
||||
|
@ -1073,8 +1072,8 @@ ircd::json::stringify(mutable_buffer &buf,
|
|||
break;
|
||||
}
|
||||
|
||||
//consume(buf, copy(buf, v.literal_null));
|
||||
consume(buf, copy(buf, v.empty_object));
|
||||
//consume(buf, copy(buf, literal_null));
|
||||
consume(buf, copy(buf, empty_object));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1092,8 +1091,8 @@ ircd::json::stringify(mutable_buffer &buf,
|
|||
break;
|
||||
}
|
||||
|
||||
//consume(buf, copy(buf, v.literal_null));
|
||||
consume(buf, copy(buf, v.empty_array));
|
||||
//consume(buf, copy(buf, literal_null));
|
||||
consume(buf, copy(buf, empty_array));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1632,8 +1631,8 @@ ircd::json::stringify(mutable_buffer &buf,
|
|||
{
|
||||
if(v.empty() && defined(v))
|
||||
{
|
||||
consume(buf, copy(buf, value::empty_string));
|
||||
return value::empty_string;
|
||||
consume(buf, copy(buf, empty_string));
|
||||
return empty_string;
|
||||
}
|
||||
|
||||
consume(buf, copy(buf, string_view{v}));
|
||||
|
|
Loading…
Reference in a new issue