Metall  v0.28
A persistent memory allocator for data-centric analytics
metall::json Namespace Reference

Namespace for Metall JSON container, which is in an experimental phase. More...

Namespaces

 jsndtl
 

Classes

class  array
 JSON array. An array is an ordered collection of values. More...
 
class  key_value_pair
 A class for holding a pair of JSON string (as its key) and JSON value (as its value). More...
 
class  object
 JSON object. An object is a table key and value pairs. The order of key-value pairs depends on the implementation. More...
 
class  value
 JSON value. A container that holds a single bool, int64, uint64, double, JSON string, JSON array, or JSON object. More...
 

Typedefs

using null_type = std::monostate
 JSON null type. More...
 
template<typename char_t , typename traits , typename allocator_type >
using basic_string = metall::container::basic_string< char_t, traits, allocator_type >
 JSON basic string type. More...
 
template<typename allocator_type = std::allocator<std::byte>>
using string = basic_string< char, std::char_traits< char >, allocator_type >
 JSON string. More...
 

Functions

template<typename allocator_type >
void swap (array< allocator_type > &lhd, array< allocator_type > &rhd) noexcept
 Swap value instances. More...
 
template<typename char_type , typename char_traits , typename allocator_type >
bool operator== (const key_value_pair< char_type, char_traits, allocator_type > &key_value, const bj::key_value_pair &bj_key_value)
 
template<typename char_type , typename char_traits , typename allocator_type >
bool operator== (const bj::key_value_pair &bj_key_value, const key_value_pair< char_type, char_traits, allocator_type > &key_value)
 
template<typename char_type , typename char_traits , typename allocator_type >
bool operator!= (const key_value_pair< char_type, char_traits, allocator_type > &key_value, const bj::key_value_pair &bj_key_value)
 
template<typename char_type , typename char_traits , typename allocator_type >
bool operator!= (const bj::key_value_pair &bj_key_value, const key_value_pair< char_type, char_traits, allocator_type > &key_value)
 
template<typename allocator_type >
bool operator== (const value< allocator_type > &value, const bj::value &bj_value)
 
template<typename allocator_type >
bool operator== (const bj::value &bj_value, const value< allocator_type > &value)
 
template<typename allocator_type >
bool operator!= (const value< allocator_type > &value, const bj::value &bj_value)
 
template<typename allocator_type >
bool operator!= (const bj::value &bj_value, const value< allocator_type > &value)
 
template<typename allocator_type >
bool operator== (const array< allocator_type > &array, const bj::array &bj_array)
 
template<typename allocator_type >
bool operator== (const bj::array &bj_array, const array< allocator_type > &array)
 
template<typename allocator_type >
bool operator!= (const array< allocator_type > &array, const bj::array &bj_array)
 
template<typename allocator_type >
bool operator!= (const bj::array &bj_array, const array< allocator_type > &array)
 
template<typename allocator_type >
bool operator== (const object< allocator_type > &object, const bj::object &bj_object)
 
template<typename allocator_type >
bool operator== (const bj::object &bj_object, const object< allocator_type > &object)
 
template<typename allocator_type >
bool operator!= (const object< allocator_type > &object, const bj::object &bj_object)
 
template<typename allocator_type >
bool operator!= (const bj::object &bj_object, const object< allocator_type > &object)
 
template<typename char_t , typename traits , typename allocator >
bool operator== (const basic_string< char_t, traits, allocator > &string, const bj::string &bj_string)
 
template<typename char_t , typename traits , typename allocator >
bool operator== (const bj::string &bj_string, const basic_string< char_t, traits, allocator > &string)
 
template<typename char_t , typename traits , typename allocator >
bool operator!= (const basic_string< char_t, traits, allocator > &string, const bj::string &bj_string)
 
template<typename char_t , typename traits , typename allocator >
bool operator!= (const bj::string &bj_string, const basic_string< char_t, traits, allocator > &string)
 
template<typename char_type , typename char_traits , typename allocator_type >
void swap (key_value_pair< char_type, char_traits, allocator_type > &rhd, key_value_pair< char_type, char_traits, allocator_type > &lhd) noexcept
 Swap value instances. More...
 
template<typename allocator_type >
void swap (object< allocator_type > &lhd, object< allocator_type > &rhd) noexcept
 Swap value instances. More...
 
template<typename allocator_type = std::allocator<std::byte>>
value< allocator_type > parse (std::string_view input_json_string, const allocator_type &allocator=allocator_type())
 Parses a JSON represented as a string. More...
 
template<typename allocator_type , int indent_size = 2>
void pretty_print (std::ostream &os, const value< allocator_type > &json_value)
 Pretty-prints a JSON value. More...
 
template<typename allocator_type >
std::string serialize (const value< allocator_type > &input)
 
