A library for working with phylogenetic and population genetic data.
v0.32.0
JsonDocument Class Reference

#include <genesis/utils/formats/json/document.hpp>

Detailed Description

Store a Json value of any kind.

This class is a heavily altered adaption of the excellent JSON for Modern C++ library by Niels Lohmann, see also Acknowledgements.

Definition at line 114 of file json/document.hpp.

Public Member Functions

 JsonDocument (ArrayType const &v)
 Create an array, explicitly. More...
 
 JsonDocument (BooleanType v)
 Create a boolean, explicitly. More...
 
template<class CompatibleObjectType , typename std::enable_if< std::is_constructible< typename ObjectType::key_type, typename CompatibleObjectType::key_type >::value and std::is_constructible< JsonDocument, typename CompatibleObjectType::mapped_type >::value, int >::type = 0>
 JsonDocument (CompatibleObjectType const &val)
 Create an object (implicit). More...
 
template<class CompatibleArrayTypeT , typename std::enable_if< not std::is_same< CompatibleArrayTypeT, typename JsonDocument::iterator >::value and not std::is_same< CompatibleArrayTypeT, typename JsonDocument::const_iterator >::value and not std::is_same< CompatibleArrayTypeT, typename ArrayType::iterator >::value and not std::is_same< CompatibleArrayTypeT, typename ArrayType::const_iterator >::value and std::is_constructible< JsonDocument, typename CompatibleArrayTypeT::value_type >::value, int >::type = 0>
 JsonDocument (const CompatibleArrayTypeT &val)
 
template<class CompatibleStringType , typename std::enable_if< std::is_constructible< StringType, CompatibleStringType >::value, int >::type = 0>
 JsonDocument (const CompatibleStringType &val)
 Create a string (implicit). More...
 
 JsonDocument (const NumberFloatType val)
 Create a floating-point number (explicit). More...
 
template<typename T , typename std::enable_if< not(std::is_same< T, int >::value) and std::is_same< T, NumberSignedType >::value, int >::type = 0>
 JsonDocument (const NumberSignedType val)
 Create a signed integer number (explicit). More...
 
template<typename T , typename std::enable_if< not(std::is_same< T, int >::value) and std::is_same< T, NumberUnsignedType >::value, int >::type = 0>
 JsonDocument (const NumberUnsignedType val)
 Create an unsigned integer number (explicit). More...
 
 JsonDocument (int const val)
 Create a signed integer number from an enum type (explicit). More...
 
 JsonDocument (JsonDocument &&other)
 Move constructor. More...
 
 JsonDocument (JsonDocument const &other)
 Copy constructor. More...
 
 JsonDocument (ObjectType const &v)
 Create an object, explicitly. More...
 
 JsonDocument (size_t n, JsonDocument const &val)
 Construct an array with n many copies of val. More...
 
 JsonDocument (std::initializer_list< JsonDocument > init, bool type_deduction=true, ValueType manual_type=ValueType::kArray)
 Create a container (array or object) from an initializer list. More...
 
 JsonDocument (std::nullptr_t=nullptr)
 Create a null object. More...
 
 JsonDocument (StringType const &v)
 Create a string, explicitly. More...
 
 JsonDocument (typename StringType::value_type const *v)
 Create a string, explicitly, using a char pointer. More...
 
 JsonDocument (ValueType type)
 Create an empty value of the given type. More...
 
 ~JsonDocument ()
 Destructor. More...
 
JsonDocumentat (size_t index)
 
JsonDocument const & at (size_t index) const
 
JsonDocumentat (typename ObjectType::key_type const &key)
 
JsonDocument const & at (typename ObjectType::key_type const &key) const
 
iterator begin ()
 Return an iterator to the first element. More...
 
const_iterator begin () const
 Return a const iterator to the first element. More...
 
const_iterator cbegin () const
 Return a const iterator to the first element. More...
 
const_iterator cend () const
 Return a const iterator to one past the last element. More...
 
void clear ()
 Clears the content of a JSON value and resets it to the default value as if JsonDocument(ValueType) would have been called. More...
 
size_type count (typename ObjectType::key_type key) const
 Return the number of occurrences of a key in a JSON object. More...
 
