Metall  v0.29
A persistent memory allocator for data-centric analytics
metall::json::value< Alloc > Class Template Reference

JSON value. A container that holds a single bool, int64, uint64, double, JSON string, JSON array, or JSON object. More...

#include </home/runner/work/metall/metall/include/metall/json/value.hpp>

Public Types

using allocator_type = Alloc
 
using string_type = basic_string< char, std::char_traits< char >, typename std::allocator_traits< allocator_type >::template rebind_alloc< char > >
 
using object_type = object< Alloc >
 
using array_type = array< Alloc >
 

Public Member Functions

 value ()
 Constructor. More...
 
 value (const allocator_type &alloc)
 Constructor. More...
 
 value (const value &other)
 Copy constructor. More...
 
 value (const value &other, const allocator_type &alloc)
 Allocator-extended copy constructor. More...
 
 value (value &&other) noexcept
 Move constructor. More...
 
 value (value &&other, const allocator_type &alloc) noexcept
 Allocator-extended move constructor. More...
 
 ~value () noexcept
 Destructor. More...
 
valueoperator= (const value &other)
 Copy assignment operator. More...
 
valueoperator= (value &&other) noexcept
 Move assignment operator. More...
 
void swap (value &other) noexcept
 Swap contents. More...
 
valueoperator= (const bool b)
 Assign a bool value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const signed char i)
 Assign a char value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const short i)
 Assign a short value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const int i)
 Assign an int value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const long i)
 Assign a long value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const long long i)
 Assign a long long value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const unsigned char u)
 Assign an unsigned char value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const unsigned short u)
 Assign an unsigned short value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const unsigned int u)
 Assign an unsigned int value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const unsigned long u)
 Assign an unsigned long value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const unsigned long long u)
 Assign an unsigned long long value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (std::nullptr_t)
 Assign a null value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const double d)
 Assign a double value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (std::string_view s)
 Assign a std::string_view value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const char *const s)
 Assign a const char* value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const string_type &s)
 Assign a string_type value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (string_type &&s)
 Assign a string_type value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const array_type &arr)
 Assign an array_type value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (array_type &&arr)
 Assign an array_type value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (const object_type &obj)
 Assign an object_type value. Allocates a memory storage or destroy the old content, if necessary. More...
 
valueoperator= (object_type &&obj)
 Assign an object_type value. Allocates a memory storage or destroy the old content, if necessary. More...
 
void emplace_null ()
 Set a null. The old content is destroyed. More...
 
bool & emplace_bool ()
 Set a bool and return a reference. The old content is destroyed. More...
 
std::int64_t & emplace_int64 ()
 Set a int64 and return a reference. The old content is destroyed. More...
 
std::uint64_t & emplace_uint64 ()
 Set a uint64 and return a reference. The old content is destroyed. More...
 
double & emplace_double ()
 Set a double and return a reference. The old content is destroyed. More...
 
string_typeemplace_string ()
 Set an empty string and return a reference. The old content is destroyed. More...
 
array_typeemplace_array ()
 Set an empty array and return a reference. The old content is destroyed. More...
 
object_typeemplace_object ()
 Set an empty object and return a reference. The old content is destroyed. More...
 
bool & as_bool ()
 Return a reference to the underlying bool, or throw an exception. More...
 
const bool & as_bool () const
 Return a const reference to the underlying bool, or throw an exception. More...
 
std::int64_t & as_int64 ()
 Return a reference to the underlying std::int64_t, or throw an exception. More...
 
const std::int64_t & as_int64 () const
 Return a const reference to the underlying std::int64_t, or throw an exception. More...
 
std::uint64_t & as_uint64 ()
 Return a reference to the underlying std::uint64_t, or throw an exception. More...
 
const std::uint64_t & as_uint64 () const
 Return a const reference to the underlying std::uint64_t, or throw an exception. More...
 
double & as_double ()
 Return a reference to the underlying double, or throw an exception. More...
 
const double & as_double () const
 Return a const reference to the underlying double, or throw an exception. More...
 
string_typeas_string ()
 Return a reference to the underlying string, or throw an exception. More...
 
