JSON for Modern C++  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
Container

C++ Container concept. More...

Collaboration diagram for Container:

Modules

 Reversible Container
 C++ Reversible Container conceptA ReversibleContainer is a Container that has iterators that meet the requirements of either BidirectionalIterator or RandomAccessIterator. Such iterators allow a ReversibleContainer to be iterated over in reverse.
 

Typedefs

using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::value_type = basic_json
 the type of elements in a basic_json container More...
 
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::reference = basic_json &
 the type of an element reference More...
 
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_reference = const basic_json &
 the type of an element const reference More...
 
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::difference_type = std::ptrdiff_t
 a type to represent differences between iterators More...
 
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::size_type = std::size_t
 a type to represent container sizes More...
 
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::iterator = basic_json::iterator
 an iterator for a basic_json container More...
 
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator = basic_json::const_iterator
 a const iterator for a basic_json container More...
 

Functions

 nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::basic_json () noexcept=default
 create a null object (implicitly) More...
 
 nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::basic_json (const basic_json &other)
 copy constructor More...
 
reference & nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::operator= (basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value andstd::is_nothrow_move_assignable< value_t >::value andstd::is_nothrow_move_constructible< json_value >::value andstd::is_nothrow_move_assignable< json_value >::value)
 copy assignment More...
 
 nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::~basic_json () noexcept
 destructor More...
 
iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::begin () noexcept
 returns an iterator to the first element More...
 
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::begin () const noexcept
 returns a const iterator to the first element More...
 
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::cbegin () const noexcept
 returns a const iterator to the first element More...
 
iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::end () noexcept
 returns an iterator to one past the last element More...
 
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::end () const noexcept
 returns a const iterator to one past the last element More...
 
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::cend () const noexcept
 returns a const iterator to one past the last element More...
 
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::empty () const noexcept
 checks whether the container is empty More...
 
size_type nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::size () const noexcept
 returns the number of elements More...
 
size_type nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::max_size () const noexcept
 returns the maximum possible number of elements More...
 
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::swap (reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value andstd::is_nothrow_move_assignable< value_t >::value andstd::is_nothrow_move_constructible< json_value >::value andstd::is_nothrow_move_assignable< json_value >::value)
 exchanges the values More...
 