template<class... Args>
void emplace_back (Args &&... args)
 
bool empty () const
 
iterator end ()
 Return an iterator to one past the last element. More...
 
const_iterator end () const
 Return a const iterator to one past the last element. More...
 
iterator find (typename JsonDocument::ObjectType::key_type key)
 Find an element in a JSON object. More...
 
const_iterator find (typename JsonDocument::ObjectType::key_type key) const
 Find an element in a JSON object. More...
 
ArrayTypeget_array ()
 
ArrayType const & get_array () const
 
BooleanTypeget_boolean ()
 
BooleanType get_boolean () const
 
template<typename T >
get_number () const
 
NumberFloatTypeget_number_float ()
 
NumberFloatType get_number_float () const
 
NumberSignedTypeget_number_signed ()
 
NumberSignedType get_number_signed () const
 
NumberUnsignedTypeget_number_unsigned ()
 
NumberUnsignedType get_number_unsigned () const
 
ObjectTypeget_object ()
 
ObjectType const & get_object () const
 
StringTypeget_string ()
 
StringType const & get_string () const
 
bool is_array () const
 Return true iff the JSON value is an array. More...
 
bool is_boolean () const
 Return true iff the JSON value is a boolean. More...
 
bool is_null () const
 Return true iff the JSON value is null. More...
 
bool is_number () const
 Return true iff the JSON value is a number, i.e., a float or signed or unsigned integer. More...
 
bool is_number_float () const
 Return true iff the JSON value is a float number. More...
 
bool is_number_integer () const
 Return true iff the JSON value is a signed or unsigned integer number. More...
 
bool is_number_signed () const
 Return true iff the JSON value is a signed integer number. More...
 
bool is_number_unsigned () const
 Return true iff the JSON value is an unsigned integer number. More...
 
bool is_object () const
 Return true iff the JSON value is an object. More...
 
bool is_primitive () const
 Return true iff the JSON type is primitive (string, number, boolean, or null). More...
 
bool is_string () const
 Return true iff the JSON value is a string. More...
 
bool is_structured () const
 Return true iff the JSON type is structured (array or object). More...
 
size_t max_size () const
 
JsonDocumentoperator= (JsonDocument other)
 Copy assignment. More...
 
JsonDocumentoperator[] (size_t index)
 
JsonDocument const & operator[] (size_t index) const
 
JsonDocumentoperator[] (typename ObjectType::key_type const &key)
 
JsonDocument const & operator[] (typename ObjectType::key_type const &key) const
 
void push_back (JsonDocument &&val)
 Add a Json value to an array. More...
 
void push_back (JsonDocument const &val)
 Add a Json value to an array. More...
 
void push_back (typename ObjectType::value_type const &val)
 Add an object to an object. More...
 
size_t size () const
 
ValueType type () const
 Return the type of the JSON value. More...
 
std::string type_name () const
 

Static Public Member Functions

static JsonDocument array (std::initializer_list< JsonDocument > init=std::initializer_list< JsonDocument >())
 Explicitly create an array from an initializer list. More...
 
static JsonDocument boolean (BooleanType value)
 Explicitly create a boolean. More...
 
static JsonDocument number_float (NumberFloatType value)
 Explicitly create a float number. More...
 
static JsonDocument number_signed (NumberSignedType value)
 Explicitly create a signed number. More...
 
static JsonDocument number_unsigned (NumberUnsignedType value)
 Explicitly create an unsigned number. More...
 
static JsonDocument object (std::initializer_list< JsonDocument > init=std::initializer_list< JsonDocument >())
 Explicitly create an object from an initializer list. More...
 
static JsonDocument string (std::string const &init)
 Explicitly create a string. More...
 

Public Types

using ArrayType = std::vector< JsonDocument >
 
using BooleanType = bool
 
using const_iterator = JsonIterator< JsonDocument const >
 
using const_pointer = JsonDocument const *
 
using const_reference = JsonDocument const &
 
using difference_type = std::ptrdiff_t
 
using iterator = JsonIterator< JsonDocument >
 
using NumberFloatType = double
 
using NumberSignedType = std::int64_t
 
using NumberUnsignedType = std::uint64_t
 