template<typename allocator_type >
std::string serialize (const object< allocator_type > &input)
 
template<typename allocator_type >
std::string serialize (const array< allocator_type > &input)
 
template<typename char_type , typename traits , typename allocator_type >
std::string serialize (const basic_string< char_type, traits, allocator_type > &input)
 
template<typename allocator_type >
std::ostream & operator<< (std::ostream &os, const value< allocator_type > &val)
 
template<typename allocator_type >
std::ostream & operator<< (std::ostream &os, const object< allocator_type > &obj)
 
template<typename allocator_type >
std::ostream & operator<< (std::ostream &os, const array< allocator_type > &arr)
 
template<typename allocator_type >
void swap (value< allocator_type > &lhd, value< allocator_type > &rhd) noexcept
 Swap value instances. More...
 
template<typename T , typename allocator_type = std::allocator<std::byte>>
value< allocator_type > value_from (T &&input_data, const allocator_type &allocator=allocator_type())
 Convert an input data and construct a JSON value. More...
 
template<typename T , typename allocator_type >
value_to (const mj::value< allocator_type > &value)
 Convert a JSON value to another data type. More...
 

Detailed Description

Namespace for Metall JSON container, which is in an experimental phase.

Typedef Documentation

◆ null_type

using metall::json::null_type = typedef std::monostate

JSON null type.

◆ basic_string

template<typename char_t , typename traits , typename allocator_type >
using metall::json::basic_string = typedef metall::container::basic_string<char_t, traits, allocator_type>

JSON basic string type.

◆ string

template<typename allocator_type = std::allocator<std::byte>>
using metall::json::string = typedef basic_string<char, std::char_traits<char>, allocator_type>

JSON string.

Function Documentation

◆ swap() [1/4]

template<typename allocator_type >
void metall::json::swap ( array< allocator_type > &  lhd,
array< allocator_type > &  rhd 
)
inlinenoexcept

Swap value instances.

◆ operator==() [1/10]

template<typename char_type , typename char_traits , typename allocator_type >
bool metall::json::operator== ( const key_value_pair< char_type, char_traits, allocator_type > &  key_value,
const bj::key_value_pair &  bj_key_value 
)
inline

◆ operator==() [2/10]

template<typename char_type , typename char_traits , typename allocator_type >
bool metall::json::operator== ( const bj::key_value_pair &  bj_key_value,
const key_value_pair< char_type, char_traits, allocator_type > &  key_value 
)
inline

◆ operator!=() [1/10]

template<typename char_type , typename char_traits , typename allocator_type >
bool metall::json::operator!= ( const key_value_pair< char_type, char_traits, allocator_type > &  key_value,
const bj::key_value_pair &  bj_key_value 
)
inline

◆ operator!=() [2/10]

template<typename char_type , typename char_traits , typename allocator_type >
bool metall::json::operator!= ( const bj::key_value_pair &  bj_key_value,
const key_value_pair< char_type, char_traits, allocator_type > &  key_value 
)
inline

◆ operator==() [3/10]

template<typename allocator_type >
bool metall::json::operator== ( const value< allocator_type > &  value,
const bj::value &  bj_value 
)
inline

◆ operator==() [4/10]

template<typename allocator_type >
bool metall::json::operator== ( const bj::value &  bj_value,
const value< allocator_type > &  value 
)
inline

◆ operator!=() [3/10]

template<typename allocator_type >
bool metall::json::operator!= ( const value< allocator_type > &  value,
const bj::value &  bj_value 
)
inline

◆ operator!=() [4/10]

template<typename allocator_type >
bool metall::json::operator!= ( const bj::value &  bj_value,
const value< allocator_type > &  value 
)
inline

◆ operator==() [5/10]

template<typename allocator_type >
bool metall::json::operator== ( const array< allocator_type > &  array,
const bj::array &  bj_array 
)
inline

◆ operator==() [6/10]

template<typename allocator_type >
bool metall::json::operator== ( const bj::array &  bj_array,
const array< allocator_type > &  array 
)
inline

◆ operator!=() [5/10]

template<typename allocator_type >
bool metall::json::operator!= ( const array< allocator_type > &  array,
const bj::array &  bj_array 
)
inline

◆ operator!=() [6/10]

template<typename allocator_type >
bool metall::json::operator!= ( const bj::array &  bj_array,
const array< allocator_type > &  array 
)
inline

◆ operator==() [7/10]

template<typename allocator_type >
bool metall::json::operator== ( const object< allocator_type > &  object,
const bj::object &  bj_object 
)
inline

◆ operator==() [8/10]

template<typename allocator_type >
bool metall::json::operator== ( const bj::object &  bj_object,
const object< allocator_type > &  object 
)
inline

◆ operator!=() [7/10]