const string_typeas_string () const
 Return a const reference to the underlying string, or throw an exception. More...
 
array_typeas_array ()
 Return a reference to the underlying array, or throw an exception. More...
 
const array_typeas_array () const
 Return a const reference to the underlying array, or throw an exception. More...
 
object_typeas_object ()
 Return a reference to the underlying object, or throw an exception. More...
 
const object_typeas_object () const
 Return a const reference to the underlying object, or throw an exception. More...
 
bool is_null () const noexcept
 Return true if this is a null. More...
 
bool is_bool () const noexcept
 Return true if this is a bool. More...
 
bool is_int64 () const noexcept
 Return true if this is a int64. More...
 
bool is_uint64 () const noexcept
 Return true if this is a uint64. More...
 
bool is_double () const noexcept
 Return true if this is a double. More...
 
bool is_string () const noexcept
 Return true if this is a string. More...
 
bool is_array () const noexcept
 Return true if this is an array. More...
 
bool is_object () const noexcept
 Return true if this is a object. More...
 
allocator_type get_allocator () const noexcept
 Return an allocator object. More...
 

Friends

bool operator== (const value &lhs, const value &rhs) noexcept
 Equal operator. More...
 
bool operator!= (const value &lhs, const value &rhs) noexcept
 Return true if two values are not equal. Two values are equal when they are the same kind and their referenced values are equal, or when they are both integral types and their integral representations are equal. More...
 

Detailed Description

template<typename Alloc = std::allocator<std::byte>>
class metall::json::value< Alloc >

JSON value. A container that holds a single bool, int64, uint64, double, JSON string, JSON array, or JSON object.

Examples
json_create.cpp, and json_open.cpp.

Member Typedef Documentation

◆ allocator_type

template<typename Alloc = std::allocator<std::byte>>
using metall::json::value< Alloc >::allocator_type = Alloc

◆ string_type

template<typename Alloc = std::allocator<std::byte>>
using metall::json::value< Alloc >::string_type = basic_string<char, std::char_traits<char>, typename std::allocator_traits< allocator_type>::template rebind_alloc<char> >

◆ object_type

template<typename Alloc = std::allocator<std::byte>>
using metall::json::value< Alloc >::object_type = object<Alloc>

◆ array_type

template<typename Alloc = std::allocator<std::byte>>
using metall::json::value< Alloc >::array_type = array<Alloc>

Constructor & Destructor Documentation

◆ value() [1/6]

template<typename Alloc = std::allocator<std::byte>>
metall::json::value< Alloc >::value ( )
inline

Constructor.

◆ value() [2/6]

template<typename Alloc = std::allocator<std::byte>>
metall::json::value< Alloc >::value ( const allocator_type alloc)
inlineexplicit

Constructor.

Parameters
allocAn allocator object.

◆ value() [3/6]

template<typename Alloc = std::allocator<std::byte>>
metall::json::value< Alloc >::value ( const value< Alloc > &  other)
inline

Copy constructor.

◆ value() [4/6]

template<typename Alloc = std::allocator<std::byte>>
metall::json::value< Alloc >::value ( const value< Alloc > &  other,
const allocator_type alloc 
)
inline

Allocator-extended copy constructor.

◆ value() [5/6]

template<typename Alloc = std::allocator<std::byte>>
metall::json::value< Alloc >::value ( value< Alloc > &&  other)
inlinenoexcept

Move constructor.

◆ value() [6/6]

template<typename Alloc = std::allocator<std::byte>>
metall::json::value< Alloc >::value ( value< Alloc > &&  other,
const allocator_type alloc 
)
inlinenoexcept

Allocator-extended move constructor.

◆ ~value()

template<typename Alloc = std::allocator<std::byte>>
metall::json::value< Alloc >::~value ( )
inlinenoexcept

Destructor.

Member Function Documentation

◆ operator=() [1/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const value< Alloc > &  other)
inline

Copy assignment operator.