using ObjectType = std::map< std::string, JsonDocument >
 
using pointer = JsonDocument *
 
using reference = JsonDocument &
 
using size_type = std::size_t
 
using StringType = std::string
 
using value_type = JsonDocument
 
enum  ValueType : uint8_t {
  kNull, kArray, kObject, kString,
  kBoolean, kNumberFloat, kNumberSigned, kNumberUnsigned
}
 

Friends

class JsonIterator< JsonDocument >
 
class JsonIterator< JsonDocument const >
 
bool operator!= (const_reference lhs, const_reference rhs)
 Compare not equal. More...
 
bool operator!= (const_reference v, std::nullptr_t)
 Compare not equal. More...
 
bool operator!= (std::nullptr_t, const_reference v)
 Compare not equal. More...
 
bool operator< (const ValueType lhs, const ValueType rhs)
 Comparison of Json types (instead of values). More...
 
bool operator< (const_reference lhs, const_reference rhs)
 Compare less than. More...
 
bool operator<= (const_reference lhs, const_reference rhs)
 Compare less than or equal. More...
 
bool operator== (const_reference lhs, const_reference rhs)
 Compare equal. More...
 
bool operator== (const_reference v, std::nullptr_t)
 Compare equal. More...
 
bool operator== (std::nullptr_t, const_reference v)
 Compare equal. More...
 
bool operator> (const_reference lhs, const_reference rhs)
 Compare greater than. More...
 
bool operator>= (const_reference lhs, const_reference rhs)
 Compare greater than or equal. More...
 

Constructor & Destructor Documentation

◆ JsonDocument() [1/18]

JsonDocument ( std::nullptr_t  = nullptr)
inline

Create a null object.

Create a null JSON value. It either takes a null pointer as parameter (explicitly creating null) or no parameter (implicitly creating null).

Definition at line 269 of file json/document.hpp.

◆ JsonDocument() [2/18]

JsonDocument ( ValueType  type)
inline

Create an empty value of the given type.

Definition at line 278 of file json/document.hpp.

◆ JsonDocument() [3/18]

JsonDocument ( ArrayType const &  v)
inline

Create an array, explicitly.

Definition at line 289 of file json/document.hpp.

◆ JsonDocument() [4/18]

JsonDocument ( ObjectType const &  v)
inline

Create an object, explicitly.

Definition at line 299 of file json/document.hpp.

◆ JsonDocument() [5/18]

JsonDocument ( StringType const &  v)
inline

Create a string, explicitly.

Definition at line 309 of file json/document.hpp.

◆ JsonDocument() [6/18]

JsonDocument ( typename StringType::value_type const *  v)
inline

Create a string, explicitly, using a char pointer.

Definition at line 319 of file json/document.hpp.

◆ JsonDocument() [7/18]

JsonDocument ( BooleanType  v)
inline

Create a boolean, explicitly.

Definition at line 329 of file json/document.hpp.

◆ JsonDocument() [8/18]

JsonDocument ( const NumberSignedType  val)
inline

Create a signed integer number (explicit).

Definition at line 343 of file json/document.hpp.

◆ JsonDocument() [9/18]

JsonDocument ( int const  val)
inline

Create a signed integer number from an enum type (explicit).

Definition at line 353 of file json/document.hpp.

◆ JsonDocument() [10/18]

JsonDocument ( const NumberUnsignedType  val)
inline

Create an unsigned integer number (explicit).

Definition at line 367 of file json/document.hpp.

◆ JsonDocument() [11/18]

JsonDocument ( const NumberFloatType  val)
inline

Create a floating-point number (explicit).

RFC 7159, section 6 disallows NaN values:

Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.

In case the parameter val is not a number, a JSON null value is created instead.

Definition at line 381 of file json/document.hpp.

◆ JsonDocument() [12/18]

JsonDocument ( std::initializer_list< JsonDocument init,
bool  type_deduction = true,
ValueType  manual_type = ValueType::kArray 
)

Create a container (array or object) from an initializer list.

Definition at line 86 of file json/document.cpp.

◆ JsonDocument() [13/18]

JsonDocument ( size_t  n,
JsonDocument const &  val 
)
inline

Construct an array with n many copies of val.