template<>
void std::swap (nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
 exchanges the values of two JSON objects More...
 

Friends

bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::operator== (const_reference lhs, const_reference rhs) noexcept
 comparison: equal More...
 
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::operator!= (const_reference lhs, const_reference rhs) noexcept
 comparison: not equal More...
 

Detailed Description

A Container is an object used to store other objects and taking care of the management of the memory used by the objects it contains.

See Also
http://en.cppreference.com/w/cpp/concept/Container

Typedef Documentation

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator = basic_json::const_iterator

Definition at line 163 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_reference = const basic_json&

Definition at line 131 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::difference_type = std::ptrdiff_t

Definition at line 137 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::iterator = basic_json::iterator

Definition at line 157 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::reference = basic_json&

Definition at line 125 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::size_type = std::size_t

Definition at line 143 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::value_type = basic_json

Definition at line 119 of file json.hpp.

Function Documentation

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::basic_json ( )
inlinedefaultnoexcept
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::basic_json ( const basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator > &  other)
inline
Exceptions
std::bad_allocif allocation for object, array, or string fails.

Definition at line 613 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::json_value::array, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::json_value::boolean, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::m_value, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::json_value::number_float, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::json_value::number_integer, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::json_value::object, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::json_value::string.

614  : m_type(other.m_type)
615  {
616  switch (m_type)
617  {
618  case (value_t::null):
619  {
620  break;
621  }
622 
623  case (value_t::object):
624  {
625  Allocator<object_t> alloc;
626  m_value.object = alloc.allocate(1);
627  alloc.construct(m_value.object, *other.m_value.object);
628  break;
629  }
630 
631  case (value_t::array):
632  {
633  Allocator<array_t> alloc;
634  m_value.array = alloc.allocate(1);
635  alloc.construct(m_value.array, *other.m_value.array);
636  break;
637  }
638 
639  case (value_t::string):
640  {
641  Allocator<string_t> alloc;
642  m_value.string = alloc.allocate(1);
643  alloc.construct(m_value.string, *other.m_value.string);
644  break;
645  }
646 
647  case (value_t::boolean):
648  {
649  m_value.boolean = other.m_value.boolean;
650  break;
651  }
652 
654  {
655  m_value.number_integer = other.m_value.number_integer;
656  break;
657  }
658 
659  case (value_t::number_float):
660  {
661  m_value.number_float = other.m_value.number_float;
662  break;
663  }
664  }
665  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
object_t * object
object (stored with pointer to save storage)
Definition: json.hpp:213
string_t * string
string (stored with pointer to save storage)
Definition: json.hpp:217
boolean_t boolean
bolean
Definition: json.hpp:219
json_value m_value
the value of the current element
Definition: json.hpp:2203
array (ordered collection of values)
number_integer_t number_integer
number (integer)
Definition: json.hpp:221
number_float_t number_float
number (floating-point)
Definition: json.hpp:223
object (unordered set of name/value pairs)
number value (floating-point)
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:215
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::~basic_json ( )
inlinenoexcept

Definition at line 697 of file json.hpp.

698  {
699  switch (m_type)
700  {
701  case (value_t::object):
702  {
703  Allocator<object_t> alloc;
704  alloc.destroy(m_value.object);
705  alloc.deallocate(m_value.object, 1);
706  m_value.object = nullptr;
707  break;
708  }
709 
710  case (value_t::array):
711  {
712  Allocator<array_t> alloc;
713  alloc.destroy(m_value.array);
714  alloc.deallocate(m_value.array, 1);
715  m_value.array = nullptr;
716  break;
717  }
718 
719  case (value_t::string):
720  {
721  Allocator<string_t> alloc;
722  alloc.destroy(m_value.string);
723  alloc.deallocate(m_value.string, 1);
724  m_value.string = nullptr;
725  break;
726  }
727 
728  default:
729  {
730  // all other types need no specific destructor
731  break;
732  }
733  }
734  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
object_t * object
object (stored with pointer to save storage)
Definition: json.hpp:213
string_t * string
string (stored with pointer to save storage)
Definition: json.hpp:217
json_value m_value
the value of the current element
Definition: json.hpp:2203
array (ordered collection of values)
object (unordered set of name/value pairs)
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:215
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::begin ( )
inlinenoexcept

Definition at line 1261 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::iterator::set_begin().

1262  {
1263  iterator result(this);
1264  result.set_begin();
1265  return result;
1266  }
basic_json::iterator iterator
an iterator for a basic_json container
Definition: json.hpp:157

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::begin ( ) const
inlinenoexcept

Definition at line 1272 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::set_begin().

1273  {
1274  const_iterator result(this);
1275  result.set_begin();
1276  return result;
1277  }
basic_json::const_iterator const_iterator
a const iterator for a basic_json container
Definition: json.hpp:163

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::cbegin ( ) const
inlinenoexcept

Definition at line 1283 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::set_begin().

1284  {
1285  const_iterator result(this);
1286  result.set_begin();
1287  return result;
1288  }
basic_json::const_iterator const_iterator
a const iterator for a basic_json container
Definition: json.hpp:163

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::cend ( ) const
inlinenoexcept

Definition at line 1316 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::set_end().

1317  {
1318  const_iterator result(this);
1319  result.set_end();
1320  return result;
1321  }
basic_json::const_iterator const_iterator
a const iterator for a basic_json container
Definition: json.hpp:163

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::empty ( ) const
inlinenoexcept

Definition at line 1386 of file json.hpp.

1387  {
1388  switch (m_type)
1389  {
1390  case (value_t::null):
1391  {
1392  return true;
1393  }
1394 
1395  case (value_t::array):
1396  {
1397  return m_value.array->empty();
1398  }
1399 
1400  case (value_t::object):
1401  {
1402  return m_value.object->empty();
1403  }
1404 
1405  default:
1406  {
1407  // all other types are nonempty
1408  return false;
1409  }
1410  }
1411  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
object_t * object
object (stored with pointer to save storage)
Definition: json.hpp:213
json_value m_value
the value of the current element
Definition: json.hpp:2203
array (ordered collection of values)
object (unordered set of name/value pairs)
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:215
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::end ( )
inlinenoexcept

Definition at line 1294 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::iterator::set_end().

1295  {
1296  iterator result(this);
1297  result.set_end();
1298  return result;
1299  }
basic_json::iterator iterator
an iterator for a basic_json container
Definition: json.hpp:157

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::end ( ) const
inlinenoexcept

Definition at line 1305 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::set_end().

1306  {
1307  const_iterator result(this);
1308  result.set_end();
1309  return result;
1310  }
basic_json::const_iterator const_iterator
a const iterator for a basic_json container
Definition: json.hpp:163

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
size_type nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::max_size ( ) const
inlinenoexcept

Definition at line 1448 of file json.hpp.

1449  {
1450  switch (m_type)
1451  {
1452  case (value_t::null):
1453  {
1454  return 0;
1455  }
1456 
1457  case (value_t::array):
1458  {
1459  return m_value.array->max_size();
1460  }
1461 
1462  case (value_t::object):
1463  {
1464  return m_value.object->max_size();
1465  }
1466 
1467  default:
1468  {
1469  // all other types have max_size 1
1470  return 1;
1471  }
1472  }
1473  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
object_t * object
object (stored with pointer to save storage)
Definition: json.hpp:213
json_value m_value
the value of the current element
Definition: json.hpp:2203
array (ordered collection of values)
object (unordered set of name/value pairs)
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:215
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
reference& nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::operator= ( basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >  other)
inlinenoexcept

Definition at line 681 of file json.hpp.

References std::swap().

687  {
688  std::swap(m_type, other.m_type);
689  std::swap(m_value, other.m_value);
690  return *this;
691  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
json_value m_value
the value of the current element
Definition: json.hpp:2203
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
Definition: json.hpp:4695

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
size_type nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::size ( ) const
inlinenoexcept

Definition at line 1417 of file json.hpp.

1418  {
1419  switch (m_type)
1420  {
1421  case (value_t::null):
1422  {
1423  return 0;
1424  }
1425 
1426  case (value_t::array):
1427  {
1428  return m_value.array->size();
1429  }
1430 
1431  case (value_t::object):
1432  {
1433  return m_value.object->size();
1434  }
1435 
1436  default:
1437  {
1438  // all other types have size 1
1439  return 1;
1440  }
1441  }
1442  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
object_t * object
object (stored with pointer to save storage)
Definition: json.hpp:213
json_value m_value
the value of the current element
Definition: json.hpp:2203
array (ordered collection of values)
object (unordered set of name/value pairs)
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:215
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::swap ( reference  other)
inlinenoexcept

Definition at line 1621 of file json.hpp.

References std::swap().

1627  {
1628  std::swap(m_type, other.m_type);
1629  std::swap(m_value, other.m_value);
1630  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
json_value m_value
the value of the current element
Definition: json.hpp:2203
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
Definition: json.hpp:4695

Here is the call graph for this function:

template<>
void std::swap ( nlohmann::json j1,
nlohmann::json j2 
)
inlinenoexcept

Definition at line 4695 of file json.hpp.

Referenced by nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::operator=(), nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::iterator::operator=(), nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator=(), and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::swap().

4700 {
4701  j1.swap(j2);
4702 }
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value andstd::is_nothrow_move_assignable< value_t >::value andstd::is_nothrow_move_constructible< json_value >::value andstd::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:1621

Here is the caller graph for this function:

Friends

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool operator!= ( const_reference  lhs,
const_reference  rhs 
)
friend

Definition at line 1757 of file json.hpp.

1758  {
1759  return not (lhs == rhs);
1760  }
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool operator== ( const_reference  lhs,
const_reference  rhs 
)
friend

Definition at line 1680 of file json.hpp.

1681  {
1682  switch (lhs.type())
1683  {
1684  case (value_t::array):
1685  {
1686  if (rhs.type() == value_t::array)
1687  {
1688  return *lhs.m_value.array == *rhs.m_value.array;
1689  }
1690  break;
1691  }
1692  case (value_t::object):
1693  {
1694  if (rhs.type() == value_t::object)
1695  {
1696  return *lhs.m_value.object == *rhs.m_value.object;
1697  }
1698  break;
1699  }
1700  case (value_t::null):
1701  {
1702  if (rhs.type() == value_t::null)
1703  {
1704  return true;
1705  }
1706  break;
1707  }
1708  case (value_t::string):
1709  {
1710  if (rhs.type() == value_t::string)
1711  {
1712  return *lhs.m_value.string == *rhs.m_value.string;
1713  }
1714  break;
1715  }
1716  case (value_t::boolean):
1717  {
1718  if (rhs.type() == value_t::boolean)
1719  {
1720  return lhs.m_value.boolean == rhs.m_value.boolean;
1721  }
1722  break;
1723  }
1724  case (value_t::number_integer):
1725  {
1726  if (rhs.type() == value_t::number_integer)
1727  {
1728  return lhs.m_value.number_integer == rhs.m_value.number_integer;
1729  }
1730  if (rhs.type() == value_t::number_float)
1731  {
1732  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_float);
1733  }
1734  break;
1735  }
1736  case (value_t::number_float):
1737  {
1738  if (rhs.type() == value_t::number_integer)
1739  {
1740  return approx(lhs.m_value.number_float, static_cast<number_float_t>(rhs.m_value.number_integer));
1741  }
1742  if (rhs.type() == value_t::number_float)
1743  {
1744  return approx(lhs.m_value.number_float, rhs.m_value.number_float);
1745  }
1746  break;
1747  }
1748  }
1749 
1750  return false;
1751  }
static bool approx(const T a, const T b)
"equality" comparison for floating point numbers
Definition: json.hpp:2185
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:198
array (ordered collection of values)
object (unordered set of name/value pairs)
number value (floating-point)