template<typename allocator_type >
bool metall::json::operator!= ( const object< allocator_type > &  object,
const bj::object &  bj_object 
)
inline

◆ operator!=() [8/10]

template<typename allocator_type >
bool metall::json::operator!= ( const bj::object &  bj_object,
const object< allocator_type > &  object 
)
inline

◆ operator==() [9/10]

template<typename char_t , typename traits , typename allocator >
bool metall::json::operator== ( const basic_string< char_t, traits, allocator > &  string,
const bj::string &  bj_string 
)
inline

◆ operator==() [10/10]

template<typename char_t , typename traits , typename allocator >
bool metall::json::operator== ( const bj::string &  bj_string,
const basic_string< char_t, traits, allocator > &  string 
)
inline

◆ operator!=() [9/10]

template<typename char_t , typename traits , typename allocator >
bool metall::json::operator!= ( const basic_string< char_t, traits, allocator > &  string,
const bj::string &  bj_string 
)
inline

◆ operator!=() [10/10]

template<typename char_t , typename traits , typename allocator >
bool metall::json::operator!= ( const bj::string &  bj_string,
const basic_string< char_t, traits, allocator > &  string 
)
inline

◆ swap() [2/4]

template<typename char_type , typename char_traits , typename allocator_type >
void metall::json::swap ( key_value_pair< char_type, char_traits, allocator_type > &  rhd,
key_value_pair< char_type, char_traits, allocator_type > &  lhd 
)
inlinenoexcept

Swap value instances.

◆ swap() [3/4]

template<typename allocator_type >
void metall::json::swap ( object< allocator_type > &  lhd,
object< allocator_type > &  rhd 
)
inlinenoexcept

Swap value instances.

◆ parse()

template<typename allocator_type = std::allocator<std::byte>>
value<allocator_type> metall::json::parse ( std::string_view  input_json_string,
const allocator_type &  allocator = allocator_type() 
)
inline

Parses a JSON represented as a string.

Template Parameters
allocator_typeAn allocator type.
Parameters
input_json_stringAn input JSON string.
allocatorAn allocator object.
Returns
Returns a constructed value.
Examples
jgraph.cpp, and json_create.cpp.

◆ pretty_print()

template<typename allocator_type , int indent_size = 2>
void metall::json::pretty_print ( std::ostream &  os,
const value< allocator_type > &  json_value 
)
inline

Pretty-prints a JSON value.

Template Parameters
allocator_typeAn allocator type used in the value.
indent_sizeThe size of the indent when going to a lower layer.
Parameters
osAn output stream object.
json_valueA JSON value to print.
Examples
jgraph.cpp, json_create.cpp, and json_open.cpp.

◆ serialize() [1/4]

template<typename allocator_type >
std::string metall::json::serialize ( const value< allocator_type > &  input)

◆ serialize() [2/4]

template<typename allocator_type >
std::string metall::json::serialize ( const object< allocator_type > &  input)

◆ serialize() [3/4]

template<typename allocator_type >
std::string metall::json::serialize ( const array< allocator_type > &  input)

◆ serialize() [4/4]

template<typename char_type , typename traits , typename allocator_type >
std::string metall::json::serialize ( const basic_string< char_type, traits, allocator_type > &  input)

◆ operator<<() [1/3]

template<typename allocator_type >
std::ostream& metall::json::operator<< ( std::ostream &  os,
const value< allocator_type > &  val 
)

◆ operator<<() [2/3]

template<typename allocator_type >
std::ostream& metall::json::operator<< ( std::ostream &  os,
const object< allocator_type > &  obj 
)

◆ operator<<() [3/3]

template<typename allocator_type >
std::ostream& metall::json::operator<< ( std::ostream &  os,
const array< allocator_type > &  arr 
)

◆ swap() [4/4]

template<typename allocator_type >
void metall::json::swap ( value< allocator_type > &  lhd,
value< allocator_type > &  rhd 
)
inlinenoexcept

Swap value instances.

◆ value_from()

template<typename T , typename allocator_type = std::allocator<std::byte>>
value<allocator_type> metall::json::value_from ( T &&  input_data,
const allocator_type &  allocator = allocator_type() 
)
inline

Convert an input data and construct a JSON value.

Template Parameters
TThe type of an input data.
allocator_typeAn allocator type to allocate a return value.
Parameters
input_dataInput data.
allocatorAn allocator object.
Returns
Returns a constructed JSON value.

◆ value_to()

template<typename T , typename allocator_type >
T metall::json::value_to ( const mj::value< allocator_type > &  value)

Convert a JSON value to another data type.

Template Parameters
TThe type to convert.
allocator_typeThe allocator type of the input.
Parameters
valueAn input JSON value.
Returns
An instance of T that contains the data in 'value'.