Definition at line 410 of file json/document.hpp.

◆ JsonDocument() [14/18]

JsonDocument ( const CompatibleArrayTypeT &  val)
inline

Definition at line 427 of file json/document.hpp.

◆ JsonDocument() [15/18]

JsonDocument ( CompatibleObjectType const &  val)
inline

Create an object (implicit).

Create an object JSON value with a given content. This constructor allows any type CompatibleObjectType that can be used to construct values of type ObjectType.

Definition at line 453 of file json/document.hpp.

◆ JsonDocument() [16/18]

JsonDocument ( const CompatibleStringType &  val)
inline

Create a string (implicit).

Create a string JSON value with a given content with a type which is compatible to StringType, for instance std::string.

Definition at line 471 of file json/document.hpp.

◆ JsonDocument() [17/18]

JsonDocument ( JsonDocument const &  other)

Copy constructor.

Definition at line 140 of file json/document.cpp.

◆ JsonDocument() [18/18]

JsonDocument ( JsonDocument &&  other)

Move constructor.

Definition at line 187 of file json/document.cpp.

◆ ~JsonDocument()

Destructor.

Definition at line 223 of file json/document.cpp.

Member Function Documentation

◆ array()

static JsonDocument array ( std::initializer_list< JsonDocument init = std::initializer_list<JsonDocument>())
inlinestatic

Explicitly create an array from an initializer list.

Definition at line 508 of file json/document.hpp.

◆ at() [1/4]

JsonDocument & at ( size_t  index)

Definition at line 433 of file json/document.cpp.

◆ at() [2/4]

JsonDocument const & at ( size_t  index) const

Definition at line 449 of file json/document.cpp.

◆ at() [3/4]

JsonDocument & at ( typename ObjectType::key_type const &  key)

Definition at line 465 of file json/document.cpp.

◆ at() [4/4]

JsonDocument const & at ( typename ObjectType::key_type const &  key) const

Definition at line 481 of file json/document.cpp.

◆ begin() [1/2]

Return an iterator to the first element.

Definition at line 591 of file json/document.cpp.

◆ begin() [2/2]

const_iterator begin ( ) const

Return a const iterator to the first element.

◆ boolean()

static JsonDocument boolean ( BooleanType  value)
inlinestatic

Explicitly create a boolean.

Definition at line 535 of file json/document.hpp.

◆ cbegin()

JsonDocument::const_iterator cbegin ( ) const

Return a const iterator to the first element.

Definition at line 603 of file json/document.cpp.

◆ cend()

Return a const iterator to one past the last element.

Definition at line 622 of file json/document.cpp.

◆ clear()

void clear ( )

Clears the content of a JSON value and resets it to the default value as if JsonDocument(ValueType) would have been called.

The values are cleared as follows:

Value type initial value
null null
boolean false
string ""
number 0
object {}
array []

In order to complete eliminate a Json value, set it to nullptr instead.

Definition at line 633 of file json/document.cpp.

◆ count()

JsonDocument::size_type count ( typename ObjectType::key_type  key) const

Return the number of occurrences of a key in a JSON object.

As we use a std::map for objects, this value is either 0 (key not found) or 1 (key found). For non-object types, the return value is always 0.

Definition at line 581 of file json/document.cpp.

◆ emplace_back()

void emplace_back ( Args &&...  args)
inline

Definition at line 865 of file json/document.hpp.

◆ empty()

bool empty ( ) const

Definition at line 251 of file json/document.cpp.

◆ end() [1/2]

Return an iterator to one past the last element.

Definition at line 610 of file json/document.cpp.

◆ end() [2/2]

const_iterator end ( ) const

Return a const iterator to one past the last element.

◆ find() [1/2]

JsonDocument::iterator find ( typename JsonDocument::ObjectType::key_type  key)

Find an element in a JSON object.

Finds an element in a JSON object with key equivalent to key. If the element is not found or the JSON value is not an object, end() is returned.

Definition at line 563 of file json/document.cpp.

◆ find() [2/2]

JsonDocument::const_iterator find ( typename JsonDocument::ObjectType::key_type  key) const

Find an element in a JSON object.