◆ operator=() [2/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( value< Alloc > &&  other)
inlinenoexcept

Move assignment operator.

◆ swap()

template<typename Alloc = std::allocator<std::byte>>
void metall::json::value< Alloc >::swap ( value< Alloc > &  other)
inlinenoexcept

Swap contents.

◆ operator=() [3/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const bool  b)
inline

Assign a bool value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [4/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const signed char  i)
inline

Assign a char value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [5/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const short  i)
inline

Assign a short value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [6/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const int  i)
inline

Assign an int value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [7/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const long  i)
inline

Assign a long value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [8/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const long long  i)
inline

Assign a long long value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [9/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const unsigned char  u)
inline

Assign an unsigned char value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [10/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const unsigned short  u)
inline

Assign an unsigned short value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [11/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const unsigned int  u)
inline

Assign an unsigned int value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [12/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const unsigned long  u)
inline

Assign an unsigned long value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [13/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const unsigned long long  u)
inline

Assign an unsigned long long value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [14/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( std::nullptr_t  )
inline

Assign a null value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [15/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const double  d)
inline

Assign a double value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [16/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( std::string_view  s)
inline

Assign a std::string_view value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [17/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const char *const  s)
inline

Assign a const char* value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [18/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const string_type s)
inline

Assign a string_type value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [19/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( string_type &&  s)
inline

Assign a string_type value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [20/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const array_type arr)
inline

Assign an array_type value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [21/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( array_type &&  arr)
inline

Assign an array_type value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [22/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( const object_type obj)
inline

Assign an object_type value. Allocates a memory storage or destroy the old content, if necessary.

◆ operator=() [23/23]

template<typename Alloc = std::allocator<std::byte>>
value& metall::json::value< Alloc >::operator= ( object_type &&  obj)
inline

Assign an object_type value. Allocates a memory storage or destroy the old content, if necessary.

◆ emplace_null()

template<typename Alloc = std::allocator<std::byte>>
void metall::json::value< Alloc >::emplace_null ( )
inline

Set a null. The old content is destroyed.

◆ emplace_bool()

template<typename Alloc = std::allocator<std::byte>>
bool& metall::json::value< Alloc >::emplace_bool ( )
inline

Set a bool and return a reference. The old content is destroyed.

◆ emplace_int64()

template<typename Alloc = std::allocator<std::byte>>
std::int64_t& metall::json::value< Alloc >::emplace_int64 ( )
inline

Set a int64 and return a reference. The old content is destroyed.

◆ emplace_uint64()

template<typename Alloc = std::allocator<std::byte>>
std::uint64_t& metall::json::value< Alloc >::emplace_uint64 ( )
inline

Set a uint64 and return a reference. The old content is destroyed.

◆ emplace_double()

template<typename Alloc = std::allocator<std::byte>>
double& metall::json::value< Alloc >::emplace_double ( )
inline

Set a double and return a reference. The old content is destroyed.

◆ emplace_string()

template<typename Alloc = std::allocator<std::byte>>
string_type& metall::json::value< Alloc >::emplace_string ( )
inline

Set an empty string and return a reference. The old content is destroyed.

◆ emplace_array()

template<typename Alloc = std::allocator<std::byte>>
array_type& metall::json::value< Alloc >::emplace_array ( )
inline

Set an empty array and return a reference. The old content is destroyed.

◆ emplace_object()

template<typename Alloc = std::allocator<std::byte>>
object_type& metall::json::value< Alloc >::emplace_object ( )
inline

Set an empty object and return a reference. The old content is destroyed.

◆ as_bool() [1/2]

template<typename Alloc = std::allocator<std::byte>>
bool& metall::json::value< Alloc >::as_bool ( )
inline

Return a reference to the underlying bool, or throw an exception.

◆ as_bool() [2/2]

template<typename Alloc = std::allocator<std::byte>>
const bool& metall::json::value< Alloc >::as_bool ( ) const
inline

Return a const reference to the underlying bool, or throw an exception.

◆ as_int64() [1/2]

template<typename Alloc = std::allocator<std::byte>>
std::int64_t& metall::json::value< Alloc >::as_int64 ( )
inline

Return a reference to the underlying std::int64_t, or throw an exception.

◆ as_int64() [2/2]

template<typename Alloc = std::allocator<std::byte>>
const std::int64_t& metall::json::value< Alloc >::as_int64 ( ) const
inline

Return a const reference to the underlying std::int64_t, or throw an exception.

◆ as_uint64() [1/2]

template<typename Alloc = std::allocator<std::byte>>
std::uint64_t& metall::json::value< Alloc >::as_uint64 ( )
inline

Return a reference to the underlying std::uint64_t, or throw an exception.

◆ as_uint64() [2/2]

template<typename Alloc = std::allocator<std::byte>>
const std::uint64_t& metall::json::value< Alloc >::as_uint64 ( ) const
inline

Return a const reference to the underlying std::uint64_t, or throw an exception.

◆ as_double() [1/2]

template<typename Alloc = std::allocator<std::byte>>
double& metall::json::value< Alloc >::as_double ( )
inline

Return a reference to the underlying double, or throw an exception.

◆ as_double() [2/2]

template<typename Alloc = std::allocator<std::byte>>
const double& metall::json::value< Alloc >::as_double ( ) const
inline

Return a const reference to the underlying double, or throw an exception.

◆ as_string() [1/2]

template<typename Alloc = std::allocator<std::byte>>
string_type& metall::json::value< Alloc >::as_string ( )
inline

Return a reference to the underlying string, or throw an exception.

◆ as_string() [2/2]

template<typename Alloc = std::allocator<std::byte>>
const string_type& metall::json::value< Alloc >::as_string ( ) const
inline

Return a const reference to the underlying string, or throw an exception.

◆ as_array() [1/2]

template<typename Alloc = std::allocator<std::byte>>
array_type& metall::json::value< Alloc >::as_array ( )
inline

Return a reference to the underlying array, or throw an exception.

◆ as_array() [2/2]

template<typename Alloc = std::allocator<std::byte>>
const array_type& metall::json::value< Alloc >::as_array ( ) const
inline

Return a const reference to the underlying array, or throw an exception.

◆ as_object() [1/2]

template<typename Alloc = std::allocator<std::byte>>
object_type& metall::json::value< Alloc >::as_object ( )
inline

Return a reference to the underlying object, or throw an exception.

◆ as_object() [2/2]

template<typename Alloc = std::allocator<std::byte>>
const object_type& metall::json::value< Alloc >::as_object ( ) const
inline

Return a const reference to the underlying object, or throw an exception.

◆ is_null()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_null ( ) const
inlinenoexcept

Return true if this is a null.

◆ is_bool()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_bool ( ) const
inlinenoexcept

Return true if this is a bool.

◆ is_int64()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_int64 ( ) const
inlinenoexcept

Return true if this is a int64.

◆ is_uint64()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_uint64 ( ) const
inlinenoexcept

Return true if this is a uint64.

◆ is_double()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_double ( ) const
inlinenoexcept

Return true if this is a double.

◆ is_string()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_string ( ) const
inlinenoexcept

Return true if this is a string.

◆ is_array()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_array ( ) const
inlinenoexcept

Return true if this is an array.

◆ is_object()

template<typename Alloc = std::allocator<std::byte>>
bool metall::json::value< Alloc >::is_object ( ) const
inlinenoexcept

Return true if this is a object.

◆ get_allocator()

template<typename Alloc = std::allocator<std::byte>>
allocator_type metall::json::value< Alloc >::get_allocator ( ) const
inlinenoexcept

Return an allocator object.

Friends And Related Function Documentation

◆ operator==

template<typename Alloc = std::allocator<std::byte>>
bool operator== ( const value< Alloc > &  lhs,
const value< Alloc > &  rhs 
)
friend

Equal operator.

◆ operator!=

template<typename Alloc = std::allocator<std::byte>>
bool operator!= ( const value< Alloc > &  lhs,
const value< Alloc > &  rhs 
)
friend

Return true if two values are not equal. Two values are equal when they are the same kind and their referenced values are equal, or when they are both integral types and their integral representations are equal.


The documentation for this class was generated from the following file: