Flow123d
JS_before_hm-2206-gca2a8366f
|
Go to the documentation of this file.
29 #ifndef NLOHMANN_JSON_HPP
30 #define NLOHMANN_JSON_HPP
41 #include <initializer_list>
51 #include <type_traits>
56 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
57 #pragma GCC diagnostic push
58 #pragma GCC diagnostic ignored "-Wfloat-equal"
81 struct has_mapped_type
84 template<
typename C>
static char test(
typename C::mapped_type*);
85 template<
typename C>
static char (&test(...))[2];
87 static constexpr
bool value =
sizeof(test<T>(0)) == 1;
164 template<
typename U,
typename V,
typename... Args>
class ObjectType =
std::map,
165 template<
typename U,
typename... Args>
class ArrayType =
std::vector,
166 class StringType = std::string,
167 class BooleanType = bool,
168 class NumberIntegerType = std::int64_t,
169 class NumberUnsignedType = std::uint64_t,
170 class NumberFloatType = double,
171 template<
typename U>
class AllocatorType = std::allocator
212 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
214 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
329 using object_t = ObjectType<StringType,
331 std::less<StringType>,
332 AllocatorType<std::pair<
const StringType,
379 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
698 template<
typename T,
typename... Args>
701 AllocatorType<T> alloc;
702 auto deleter = [&](T *
object)
704 alloc.deallocate(
object, 1);
706 std::unique_ptr<T, decltype(deleter)>
object(alloc.allocate(1), deleter);
707 alloc.construct(
object.
get(), std::forward<Args>(args)...);
708 return object.release();
756 object = create<object_t>();
762 array = create<array_t>();
768 string = create<string_t>(
"");
806 string = create<string_t>(
value);
812 object = create<object_t>(
value);
1055 template <
class CompatibleObjectType,
typename
1117 template <
class CompatibleArrayType,
typename
1207 template <
class CompatibleStringType,
typename
1256 template<
typename T,
1257 typename std::enable_if<
1321 template<
typename CompatibleNumberIntegerType,
typename
1324 std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
1325 std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
1326 CompatibleNumberIntegerType>
::type
1350 template<
typename T,
1351 typename std::enable_if<
1380 template <
typename CompatibleNumberUnsignedType,
typename
1383 std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
1384 !std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
1385 CompatibleNumberUnsignedType >
::type
1420 if (not std::isfinite(val))
1457 template<
typename CompatibleNumberFloatType,
typename =
typename
1536 bool type_deduction =
true,
1540 bool is_an_object =
true;
1544 for (
const auto& element : init)
1546 if (not element.is_array() or element.size() != 2
1547 or not element[0].is_string())
1551 is_an_object =
false;
1557 if (not type_deduction)
1562 is_an_object =
false;
1568 throw std::domain_error(
"cannot create object from initializer list");
1580 for (
auto& element : init)
1628 std::initializer_list<basic_json>())
1668 std::initializer_list<basic_json>())
1731 template <
class InputIT,
typename
1740 if (first.m_object != last.m_object)
1742 throw std::domain_error(
"iterators are not compatible");
1754 if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
1756 throw std::out_of_range(
"iterators out of range");
1771 assert(first.m_object !=
nullptr);
1778 assert(first.m_object !=
nullptr);
1785 assert(first.m_object !=
nullptr);
1792 assert(first.m_object !=
nullptr);
1799 assert(first.m_object !=
nullptr);
1806 m_value.
object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
1812 m_value.
array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
1818 assert(first.m_object !=
nullptr);
1819 throw std::domain_error(
"cannot use construct with iterators from " + first.m_object->type_name());
2016 AllocatorType<object_t> alloc;
2024 AllocatorType<array_t> alloc;
2032 AllocatorType<string_t> alloc;
2081 std::stringstream ss;
2085 dump(ss,
true,
static_cast<unsigned int>(indent));
2458 template <
class T,
typename
2472 throw std::domain_error(
"type must be object, but is " +
type_name());
2486 throw std::domain_error(
"type must be object, but is " +
type_name());
2491 template <
class T,
typename
2506 std::inserter(to_vector, to_vector.end()), [](
basic_json i)
2508 return i.get<typename T::value_type>();
2514 throw std::domain_error(
"type must be array, but is " +
type_name());
2519 template <
class T,
typename
2532 std::inserter(to_vector, to_vector.end()), [](
basic_json i)
2540 throw std::domain_error(
"type must be array, but is " +
type_name());
2545 template <
class T,
typename
2559 throw std::domain_error(
"type must be array, but is " +
type_name());
2573 throw std::domain_error(
"type must be array, but is " +
type_name());
2578 template <
typename T,
typename
2591 throw std::domain_error(
"type must be string, but is " +
type_name());
2596 template<
typename T,
typename
2621 throw std::domain_error(
"type must be number, but is " +
type_name());
2631 :
throw std::domain_error(
"type must be boolean, but is " +
type_name());
2729 template<
typename ReferenceType,
typename ThisType>
2733 using PointerType =
typename std::add_pointer<ReferenceType>::type;
2734 auto ptr = obj.template get_ptr<PointerType>();
2742 throw std::domain_error(
"incompatible ReferenceType for get_ref, actual type is " +
2785 template<
typename ValueType,
typename
2791 return get_impl(
static_cast<ValueType*
>(
nullptr));
2820 template<
typename PointerType,
typename
2827 return get_ptr<PointerType>();
2834 template<
typename PointerType,
typename
2838 constexpr
const PointerType
get() const noexcept
2841 return get_ptr<PointerType>();
2869 template<
typename PointerType,
typename
2876 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
2883 template<
typename PointerType,
typename
2886 and std::is_const<typename std::remove_pointer<PointerType>::type>
::value
2888 constexpr
const PointerType
get_ptr() const noexcept
2891 return get_impl_ptr(
static_cast<const PointerType
>(
nullptr));
2920 template<
typename ReferenceType,
typename
2927 return get_ref_impl<ReferenceType>(*
this);
2934 template<
typename ReferenceType,
typename
2937 and std::is_const<typename std::remove_reference<ReferenceType>::type>
::value
2942 return get_ref_impl<ReferenceType>(*
this);
2973 template <
typename ValueType,
typename
2977 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
2978 and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>
::value
2981 operator ValueType()
const
2984 return get<ValueType>();
3029 catch (std::out_of_range&)
3032 throw std::out_of_range(
"array index " +
std::to_string(idx) +
" is out of range");
3037 throw std::domain_error(
"cannot use at() with " +
type_name());
3073 catch (std::out_of_range&)
3076 throw std::out_of_range(
"array index " +
std::to_string(idx) +
" is out of range");
3081 throw std::domain_error(
"cannot use at() with " +
type_name());
3121 catch (std::out_of_range&)
3124 throw std::out_of_range(
"key '" + key +
"' not found");
3129 throw std::domain_error(
"cannot use at() with " +
type_name());
3169 catch (std::out_of_range&)
3172 throw std::out_of_range(
"key '" + key +
"' not found");
3177 throw std::domain_error(
"cannot use at() with " +
type_name());
3229 throw std::domain_error(
"cannot use operator[] with " +
type_name());
3262 throw std::domain_error(
"cannot use operator[] with " +
type_name());
3310 throw std::domain_error(
"cannot use operator[] with " +
type_name());
3352 throw std::domain_error(
"cannot use operator[] with " +
type_name());
3383 template<
typename T, std::
size_t n>
3386 return operator[](
static_cast<const T
>(key));
3418 template<
typename T, std::
size_t n>
3421 return operator[](
static_cast<const T
>(key));
3451 template<
typename T>
3469 throw std::domain_error(
"cannot use operator[] with " +
type_name());
3500 template<
typename T>
3512 throw std::domain_error(
"cannot use operator[] with " +
type_name());
3564 template <
class ValueType,
typename
3568 ValueType
value(
const typename object_t::key_type& key, ValueType default_value)
const
3574 const auto it =
find(key);
3581 return default_value;
3586 throw std::domain_error(
"cannot use value() with " +
type_name());
3594 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
3727 template <
class InteratorType,
typename
3736 if (
this != pos.m_object)
3738 throw std::domain_error(
"iterator does not fit current value");
3741 InteratorType result =
end();
3751 if (not pos.m_it.primitive_iterator.is_begin())
3753 throw std::out_of_range(
"iterator out of range");
3769 result.m_it.object_iterator =
m_value.
object->erase(pos.m_it.object_iterator);
3776 result.m_it.array_iterator =
m_value.
array->erase(pos.m_it.array_iterator);
3782 throw std::domain_error(
"cannot use erase() with " +
type_name());
3835 template <
class InteratorType,
typename
3841 InteratorType
erase(InteratorType first, InteratorType last)
3844 if (
this != first.m_object or
this != last.m_object)
3846 throw std::domain_error(
"iterators do not fit current value");
3849 InteratorType result =
end();
3859 if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
3861 throw std::out_of_range(
"iterators out of range");
3877 result.m_it.object_iterator =
m_value.
object->erase(first.m_it.object_iterator,
3878 last.m_it.object_iterator);
3885 result.m_it.array_iterator =
m_value.
array->erase(first.m_it.array_iterator,
3886 last.m_it.array_iterator);
3892 throw std::domain_error(
"cannot use erase() with " +
type_name());
3938 throw std::domain_error(
"cannot use erase() with " +
type_name());
3973 throw std::out_of_range(
"index out of range");
3981 throw std::domain_error(
"cannot use erase() with " +
type_name());
4014 auto result =
end();
4031 auto result =
cend();
4691 throw std::domain_error(
"cannot use push_back() with " +
type_name());
4727 throw std::domain_error(
"cannot use push_back() with " +
type_name());
4777 throw std::domain_error(
"cannot use push_back() with " +
type_name());
4832 throw std::domain_error(
"iterator does not fit current value");
4843 throw std::domain_error(
"cannot use insert() with " +
type_name());
4888 throw std::domain_error(
"iterator does not fit current value");
4899 throw std::domain_error(
"cannot use insert() with " +
type_name());
4938 throw std::domain_error(
"cannot use insert() with " +
type_name());
4944 throw std::domain_error(
"iterator does not fit current value");
4949 throw std::domain_error(
"iterators do not fit");
4954 throw std::domain_error(
"passed iterators may not belong to container");
4996 throw std::domain_error(
"cannot use insert() with " +
type_name());
5002 throw std::domain_error(
"iterator does not fit current value");
5070 throw std::domain_error(
"cannot use swap() with " +
type_name());
5104 throw std::domain_error(
"cannot use swap() with " +
type_name());
5138 throw std::domain_error(
"cannot use swap() with " +
type_name());
5164 static constexpr std::array<uint8_t, 8> order = {{
5182 return order[
static_cast<std::size_t
>(lhs)] < order[
static_cast<std::size_t
>(rhs)];
5211 const auto lhs_type = lhs.type();
5212 const auto rhs_type = rhs.type();
5214 if (lhs_type == rhs_type)
5220 assert(lhs.m_value.array !=
nullptr);
5221 assert(rhs.m_value.array !=
nullptr);
5222 return *lhs.m_value.array == *rhs.m_value.array;
5226 assert(lhs.m_value.object !=
nullptr);
5227 assert(rhs.m_value.object !=
nullptr);
5228 return *lhs.m_value.object == *rhs.m_value.object;
5236 assert(lhs.m_value.string !=
nullptr);
5237 assert(rhs.m_value.string !=
nullptr);
5238 return *lhs.m_value.string == *rhs.m_value.string;
5242 return lhs.m_value.boolean == rhs.m_value.boolean;
5246 return lhs.m_value.number_integer == rhs.m_value.number_integer;
5250 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
5254 return lhs.m_value.number_float == rhs.m_value.number_float;
5264 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
5268 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
5272 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
5276 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
5280 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
5284 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
5340 return not (lhs == rhs);
5363 return not v.is_null();
5372 return not v.is_null();
5401 const auto lhs_type = lhs.type();
5402 const auto rhs_type = rhs.type();
5404 if (lhs_type == rhs_type)
5410 assert(lhs.m_value.array !=
nullptr);
5411 assert(rhs.m_value.array !=
nullptr);
5412 return *lhs.m_value.array < *rhs.m_value.array;
5416 assert(lhs.m_value.object !=
nullptr);
5417 assert(rhs.m_value.object !=
nullptr);
5418 return *lhs.m_value.object < *rhs.m_value.object;
5426 assert(lhs.m_value.string !=
nullptr);
5427 assert(rhs.m_value.string !=
nullptr);
5428 return *lhs.m_value.string < *rhs.m_value.string;
5432 return lhs.m_value.boolean < rhs.m_value.boolean;
5436 return lhs.m_value.number_integer < rhs.m_value.number_integer;
5440 return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
5444 return lhs.m_value.number_float < rhs.m_value.number_float;
5454 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
5458 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
5462 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
5466 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
5470 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
5474 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
5502 return not (rhs < lhs);
5524 return not (lhs <= rhs);
5546 return not (lhs < rhs);
5585 const auto indentation = (
pretty_print ? o.width() : 0);
5759 std::size_t result = 0;
5761 for (
const auto& c : s)
5780 if (c >= 0x00 and c <= 0x1f)
5815 string_t result(s.size() + space,
'\\');
5816 std::size_t pos = 0;
5818 for (
const auto& c : s)
5825 result[pos + 1] =
'"';
5841 result[pos + 1] =
'b';
5849 result[pos + 1] =
'f';
5857 result[pos + 1] =
'n';
5865 result[pos + 1] =
'r';
5873 result[pos + 1] =
't';
5880 if (c >= 0x00 and c <= 0x1f)
5884 auto hexify = [](
const char v) ->
char
5886 return (v < 10) ? (
'0' + v) : (
'a' + v - 10);
5891 {
'u',
'0',
'0', hexify(c >> 4), hexify(c & 0x0f)
5931 const unsigned int indent_step,
5932 const unsigned int current_indent = 0)
const
5935 unsigned int new_indent = current_indent;
5954 new_indent += indent_step;
5964 o <<
string_t(new_indent,
' ') <<
"\""
5967 i->second.dump(o,
pretty_print, indent_step, new_indent);
5973 new_indent -= indent_step;
5977 o <<
string_t(new_indent,
' ') +
"}";
5996 new_indent += indent_step;
6013 new_indent -= indent_step;
6017 o <<
string_t(new_indent,
' ') <<
"]";
6056 o << std::fixed << std::setprecision(1);
6061 o.unsetf(std::ios_base::floatfield);
6062 o << std::setprecision(std::numeric_limits<double>::digits10);
6178 template<
typename IteratorType>
6179 class iteration_proxy
6220 assert(
anchor.m_object !=
nullptr);
6222 switch (
anchor.m_object->type())
6245 typename IteratorType::reference
value()
const
6287 class const_iterator :
public std::iterator<std::random_access_iterator_tag, const basic_json>
6391 assert(
m_object->m_value.object !=
nullptr);
6398 assert(
m_object->m_value.array !=
nullptr);
6427 assert(
m_object->m_value.object !=
nullptr);
6434 assert(
m_object->m_value.array !=
nullptr);
6471 throw std::out_of_range(
"cannot get value");
6482 throw std::out_of_range(
"cannot get value");
6517 throw std::out_of_range(
"cannot get value");
6526 auto result = *
this;
6563 auto result = *
this;
6603 throw std::domain_error(
"cannot compare iterators of different containers");
6639 throw std::domain_error(
"cannot compare iterators of different containers");
6648 throw std::domain_error(
"cannot compare order of object iterators");
6666 return not other.operator < (*this);
6690 throw std::domain_error(
"cannot use offsets with object iterators");
6718 auto result = *
this;
6726 auto result = *
this;
6740 throw std::domain_error(
"cannot use offsets with object iterators");
6764 throw std::domain_error(
"cannot use operator[] for object iterators");
6774 throw std::out_of_range(
"cannot get value");
6785 throw std::out_of_range(
"cannot get value");
6792 typename object_t::key_type
key()
const
6802 throw std::domain_error(
"cannot use key() for non-object iterators");
6922 auto result = *
this;
6930 auto result = *
this;
6971 template<
typename Base>
6972 class json_reverse_iterator :
public std::reverse_iterator<Base>
6993 return base_iterator::operator++(1);
6999 base_iterator::operator++();
7006 return base_iterator::operator--(1);
7012 base_iterator::operator--();
7019 base_iterator::operator+=(i);
7026 auto result = *
this;
7034 auto result = *
this;
7042 return this->base() - other.base();
7052 typename object_t::key_type
key()
const
7054 auto it = --this->base();
7061 auto it = --this->base();
7062 return it.operator * ();
7115 explicit lexer(std::istream* s) noexcept
7149 const std::size_t codepoint2 = 0)
7152 std::size_t codepoint = codepoint1;
7155 if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
7158 if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
7172 throw std::invalid_argument(
"missing or wrong low surrogate");
7178 if (codepoint < 0x80)
7181 result.append(1,
static_cast<typename string_t::value_type
>(codepoint));
7183 else if (codepoint <= 0x7ff)
7186 result.append(1,
static_cast<typename string_t::value_type
>(0xC0 | ((codepoint >> 6) & 0x1F)));
7187 result.append(1,
static_cast<typename string_t::value_type
>(0x80 | (codepoint & 0x3F)));
7189 else if (codepoint <= 0xffff)
7192 result.append(1,
static_cast<typename string_t::value_type
>(0xE0 | ((codepoint >> 12) & 0x0F)));
7193 result.append(1,
static_cast<typename string_t::value_type
>(0x80 | ((codepoint >> 6) & 0x3F)));
7194 result.append(1,
static_cast<typename string_t::value_type
>(0x80 | (codepoint & 0x3F)));
7196 else if (codepoint <= 0x10ffff)
7199 result.append(1,
static_cast<typename string_t::value_type
>(0xF0 | ((codepoint >> 18) & 0x07)));
7200 result.append(1,
static_cast<typename string_t::value_type
>(0x80 | ((codepoint >> 12) & 0x3F)));
7201 result.append(1,
static_cast<typename string_t::value_type
>(0x80 | ((codepoint >> 6) & 0x3F)));
7202 result.append(1,
static_cast<typename string_t::value_type
>(0x80 | (codepoint & 0x3F)));
7206 throw std::out_of_range(
"code points above 0x10FFFF are invalid");
7218 return "<uninitialized>";
7220 return "true literal";
7222 return "false literal";
7224 return "null literal";
7226 return "string literal";
7228 return "number literal";
7242 return "<parse error>";
7244 return "end of input";
7248 return "unknown token";
7275 unsigned int yyaccept = 0;
7276 static const unsigned char yybm[] =
7278 0, 0, 0, 0, 0, 0, 0, 0,
7279 0, 32, 32, 0, 0, 32, 0, 0,
7280 128, 128, 128, 128, 128, 128, 128, 128,
7281 128, 128, 128, 128, 128, 128, 128, 128,
7282 160, 128, 0, 128, 128, 128, 128, 128,
7283 128, 128, 128, 128, 128, 128, 128, 128,
7284 192, 192, 192, 192, 192, 192, 192, 192,
7285 192, 192, 128, 128, 128, 128, 128, 128,
7286 128, 128, 128, 128, 128, 128, 128, 128,
7287 128, 128, 128, 128, 128, 128, 128, 128,
7288 128, 128, 128, 128, 128, 128, 128, 128,
7289 128, 128, 128, 128, 0, 128, 128, 128,
7290 128, 128, 128, 128, 128, 128, 128, 128,
7291 128, 128, 128, 128, 128, 128, 128, 128,
7292 128, 128, 128, 128, 128, 128, 128, 128,
7293 128, 128, 128, 128, 128, 128, 128, 128,
7294 128, 128, 128, 128, 128, 128, 128, 128,
7295 128, 128, 128, 128, 128, 128, 128, 128,
7296 128, 128, 128, 128, 128, 128, 128, 128,
7297 128, 128, 128, 128, 128, 128, 128, 128,
7298 128, 128, 128, 128, 128, 128, 128, 128,
7299 128, 128, 128, 128, 128, 128, 128, 128,
7300 128, 128, 128, 128, 128, 128, 128, 128,
7301 128, 128, 128, 128, 128, 128, 128, 128,
7302 128, 128, 128, 128, 128, 128, 128, 128,
7303 128, 128, 128, 128, 128, 128, 128, 128,
7304 128, 128, 128, 128, 128, 128, 128, 128,
7305 128, 128, 128, 128, 128, 128, 128, 128,
7306 128, 128, 128, 128, 128, 128, 128, 128,
7307 128, 128, 128, 128, 128, 128, 128, 128,
7308 128, 128, 128, 128, 128, 128, 128, 128,
7309 128, 128, 128, 128, 128, 128, 128, 128,
7316 if (yybm[0 + yych] & 32)
7318 goto basic_json_parser_6;
7328 goto basic_json_parser_2;
7332 goto basic_json_parser_4;
7334 goto basic_json_parser_9;
7340 goto basic_json_parser_4;
7344 goto basic_json_parser_10;
7346 goto basic_json_parser_12;
7355 goto basic_json_parser_4;
7359 goto basic_json_parser_13;
7361 goto basic_json_parser_15;
7367 goto basic_json_parser_17;
7371 goto basic_json_parser_19;
7373 goto basic_json_parser_4;
7385 goto basic_json_parser_21;
7389 goto basic_json_parser_4;
7391 goto basic_json_parser_23;
7397 goto basic_json_parser_24;
7401 goto basic_json_parser_4;
7403 goto basic_json_parser_25;
7412 goto basic_json_parser_26;
7414 goto basic_json_parser_4;
7420 goto basic_json_parser_28;
7424 goto basic_json_parser_30;
7426 goto basic_json_parser_4;
7430 basic_json_parser_2:
7435 basic_json_parser_4:
7437 basic_json_parser_5:
7441 basic_json_parser_6:
7448 if (yybm[0 + yych] & 32)
7450 goto basic_json_parser_6;
7455 basic_json_parser_9:
7460 goto basic_json_parser_5;
7462 goto basic_json_parser_32;
7463 basic_json_parser_10:
7468 basic_json_parser_12:
7472 goto basic_json_parser_5;
7476 goto basic_json_parser_13;
7480 goto basic_json_parser_15;
7482 goto basic_json_parser_5;
7483 basic_json_parser_13:
7490 goto basic_json_parser_37;
7497 goto basic_json_parser_38;
7501 goto basic_json_parser_38;
7504 basic_json_parser_14:
7508 basic_json_parser_15:
7516 if (yybm[0 + yych] & 64)
7518 goto basic_json_parser_15;
7524 goto basic_json_parser_37;
7526 goto basic_json_parser_14;
7532 goto basic_json_parser_38;
7536 goto basic_json_parser_38;
7538 goto basic_json_parser_14;
7540 basic_json_parser_17:
7545 basic_json_parser_19:
7550 basic_json_parser_21:
7555 basic_json_parser_23:
7560 goto basic_json_parser_39;
7562 goto basic_json_parser_5;
7563 basic_json_parser_24:
7568 goto basic_json_parser_40;
7570 goto basic_json_parser_5;
7571 basic_json_parser_25:
7576 goto basic_json_parser_41;
7578 goto basic_json_parser_5;
7579 basic_json_parser_26:
7584 basic_json_parser_28:
7589 basic_json_parser_30:
7594 goto basic_json_parser_42;
7596 goto basic_json_parser_5;
7597 basic_json_parser_31:
7604 basic_json_parser_32:
7605 if (yybm[0 + yych] & 128)
7607 goto basic_json_parser_31;
7611 goto basic_json_parser_33;
7615 goto basic_json_parser_34;
7617 goto basic_json_parser_36;
7618 basic_json_parser_33:
7622 goto basic_json_parser_5;
7626 goto basic_json_parser_14;
7628 basic_json_parser_34:
7633 basic_json_parser_36:
7646 goto basic_json_parser_31;
7650 goto basic_json_parser_33;
7652 goto basic_json_parser_31;
7660 goto basic_json_parser_33;
7662 goto basic_json_parser_31;
7668 goto basic_json_parser_31;
7670 goto basic_json_parser_33;
7680 goto basic_json_parser_31;
7684 goto basic_json_parser_31;
7686 goto basic_json_parser_33;
7694 goto basic_json_parser_31;
7696 goto basic_json_parser_33;
7702 goto basic_json_parser_31;
7706 goto basic_json_parser_43;
7708 goto basic_json_parser_33;
7712 basic_json_parser_37:
7716 goto basic_json_parser_33;
7720 goto basic_json_parser_44;
7722 goto basic_json_parser_33;
7723 basic_json_parser_38:
7729 goto basic_json_parser_46;
7731 goto basic_json_parser_33;
7737 goto basic_json_parser_46;
7741 goto basic_json_parser_33;
7745 goto basic_json_parser_47;
7747 goto basic_json_parser_33;
7749 basic_json_parser_39:
7753 goto basic_json_parser_49;
7755 goto basic_json_parser_33;
7756 basic_json_parser_40:
7760 goto basic_json_parser_50;
7762 goto basic_json_parser_33;
7763 basic_json_parser_41:
7767 goto basic_json_parser_51;
7769 goto basic_json_parser_33;
7770 basic_json_parser_42:
7774 goto basic_json_parser_52;
7776 goto basic_json_parser_33;
7777 basic_json_parser_43:
7788 goto basic_json_parser_33;
7792 goto basic_json_parser_54;
7794 goto basic_json_parser_33;
7800 goto basic_json_parser_54;
7804 goto basic_json_parser_33;
7808 goto basic_json_parser_54;
7810 goto basic_json_parser_33;
7812 basic_json_parser_44:
7824 goto basic_json_parser_14;
7828 goto basic_json_parser_44;
7830 goto basic_json_parser_14;
7836 goto basic_json_parser_38;
7840 goto basic_json_parser_38;
7842 goto basic_json_parser_14;
7844 basic_json_parser_46:
7848 goto basic_json_parser_33;
7852 goto basic_json_parser_33;
7854 basic_json_parser_47:
7863 goto basic_json_parser_14;
7867 goto basic_json_parser_47;
7869 goto basic_json_parser_14;
7870 basic_json_parser_49:
7874 goto basic_json_parser_55;
7876 goto basic_json_parser_33;
7877 basic_json_parser_50:
7881 goto basic_json_parser_56;
7883 goto basic_json_parser_33;
7884 basic_json_parser_51:
7888 goto basic_json_parser_58;
7890 goto basic_json_parser_33;
7891 basic_json_parser_52:
7896 basic_json_parser_54:
7907 goto basic_json_parser_33;
7911 goto basic_json_parser_60;
7913 goto basic_json_parser_33;
7919 goto basic_json_parser_60;
7923 goto basic_json_parser_33;
7927 goto basic_json_parser_60;
7929 goto basic_json_parser_33;
7931 basic_json_parser_55:
7935 goto basic_json_parser_61;
7937 goto basic_json_parser_33;
7938 basic_json_parser_56:
7943 basic_json_parser_58:
7948 basic_json_parser_60:
7959 goto basic_json_parser_33;
7963 goto basic_json_parser_63;
7965 goto basic_json_parser_33;
7971 goto basic_json_parser_63;
7975 goto basic_json_parser_33;
7979 goto basic_json_parser_63;
7981 goto basic_json_parser_33;
7983 basic_json_parser_61:
7988 basic_json_parser_63:
7999 goto basic_json_parser_33;
8003 goto basic_json_parser_31;
8005 goto basic_json_parser_33;
8011 goto basic_json_parser_31;
8015 goto basic_json_parser_33;
8019 goto basic_json_parser_31;
8021 goto basic_json_parser_33;
8039 m_buffer.erase(0,
static_cast<size_t>(offset_start));
8057 return string_t(
reinterpret_cast<typename string_t::const_pointer
>(
m_start),
8144 auto codepoint = std::strtoul(std::string(
reinterpret_cast<typename string_t::const_pointer
>(i + 1),
8145 4).c_str(),
nullptr, 16);
8148 if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
8151 if ((i + 6 >=
m_limit) or * (i + 5) !=
'\\' or * (i + 6) !=
'u')
8153 throw std::invalid_argument(
"missing low surrogate");
8157 auto codepoint2 = std::strtoul(std::string(
reinterpret_cast<typename string_t::const_pointer
>
8158 (i + 7), 4).c_str(),
nullptr, 16);
8178 result.append(1,
static_cast<typename string_t::value_type
>(*i));
8207 return std::strtold(
reinterpret_cast<typename string_t::const_pointer
>(
m_start), endptr);
8227 return std::strtod(
reinterpret_cast<typename string_t::const_pointer
>(
m_start), endptr);
8247 return std::strtof(
reinterpret_cast<typename string_t::const_pointer
>(
m_start), endptr);
8262 template <
typename T_A,
typename T_B>
8265 dest =
static_cast<T_B
>(source);
8266 return (source ==
static_cast<T_A
>(dest));
8309 typename string_t::value_type* endptr;
8315 if (*
reinterpret_cast<typename string_t::const_pointer
>(
m_start) !=
'-')
8319 if (
attempt_cast(std::strtoull(
reinterpret_cast<typename string_t::const_pointer
>(
m_start), &endptr,
8334 if (
attempt_cast(std::strtoll(
reinterpret_cast<typename string_t::const_pointer
>(
m_start), &endptr,
8365 throw std::invalid_argument(std::string(
"parse error - ") +
get_token() +
" is not a number");
8470 bool keep_tag =
false;
8491 if (keep and keep_tag and not
value.is_discarded())
8546 if (keep and not
value.is_discarded())
8583 result.m_value =
true;
8591 result.m_value =
false;
8627 std::string error_msg =
"parse error - unexpected ";
8631 throw std::invalid_argument(error_msg);
8639 std::string error_msg =
"parse error - unexpected ";
8642 throw std::invalid_argument(error_msg);
8709 const auto& h = hash<nlohmann::json::string_t>();
8733 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
8734 #pragma GCC diagnostic pop
const_reference at(size_type idx) const
access specified array element with bounds checking
@ value
the parser finished reading a JSON value
iterator & operator=(iterator other) noexcept(std::is_nothrow_move_constructible< pointer >::value and std::is_nothrow_move_assignable< pointer >::value and std::is_nothrow_move_constructible< internal_iterator >::value and std::is_nothrow_move_assignable< internal_iterator >::value)
copy assignment
const_iterator & operator-=(difference_type i)
subtract from iterator
@ literal_false
the "false" literal
constexpr const PointerType get() const noexcept
get a pointer value (explicit)
basic_json(const value_t value_type)
create an empty value with a given type
const lexer_char_t * m_limit
pointer to the end of the buffer
InteratorType erase(InteratorType first, InteratorType last)
remove elements given an iterator range
ReferenceType get_ref()
get a reference value (implicit)
array_t get_impl(array_t *) const
get an array (explicit)
iterator(const iterator &other) noexcept
copy constructor
@ object_end
the parser read } and finished processing a JSON object
typename basic_json::const_pointer pointer
defines a pointer to the type iterated over (value_type)
IteratorType::reference value() const
return value of the iterator
const_reference front() const
access the first element
iterator insert(const_iterator pos, basic_json &&val)
inserts element
static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
deserialize from stream
constexpr bool is_discarded() const noexcept
return whether value is discarded
float str_to_float_t(float *, char **endptr) const
parse floating point number
constexpr bool is_end() const noexcept
return whether the iterator is at end
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adaptor
json_reverse_iterator & operator+=(difference_type i)
add to iterator
static string_t to_unicode(const std::size_t codepoint1, const std::size_t codepoint2=0)
create a string from a Unicode code point
bool operator!=(const const_iterator &other) const
comparison: not equal
size_type count(typename object_t::key_type key) const
returns the number of occurrences of a key in a JSON object
StringType string_t
a type for a string
@ parse_error
indicating a parse error
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
reference front()
access the first element
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts elements
iteration_proxy_internal begin() noexcept
return iterator begin (needed for range-based for)
basic_json(const number_float_t val) noexcept
create a floating-point number (explicit)
reference operator*()
return a reference to the value pointed to by the iterator
@ discarded
discarded by the the parser callback function
json_value(value_t t)
constructor for empty values of a given type
bool operator!=(const iteration_proxy_internal &o) const
inequality operator (needed for range-based for)
iterator(pointer object) noexcept
constructor for a given JSON instance
object_t::key_type key() const
return the key of an object iterator
basic_json::string_t key() const
return key of the iterator
const_reference operator[](T *key) const
read-only access specified object element
const_iterator & operator+=(difference_type i)
add to iterator
const value_type & const_reference
the type of an element const reference
reference operator[](T *(&key)[n])
access specified object element
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
const_iterator & operator=(const_iterator other) noexcept(std::is_nothrow_move_constructible< pointer >::value and std::is_nothrow_move_assignable< pointer >::value and std::is_nothrow_move_constructible< internal_iterator >::value and std::is_nothrow_move_assignable< internal_iterator >::value)
copy assignment
const_iterator operator--(int)
post-decrement (it–)
iteration_proxy_internal end() noexcept
return iterator end (needed for range-based for)
const_iterator(const iterator &other) noexcept
copy constructor given a nonconst iterator
void push_back(const typename object_t::value_type &val)
add an object to an object
@ end_array
the character for array end "]"
const_iterator operator+(difference_type i)
add to iterator
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value and is_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
std::string to_string(const T &value)
void clear() noexcept
clears the contents
difference_type operator-(const json_reverse_iterator &other) const
return difference
PointerType get_ptr() noexcept
get a pointer value (implicit)
string_t get_token() const
return string representation of last read token
@ end_object
the character for object end "}"
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
number_float_t number_float
number (floating-point)
const_iterator(pointer object) noexcept
constructor for a given JSON instance
iterator end() noexcept
returns an iterator to one past the last element
friend bool operator!=(std::nullptr_t, const_reference v) noexcept
comparison: not equal
@ array
array (ordered collection of values)
friend bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
basic_json(const array_t &val)
create an array (explicit)
basic_json parse_internal(bool keep)
the actual parser
bool operator<=(const const_iterator &other) const
comparison: less than or equal
constexpr bool is_number() const noexcept
return whether value is a number
basic_json parse()
public parser interface
string_t m_buffer
the buffer
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
iterator find(typename object_t::key_type key)
find an element in a JSON object
void push_back(const basic_json &val)
add an object to an array
a template for a reverse iterator class
namespace for Niels Lohmann
static constexpr bool value
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
iterator operator--(int)
post-decrement (it–)
parser(const string_t &s, parser_callback_t cb=nullptr) noexcept
constructor for strings
constexpr boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
parse_event_t
JSON callback events.
lexer(const string_t &s) noexcept
constructor with a given buffer
iteration_proxy_internal & operator*()
dereference operator (needed for range-based for)
const_iterator base_iterator
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
@ begin_object
the character for object begin "{"
reference operator[](size_type idx)
access specified array element
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
ValueType get() const
get a value (explicit)
static constexpr difference_type end_value
const lexer_char_t * m_cursor
pointer to the current symbol
lexer::token_type last_token
the type of the last read token
const_iterator end() const noexcept
returns a const iterator to one past the last element
reference operator[](difference_type n) const
access to successor
void set_begin() noexcept
set iterator to a defined beginning
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
std::vector< T > get_impl(std::vector< T > *) const
get an array (explicit)
basic_json value_type
the type of elements in a basic_json container
constexpr bool is_object() const noexcept
return whether value is an object
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
iterator begin() noexcept
returns an iterator to the first element
NumberFloatType number_float_t
a type for a number (floating-point)
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
basic_json(basic_json &&other) noexcept
move constructor
object_t get_impl(object_t *) const
get an object (explicit)
std::bidirectional_iterator_tag iterator_category
the category of the iterator
typename basic_json::value_type value_type
the type of the values when the iterator is dereferenced
@ literal_true
the "true" literal
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
basic_json(const basic_json &other)
copy constructor
@ begin_array
the character for array begin "["
reference & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value)
copy assignment
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
T get_impl(T *) const
get an object (explicit)
iterator()=default
default constructor
const_iterator cend() const noexcept
returns a const iterator to one past the last element
const_iterator & operator++()
pre-increment (++it)
@ object_start
the parser read { and started to process a JSON object
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
@ number_integer
number value (integer)
iterator & operator-=(difference_type i)
subtract from iterator
@ literal_null
the "null" literal
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
static iteration_proxy< iterator > iterator_wrapper(reference cont)
wrapper to access iterator member functions in range-based for
std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
per-element parser callback type
size_type size() const noexcept
returns the number of elements
reference operator[](const typename object_t::key_type &key)
access specified object element
basic_json(const CompatibleObjectType &val)
create an object (implicit)
@ name_separator
the name separator ":"
reference value() const
return the value of an iterator
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
constexpr bool is_boolean() const noexcept
return whether value is a boolean
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
bool operator>(const const_iterator &other) const
comparison: greater than
NumberIntegerType number_integer_t
a type for a number (integer)
const lexer_char_t * m_marker
pointer for backtracking information
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
@ array_end
the parser read ] and finished processing a JSON array
BooleanType boolean_t
a type for a boolean
ValueType value(const typename object_t::key_type &key, ValueType default_value) const
access specified object element with default value
InteratorType erase(InteratorType pos)
remove element given an iterator
constexpr bool is_primitive() const noexcept
return whether type is primitive
value_t
the JSON type enumeration
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
array_t::iterator array_iterator
iterator for JSON arrays
const_reference operator[](T *(&key)[n]) const
read-only access specified object element
friend bool operator!=(const_reference v, std::nullptr_t) noexcept
comparison: not equal
bool operator==(const const_iterator &other) const
comparison: equal
helper class for iteration
const_iterator operator-(difference_type i)
subtract from iterator
reference operator+=(const basic_json &val)
add an object to an array
json_reverse_iterator operator+(difference_type i) const
add to iterator
constexpr bool is_null() const noexcept
return whether value is null
json_value(boolean_t v) noexcept
constructor for booleans
primitive_iterator_t primitive_iterator
generic iterator for all other types
number_unsigned_t number_unsigned
number (unsigned integer)
static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
deserialize from stream
std::ptrdiff_t difference_type
a type to represent differences between iterators
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
ReferenceType get_ref() const
get a reference value (implicit)
basic_json(boolean_t val) noexcept
create a boolean (explicit)
static allocator_type get_allocator()
returns the allocator associated with the container
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
basic_json(const number_unsigned_t val) noexcept
create an unsigned integer number (explicit)
static T * create(Args &&... args)
helper for exception-safe object creation
difference_type operator-(const iterator &other) const
return difference
iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
inserts elements
json_value(const object_t &value)
constructor for objects
basic_json(const CompatibleNumberFloatType val) noexcept
create an floating-point number (implicit)
reference operator+=(const typename object_t::value_type &val)
add an object to an object
reference operator[](difference_type n) const
access to successor
iteration_proxy(typename IteratorType::reference cont)
construct iteration proxy from a container
void set_begin() noexcept
set the iterator to the first value
@ array_start
the parser read [ and started to process a JSON array
void erase(const size_type idx)
remove element from a JSON array given an index
basic_json(const object_t &val)
create an object (explicit)
unsigned char lexer_char_t
the char type to use in the lexer
reference value() const
return the value of an iterator
basic_json(const CompatibleNumberIntegerType val) noexcept
create an integer number (implicit)
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
const_iterator find(typename object_t::key_type key) const
find an element in a JSON object
fmt::BufferedFile & move(fmt::BufferedFile &f)
token_type
token types for the parser
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
iterator operator++(int)
post-increment (it++)
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
@ end_of_input
indicating the end of the input buffer
@ number_float
number value (floating-point)
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
basic_json()=default
create a null object (implicitly)
string_t value(const typename object_t::key_type &key, const char *default_value) const
overload for a default value of type const char*
void swap(object_t &other)
exchanges the values
const lexer_char_t * m_content
the buffer pointer
number_integer_t number_integer
number (integer)
void set_end() noexcept
set iterator to a defined past the end
static basic_json object(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
explicitly create an object from an initializer list
const_reverse_iterator rbegin() const noexcept
returns a const reverse iterator to the last element
reference operator[](T *key)
access specified object element
long double str_to_float_t(long double *, char **endptr) const
parse floating point number
array_t * array
array (stored with pointer to save storage)
basic_json(const CompatibleStringType &val)
create a string (implicit)
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
pointer operator->()
dereference the iterator
json_reverse_iterator & operator++()
pre-increment (++it)
basic_json(std::istream &i, parser_callback_t cb=nullptr)
construct a JSON value given an input stream
static std::string token_type_name(token_type t)
return name of values of type token_type (only used for errors)
constexpr const PointerType get_ptr() const noexcept
get a pointer value (implicit)
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
void push_back(basic_json &&val)
add an object to an array
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
@ key
the parser read a key of a value in an object
difference_type m_it
iterator as signed integer type
proxy class for the iterator_wrapper functions
token_type scan() noexcept
const_iterator operator++(int)
post-increment (it++)
std::istream * m_stream
optional input stream
value_type & reference
the type of an element reference
basic_json(const string_t &val)
create a string (explicit)
json_value(const string_t &value)
constructor for strings
pointer m_object
associated JSON instance
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
@ uninitialized
indicating the scanner is uninitialized
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
json_value()=default
default constructor (for null values)
json_reverse_iterator & operator--()
pre-decrement (–it)
size_type max_size() const noexcept
returns the maximum possible number of elements
string_t get_string() const
return string value for string tokens
std::size_t size_type
a type to represent container sizes
iterator & operator++()
pre-increment (++it)
lexer(std::istream *s) noexcept
constructor with a given stream
void expect(typename lexer::token_type t) const
typename basic_json::const_reference reference
defines a reference to the type iterated over (value_type)
iterator & operator+=(difference_type i)
add to iterator
@ object
object (unordered set of name/value pairs)
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
void get_number(basic_json &result) const
return number value for number tokens
lexer::token_type get_token() noexcept
get next token from lexer
string_t dump(const int indent=-1) const
serialization
internal_iterator() noexcept
create an uninitialized internal_iterator
json_reverse_iterator operator--(int)
post-decrement (it–)
constexpr bool is_structured() const noexcept
return whether type is structured
object_t * object
object (stored with pointer to save storage)
void set_end() noexcept
set the iterator past the last value
lexer operator=(const lexer &)=delete
void yyfill() noexcept
append data from the stream to the internal buffer
reference operator[](difference_type n) const
access to successor
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
friend bool operator==(std::nullptr_t, const_reference v) noexcept
comparison: equal
const lexer_char_t * m_start
pointer to the beginning of the current symbol
const_reference back() const
access the last element
a class to store JSON values
IteratorType anchor
the iterator
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
explicitly create an array from an initializer list
void swap(array_t &other)
exchanges the values
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
iterator & operator--()
pre-decrement (–it)
basic_json(std::nullptr_t) noexcept
create a null object (explicitly)
reference value() const
return the value of an iterator
size_t array_index
an index for arrays (used to create key names)
AllocatorType< basic_json > allocator_type
the allocator type
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
difference_type operator-(const const_iterator &other) const
return difference
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
@ number_unsigned
number value (unsigned integer)
typename Base::reference reference
the reference type for the pointed-to element
void dump(std::ostream &o, const bool pretty_print, const unsigned int indent_step, const unsigned int current_indent=0) const
internal implementation of the serialization function
void swap(string_t &other)
exchanges the values
double str_to_float_t(double *, char **endptr) const
parse floating point number
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
basic_json(const number_integer_t val) noexcept
create an integer number (explicit)
pointer operator->() const
dereference the iterator
IteratorType::reference container
the container to iterate
const_reverse_iterator rend() const noexcept
returns a const reverse iterator to one before the first
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
reference operator+=(basic_json &&val)
add an object to an array
bool operator<(const const_iterator &other) const
comparison: smaller
parser_callback_t callback
callback function
reference operator*() const
return a reference to the value pointed to by the iterator
static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
deserialize from string
constexpr bool is_string() const noexcept
return whether value is a string
const_iterator()=default
default constructor
iterator insert(const_iterator pos, const basic_json &val)
inserts element
an iterator for primitive JSON types
static std::size_t extra_space(const string_t &s) noexcept
calculates the extra space to escape a JSON string
PointerType get() noexcept
get a pointer value (explicit)
basic_json(const CompatibleNumberUnsignedType val) noexcept
create an unsigned number (implicit)
iteration_proxy_internal(IteratorType it) noexcept
@ value_number
a number – use get_number() for actual value
typename basic_json::difference_type difference_type
a type to represent differences between iterators
static string_t escape_string(const string_t &s)
escape a string
a const random access iterator for the basic_json class
string_t type_name() const noexcept
return the type as string
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
a mutable random access iterator for the basic_json class
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
int depth
current level of recursion
static bool attempt_cast(T_A source, T_B &dest)
static_cast between two types and indicate if it results in error
object_t::iterator object_iterator
iterator for JSON objects
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
bool operator>=(const const_iterator &other) const
comparison: greater than or equal
const_reference operator[](size_type idx) const
access specified array element
const_iterator cbegin() const noexcept
returns a const iterator to the first element
bool empty() const noexcept
checks whether the container is empty
iteration_proxy_internal & operator++()
increment operator (needed for range-based for)
static constexpr difference_type begin_value
iterator operator+(difference_type i)
add to iterator
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
string_t * string
string (stored with pointer to save storage)
value_t m_type
the type of the current element
basic_json(std::initializer_list< basic_json > init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
const_reference operator[](const typename object_t::key_type &key) const
read-only access specified object element
json_value(const array_t &value)
constructor for arrays
object_t::key_type key() const
return the key of an object iterator
void unexpect(typename lexer::token_type t) const
internal_iterator m_it
the actual iterator of the associated instance
constexpr bool is_array() const noexcept
return whether value is an array
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
const_iterator & operator--()
pre-decrement (–it)
friend bool operator==(const_reference v, std::nullptr_t) noexcept
comparison: equal
json_reverse_iterator operator++(int)
post-increment (it++)
const_iterator(const const_iterator &other) noexcept
copy constructor
lexer()=default
default constructor
basic_json(const typename string_t::value_type *val)
create a string (explicit)
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts elements
json_value m_value
the value of the current element
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
@ value_string
a string – use get_string() for actual value
iterator operator-(difference_type i)
subtract from iterator
@ value_separator
the value separator ","
reference at(size_type idx)
access specified array element with bounds checking
parser(std::istream &_is, parser_callback_t cb=nullptr) noexcept
a parser reading from an input stream
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
const_iterator begin() const noexcept
returns a const iterator to the first element
basic_json(const int val) noexcept
create an integer number from an enum type (explicit)
basic_json(const CompatibleArrayType &val)
create an array (implicit)
reference back()
access the last element
static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
wrapper to access iterator member functions in range-based for
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
std::size_t operator()(const nlohmann::json &j) const
return a hash value for a JSON object