Finds an element in a JSON object with key equivalent to key. If the element is not found or the JSON value is not an object, end() is returned.

Definition at line 572 of file json/document.cpp.

◆ get_array() [1/2]

JsonDocument::ArrayType const & get_array ( )

Definition at line 317 of file json/document.cpp.

◆ get_array() [2/2]

ArrayType const& get_array ( ) const

◆ get_boolean() [1/2]

JsonDocument::BooleanType get_boolean ( )

Definition at line 365 of file json/document.cpp.

◆ get_boolean() [2/2]

BooleanType get_boolean ( ) const

◆ get_number()

T get_number ( ) const
inline

Definition at line 725 of file json/document.hpp.

◆ get_number_float() [1/2]

JsonDocument::NumberFloatType get_number_float ( )

Definition at line 381 of file json/document.cpp.

◆ get_number_float() [2/2]

NumberFloatType get_number_float ( ) const

◆ get_number_signed() [1/2]

JsonDocument::NumberSignedType get_number_signed ( )

Definition at line 397 of file json/document.cpp.

◆ get_number_signed() [2/2]

NumberSignedType get_number_signed ( ) const

◆ get_number_unsigned() [1/2]

JsonDocument::NumberUnsignedType get_number_unsigned ( )

Definition at line 413 of file json/document.cpp.

◆ get_number_unsigned() [2/2]

NumberUnsignedType get_number_unsigned ( ) const

◆ get_object() [1/2]

JsonDocument::ObjectType const & get_object ( )

Definition at line 333 of file json/document.cpp.

◆ get_object() [2/2]

ObjectType const& get_object ( ) const

◆ get_string() [1/2]

JsonDocument::StringType const & get_string ( )

Definition at line 349 of file json/document.cpp.

◆ get_string() [2/2]

StringType const& get_string ( ) const

◆ is_array()

bool is_array ( ) const
inline

Return true iff the JSON value is an array.

Definition at line 617 of file json/document.hpp.

◆ is_boolean()

bool is_boolean ( ) const
inline

Return true iff the JSON value is a boolean.

Definition at line 641 of file json/document.hpp.

◆ is_null()

bool is_null ( ) const
inline

Return true iff the JSON value is null.

Definition at line 609 of file json/document.hpp.

◆ is_number()

bool is_number ( ) const
inline

Return true iff the JSON value is a number, i.e., a float or signed or unsigned integer.

Definition at line 650 of file json/document.hpp.

◆ is_number_float()

bool is_number_float ( ) const
inline

Return true iff the JSON value is a float number.

Definition at line 658 of file json/document.hpp.

◆ is_number_integer()

bool is_number_integer ( ) const
inline

Return true iff the JSON value is a signed or unsigned integer number.

Definition at line 666 of file json/document.hpp.

◆ is_number_signed()

bool is_number_signed ( ) const
inline

Return true iff the JSON value is a signed integer number.

Definition at line 674 of file json/document.hpp.

◆ is_number_unsigned()

bool is_number_unsigned ( ) const
inline

Return true iff the JSON value is an unsigned integer number.

Definition at line 682 of file json/document.hpp.

◆ is_object()

bool is_object ( ) const
inline

Return true iff the JSON value is an object.

Definition at line 625 of file json/document.hpp.

◆ is_primitive()

bool is_primitive ( ) const
inline

Return true iff the JSON type is primitive (string, number, boolean, or null).

Definition at line 593 of file json/document.hpp.

◆ is_string()

bool is_string ( ) const
inline

Return true iff the JSON value is a string.

Definition at line 633 of file json/document.hpp.

◆ is_structured()

bool is_structured ( ) const
inline

Return true iff the JSON type is structured (array or object).

Definition at line 601 of file json/document.hpp.

◆ max_size()

size_t max_size ( ) const

Definition at line 295 of file json/document.cpp.

◆ number_float()

static JsonDocument number_float ( NumberFloatType  value)
inlinestatic

Explicitly create a float number.

Definition at line 546 of file json/document.hpp.

◆ number_signed()

static JsonDocument number_signed ( NumberSignedType  value)
inlinestatic

Explicitly create a signed number.

Definition at line 557 of file json/document.hpp.

◆ number_unsigned()

static JsonDocument number_unsigned ( NumberUnsignedType  value)
inlinestatic

Explicitly create an unsigned number.

Definition at line 568 of file json/document.hpp.

◆ object()

static JsonDocument object ( std::initializer_list< JsonDocument init = std::initializer_list<JsonDocument>())
inlinestatic

Explicitly create an object from an initializer list.

Definition at line 517 of file json/document.hpp.

◆ operator=()

JsonDocument & operator= ( JsonDocument  other)

Copy assignment.

Definition at line 205 of file json/document.cpp.

◆ operator[]() [1/4]

JsonDocument & operator[] ( size_t  index)

Definition at line 497 of file json/document.cpp.

◆ operator[]() [2/4]

JsonDocument const & operator[] ( size_t  index) const

Definition at line 522 of file json/document.cpp.

◆ operator[]() [3/4]

JsonDocument & operator[] ( typename ObjectType::key_type const &  key)

Definition at line 531 of file json/document.cpp.

◆ operator[]() [4/4]

JsonDocument const & operator[] ( typename ObjectType::key_type const &  key) const

Definition at line 548 of file json/document.cpp.

◆ push_back() [1/3]

void push_back ( JsonDocument &&  val)

Add a Json value to an array.

Appends the given element val to the end of the JSON value. If the function is called on a JSON null value, an empty array is created before appending val.void push_back( JsonDocument&& val );

Definition at line 670 of file json/document.cpp.

◆ push_back() [2/3]

void push_back ( JsonDocument const &  val)

Add a Json value to an array.

Appends the given element val to the end of the JSON value. If the function is called on a JSON null value, an empty array is created before appending val.void push_back( JsonDocument&& val );

Definition at line 690 of file json/document.cpp.

◆ push_back() [3/3]

void push_back ( typename ObjectType::value_type const &  val)

Add an object to an object.

Inserts the given element val to the JSON object. If the function is called on a JSON null value, an empty object is created before inserting val.

Definition at line 708 of file json/document.cpp.

◆ size()

size_t size ( ) const

Definition at line 273 of file json/document.cpp.

◆ string()

static JsonDocument string ( std::string const &  init)
inlinestatic

Explicitly create a string.

Definition at line 526 of file json/document.hpp.

◆ type()

ValueType type ( ) const
inline

Return the type of the JSON value.

Definition at line 585 of file json/document.hpp.

◆ type_name()

std::string type_name ( ) const

Definition at line 880 of file json/document.cpp.

Friends And Related Function Documentation

◆ JsonIterator< JsonDocument >

friend class JsonIterator< JsonDocument >
friend

Definition at line 120 of file json/document.hpp.

◆ JsonIterator< JsonDocument const >

friend class JsonIterator< JsonDocument const >
friend

Definition at line 121 of file json/document.hpp.

◆ operator!= [1/3]

bool operator!= ( const_reference  lhs,
const_reference  rhs 
)
friend

Compare not equal.

See operator==(const_reference lhs, const_reference rhs) for details.

Definition at line 929 of file json/document.hpp.

◆ operator!= [2/3]

bool operator!= ( const_reference  v,
std::nullptr_t   
)
friend

Compare not equal.

See operator==(const_reference v, std::nullptr_t) for details.

Definition at line 939 of file json/document.hpp.

◆ operator!= [3/3]

bool operator!= ( std::nullptr_t  ,
const_reference  v 
)
friend

Compare not equal.

See operator==(const_reference v, std::nullptr_t) for details.

Definition at line 949 of file json/document.hpp.

◆ operator< [1/2]

bool operator< ( const ValueType  lhs,
const ValueType  rhs 
)
friend

Comparison of Json types (instead of values).

Returns an ordering that is similar to Python:

  • order: null < boolean < number < object < array < string
  • furthermore, each type is not smaller than itself %

Definition at line 859 of file json/document.cpp.

◆ operator< [2/2]

bool operator< ( JsonDocument::const_reference  lhs,
JsonDocument::const_reference  rhs 
)
friend

Compare less than.

Compares whether one JSON value lhs is less than another JSON value rhs according to the following rules:

  • If lhs and rhs have the same type, the values are compared using the default < operator.
  • Integer and floating-point numbers are automatically converted before comparison
  • In case lhs and rhs have different types, the values are ignored and the order of the types is considered, see operator<(const JsonDocument::ValueType, const JsonDocument::ValueType). %

Definition at line 793 of file json/document.cpp.

◆ operator<=

bool operator<= ( const_reference  lhs,
const_reference  rhs 
)
friend

Compare less than or equal.

Compares whether one JSON value lhs is less than or equal to another JSON value by calculating not (rhs < lhs).

Definition at line 975 of file json/document.hpp.

◆ operator== [1/3]

bool operator== ( JsonDocument::const_reference  lhs,
JsonDocument::const_reference  rhs 
)
friend

Compare equal.

Compares two JSON values for equality according to the following rules:

  • Two JSON values are equal if (1) they are from the same type and (2) their stored values are the same.
  • Integer and floating-point numbers are automatically converted before comparison. Floating-point numbers are compared indirectly: two floating-point numbers f1 and f2 are considered equal if neither f1 > f2 nor f2 > f1 holds.
  • Two JSON null values are equal. %

Definition at line 730 of file json/document.cpp.

◆ operator== [2/3]

bool operator== ( const_reference  v,
std::nullptr_t   
)
friend

Compare equal.

The functions compares the given JSON value against a null pointer. As the null pointer can be used to initialize a JSON value to null, a comparison of JSON value v with a null pointer should be equivalent to call v.is_null().

Definition at line 911 of file json/document.hpp.

◆ operator== [3/3]

bool operator== ( std::nullptr_t  ,
const_reference  v 
)
friend

Compare equal.

The functions compares the given JSON value against a null pointer. As the null pointer can be used to initialize a JSON value to null, a comparison of JSON value v with a null pointer should be equivalent to call v.is_null().

Definition at line 919 of file json/document.hpp.

◆ operator>

bool operator> ( const_reference  lhs,
const_reference  rhs 
)
friend

Compare greater than.

Compares whether one JSON value lhs is greater than another JSON value by calculating not (lhs <= rhs).

Definition at line 986 of file json/document.hpp.

◆ operator>=

bool operator>= ( const_reference  lhs,
const_reference  rhs 
)
friend

Compare greater than or equal.

Compares whether one JSON value lhs is greater than or equal to another JSON value by calculating not (lhs < rhs).

Definition at line 997 of file json/document.hpp.

Member Typedef Documentation

◆ ArrayType

using ArrayType = std::vector< JsonDocument >

Definition at line 142 of file json/document.hpp.

◆ BooleanType

using BooleanType = bool

Definition at line 146 of file json/document.hpp.

◆ const_iterator

Definition at line 137 of file json/document.hpp.

◆ const_pointer

using const_pointer = JsonDocument const*

Definition at line 134 of file json/document.hpp.

◆ const_reference

using const_reference = JsonDocument const&

Definition at line 131 of file json/document.hpp.

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 139 of file json/document.hpp.

◆ iterator

Definition at line 136 of file json/document.hpp.

◆ NumberFloatType

using NumberFloatType = double

Definition at line 147 of file json/document.hpp.

◆ NumberSignedType

using NumberSignedType = std::int64_t

Definition at line 148 of file json/document.hpp.

◆ NumberUnsignedType

using NumberUnsignedType = std::uint64_t

Definition at line 149 of file json/document.hpp.

◆ ObjectType

using ObjectType = std::map< std::string, JsonDocument >

Definition at line 143 of file json/document.hpp.

◆ pointer

Definition at line 133 of file json/document.hpp.

◆ reference

Definition at line 130 of file json/document.hpp.

◆ size_type

using size_type = std::size_t

Definition at line 140 of file json/document.hpp.

◆ StringType

using StringType = std::string

Definition at line 144 of file json/document.hpp.

◆ value_type

Definition at line 129 of file json/document.hpp.

Member Enumeration Documentation

◆ ValueType

enum ValueType : uint8_t
strong
Enumerator
kNull 
kArray 
kObject 
kString 
kBoolean 
kNumberFloat 
kNumberSigned 
kNumberUnsigned 

Definition at line 151 of file json/document.hpp.


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