72 #ifndef NLOHMANN_JSON_HPP 73 #define NLOHMANN_JSON_HPP 86 #include <initializer_list> 98 #include <type_traits> 102 #include <wtf/Assertions.h> 103 #include <wtf/Compiler.h> 106 #if defined(__clang__) 107 #define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) 108 #if CLANG_VERSION < 30400 109 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" 111 #elif defined(__GNUC__) 112 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 113 #if GCC_VERSION < 40900 114 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" 119 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 120 #pragma GCC diagnostic push 121 #pragma GCC diagnostic ignored "-Wfloat-equal" 125 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 126 #define JSON_DEPRECATED __attribute__((deprecated)) 127 #elif defined(_MSC_VER) 128 #define JSON_DEPRECATED __declspec(deprecated) 130 #define JSON_DEPRECATED 159 struct has_mapped_type
162 template <
typename U,
typename =
typename U::mapped_type>
163 static int detect(
U&&);
165 static void detect(...);
167 static constexpr
bool value =
168 std::is_integral<decltype(detect(std::declval<T>()))>::value;
171 template <
typename T,
typename ... Types>
175 throw T(std::forward<Types>(args)...);
263 template<
typename U,
typename... Args>
class ArrayType = std::vector,
268 class NumberFloatType = double,
276 BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType,
312 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
429 std::less<StringType>,
477 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
809 template<
typename T,
typename... Args>
812 AllocatorType<T> alloc;
815 alloc.deallocate(
object, 1);
817 std::unique_ptr<T, decltype(deleter)>
object(alloc.allocate(1), deleter);
818 alloc.construct(
object.
get(), std::forward<Args>(
args)...);
819 assert(
object.
get() !=
nullptr);
820 return object.release();
869 json_value() =
default;
885 object = create<object_t>();
891 array = create<array_t>();
897 string = create<string_t>(
"");
907 case value_t::number_integer:
913 case value_t::number_unsigned:
919 case value_t::number_float:
935 string = create<string_t>(value);
941 object = create<object_t>(value);
945 json_value(
const array_t& value)
947 array = create<array_t>(value);
960 void assert_invariant()
const 1052 basic_json& parsed)>;
1104 :
m_type(value_type), m_value(value_type)
1184 template<
class CompatibleObjectType,
typename std::enable_if<
1185 std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
1186 std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value,
int>
::type = 0>
1192 m_value.object = create<object_t>(begin(val),
end(val));
1247 template<
class CompatibleArrayType,
typename std::enable_if<
1248 not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
1249 not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
1250 not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
1251 not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
1252 not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
1253 not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
1254 std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value,
int>::type = 0>
1260 m_value.array = create<array_t>(begin(val),
end(val));
1346 template<
class CompatibleStringType,
typename std::enable_if<
1347 std::is_constructible<string_t, CompatibleStringType>::value,
int>::type = 0>
1397 template<
typename T,
typename std::enable_if<
1398 not (std::is_same<T, int>::value) and
1399 std::is_same<T, number_integer_t>::value,
int>::type = 0>
1401 :
m_type(value_t::number_integer), m_value(
val)
1432 :
m_type(value_t::number_integer),
1433 m_value(static_cast<number_integer_t>(
val))
1463 template<
typename CompatibleNumberIntegerType,
typename std::enable_if<
1464 std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
1465 std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
1466 std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
1467 CompatibleNumberIntegerType>::type = 0>
1469 :
m_type(value_t::number_integer),
1470 m_value(static_cast<number_integer_t>(
val))
1492 template<
typename T,
typename std::enable_if<
1493 not (std::is_same<T, int>::value) and
1494 std::is_same<T, number_unsigned_t>::value,
int>::type = 0>
1496 :
m_type(value_t::number_unsigned), m_value(
val)
1521 template<
typename CompatibleNumberUnsignedType,
typename std::enable_if <
1522 std::is_constructible<number_unsigned_t, CompatibleNumberUnsignedType>::value and
1523 std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
1524 not std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
1525 CompatibleNumberUnsignedType>::type = 0>
1527 :
m_type(value_t::number_unsigned),
1528 m_value(static_cast<number_unsigned_t>(
val))
1558 :
m_type(value_t::number_float), m_value(
val)
1564 m_value = json_value();
1601 template<
typename CompatibleNumberFloatType,
typename =
typename std::enable_if<
1602 std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
1603 std::is_floating_point<CompatibleNumberFloatType>::value>::type>
1680 bool type_deduction =
true,
1685 bool is_an_object = std::all_of(init.begin(), init.end(),
1692 if (
not type_deduction)
1697 is_an_object =
false;
1703 Throw<std::domain_error>(
"cannot create object from initializer list");
1715 m_value.object->emplace(*(
element[0].m_value.string),
element[1]);
1722 m_value.array = create<array_t>(
init);
1763 std::initializer_list<basic_json>())
1803 std::initializer_list<basic_json>())
1829 m_value.array = create<array_t>(cnt,
val);
1870 template<
class InputIT,
typename std::enable_if<
1871 std::is_same<InputIT, typename basic_json_t::iterator>::value or
1872 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int>::type = 0>
1875 assert(first.m_object !=
nullptr);
1876 assert(last.m_object !=
nullptr);
1879 if (first.m_object != last.m_object)
1881 Throw<std::domain_error>(
"iterators are not compatible");
1885 m_type = first.m_object->m_type;
1891 case value_t::number_float:
1892 case value_t::number_integer:
1893 case value_t::number_unsigned:
1896 if (
not first.m_it.primitive_iterator.is_begin() or
not last.m_it.primitive_iterator.is_end())
1898 Throw<std::out_of_range>(
"iterators out of range");
1911 case value_t::number_integer:
1913 m_value.number_integer = first.m_object->m_value.number_integer;
1917 case value_t::number_unsigned:
1919 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
1923 case value_t::number_float:
1925 m_value.number_float = first.m_object->m_value.number_float;
1931 m_value.boolean = first.m_object->m_value.boolean;
1937 m_value = *first.m_object->m_value.string;
1943 m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
1949 m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
1955 Throw<std::domain_error>(
"cannot use construct with iterators from " + first.m_object->type_name());
2027 other.assert_invariant();
2033 m_value = *other.m_value.object;
2039 m_value = *other.m_value.array;
2045 m_value = *other.m_value.string;
2051 m_value = other.m_value.boolean;
2055 case value_t::number_integer:
2057 m_value = other.m_value.number_integer;
2061 case value_t::number_unsigned:
2063 m_value = other.m_value.number_unsigned;
2067 case value_t::number_float:
2069 m_value = other.m_value.number_float;
2105 other.assert_invariant();
2108 other.m_type = value_t::null;
2138 std::is_nothrow_move_constructible<value_t>::value and
2139 std::is_nothrow_move_assignable<value_t>::value and
2140 std::is_nothrow_move_constructible<json_value>::value and
2141 std::is_nothrow_move_assignable<json_value>::value
2145 other.assert_invariant();
2149 swap(m_value, other.m_value);
2178 AllocatorType<object_t> alloc;
2179 alloc.destroy(m_value.object);
2180 alloc.deallocate(m_value.object, 1);
2186 AllocatorType<array_t> alloc;
2187 alloc.destroy(m_value.array);
2188 alloc.deallocate(m_value.array, 1);
2194 AllocatorType<string_t> alloc;
2195 alloc.destroy(m_value.string);
2196 alloc.deallocate(m_value.string, 1);
2244 std::stringstream ss;
2246 ss.imbue(std::locale::classic());
2252 ss.precision(std::numeric_limits<double>::digits10);
2256 dump(ss,
true, static_cast<unsigned int>(indent));
2316 return is_null() or is_string() or is_boolean() or is_number();
2343 return is_array() or is_object();
2365 return m_type == value_t::null;
2417 return is_number_integer() or is_number_float();
2446 return m_type == value_t::number_integer or
m_type == value_t::number_unsigned;
2474 return m_type == value_t::number_unsigned;
2502 return m_type == value_t::number_float;
2595 return m_type == value_t::discarded;
2629 template<
class T,
typename std::enable_if<
2630 std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
2631 std::is_convertible<basic_json_t, typename T::mapped_type>::value,
int>::type = 0>
2632 T get_impl(
T*)
const 2636 return T(m_value.object->begin(), m_value.object->end());
2640 Throw<std::domain_error>(
"type must be object, but is " + type_name());
2649 return *(m_value.object);
2653 Throw<std::domain_error>(
"type must be object, but is " + type_name());
2658 template<
class T,
typename std::enable_if<
2659 std::is_convertible<basic_json_t, typename T::value_type>::value and
2660 not std::is_same<basic_json_t, typename T::value_type>::value and
2661 not std::is_arithmetic<T>::value and
2662 not std::is_convertible<std::string, T>::value and
2663 not has_mapped_type<T>::value,
int>::type = 0>
2664 T get_impl(T*)
const 2670 std::inserter(to_vector, to_vector.end()), [](
basic_json i)
2672 return i.
get<
typename T::value_type>();
2678 Throw<std::domain_error>(
"type must be array, but is " + type_name());
2683 template<
class T,
typename std::enable_if<
2684 std::is_convertible<basic_json_t, T>::value and
2685 not std::is_same<basic_json_t, T>::value,
int>::type = 0>
2686 std::vector<T> get_impl(std::vector<T>*)
const 2690 std::vector<T> to_vector;
2691 to_vector.reserve(m_value.array->size());
2693 std::inserter(to_vector, to_vector.end()), [](
basic_json i)
2701 Throw<std::domain_error>(
"type must be array, but is " + type_name());
2706 template<
class T,
typename std::enable_if<
2707 std::is_same<basic_json, typename T::value_type>::value and
2708 not has_mapped_type<T>::value,
int>::type = 0>
2709 T get_impl(T*)
const 2713 return T(m_value.array->begin(), m_value.array->end());
2717 Throw<std::domain_error>(
"type must be array, but is " + type_name());
2726 return *(m_value.array);
2730 Throw<std::domain_error>(
"type must be array, but is " + type_name());
2735 template<
typename T,
typename std::enable_if<
2736 std::is_convertible<string_t, T>::value,
int>::type = 0>
2737 T get_impl(T*)
const 2741 return *m_value.string;
2745 Throw<std::domain_error>(
"type must be string, but is " + type_name());
2750 template<
typename T,
typename std::enable_if<
2751 std::is_arithmetic<T>::value,
int>::type = 0>
2752 T get_impl(T*)
const 2756 case value_t::number_integer:
2758 return static_cast<T
>(m_value.number_integer);
2761 case value_t::number_unsigned:
2763 return static_cast<T
>(m_value.number_unsigned);
2766 case value_t::number_float:
2768 return static_cast<T
>(m_value.number_float);
2773 Throw<std::domain_error>(
"type must be number, but is " + type_name());
2783 : Throw<std::domain_error>(
"type must be boolean, but is " + type_name()),
false;
2789 return is_object() ? m_value.object :
nullptr;
2795 return is_object() ? m_value.object :
nullptr;
2801 return is_array() ? m_value.array :
nullptr;
2805 constexpr
const array_t* get_impl_ptr(
const array_t*)
const noexcept
2807 return is_array() ? m_value.array :
nullptr;
2813 return is_string() ? m_value.string :
nullptr;
2819 return is_string() ? m_value.string :
nullptr;
2825 return is_boolean() ? &m_value.boolean :
nullptr;
2831 return is_boolean() ? &m_value.boolean :
nullptr;
2837 return is_number_integer() ? &m_value.number_integer :
nullptr;
2843 return is_number_integer() ? &m_value.number_integer :
nullptr;
2849 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
2855 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
2861 return is_number_float() ? &m_value.number_float :
nullptr;
2867 return is_number_float() ? &m_value.number_float :
nullptr;
2881 template<
typename ReferenceType,
typename ThisType>
2882 static ReferenceType get_ref_impl(ThisType&
obj)
2888 auto ptr = obj.template get_ptr<PointerType>();
2896 Throw<std::domain_error>(
"incompatible ReferenceType for get_ref, actual type is " +
2940 template<
typename ValueType,
typename std::enable_if<
2941 not std::is_pointer<ValueType>::value,
int>::type = 0>
2944 return get_impl(static_cast<ValueType*>(
nullptr));
2974 template<
typename PointerType,
typename std::enable_if<
2975 std::is_pointer<PointerType>::value,
int>::type = 0>
2976 PointerType
get() noexcept
2979 return get_ptr<PointerType>();
2986 template<
typename PointerType,
typename std::enable_if<
2987 std::is_pointer<PointerType>::value,
int>::type = 0>
2988 constexpr
const PointerType
get()
const noexcept
2991 return get_ptr<PointerType>();
3020 template<
typename PointerType,
typename std::enable_if<
3021 std::is_pointer<PointerType>::value,
int>::type = 0>
3025 using pointee_t =
typename std::remove_const<
typename 3026 std::remove_pointer<
typename 3030 std::is_same<object_t, pointee_t>::value
3031 or std::is_same<array_t, pointee_t>::value
3032 or std::is_same<string_t, pointee_t>::value
3033 or std::is_same<boolean_t, pointee_t>::value
3034 or std::is_same<number_integer_t, pointee_t>::value
3035 or std::is_same<number_unsigned_t, pointee_t>::value
3036 or std::is_same<number_float_t, pointee_t>::value
3037 ,
"incompatible pointer type");
3040 return get_impl_ptr(static_cast<PointerType>(
nullptr));
3047 template<
typename PointerType,
typename std::enable_if<
3048 std::is_pointer<PointerType>::value and
3053 using pointee_t =
typename std::remove_const<
typename 3054 std::remove_pointer<
typename 3058 std::is_same<object_t, pointee_t>::value
3059 or std::is_same<array_t, pointee_t>::value
3060 or std::is_same<string_t, pointee_t>::value
3061 or std::is_same<boolean_t, pointee_t>::value
3062 or std::is_same<number_integer_t, pointee_t>::value
3063 or std::is_same<number_unsigned_t, pointee_t>::value
3064 or std::is_same<number_float_t, pointee_t>::value
3065 ,
"incompatible pointer type");
3068 return get_impl_ptr(static_cast<const PointerType>(
nullptr));
3097 template<
typename ReferenceType,
typename std::enable_if<
3098 std::is_reference<ReferenceType>::value,
int>::type = 0>
3102 return get_ref_impl<ReferenceType>(*this);
3109 template<
typename ReferenceType,
typename std::enable_if<
3110 std::is_reference<ReferenceType>::value and
3115 return get_ref_impl<ReferenceType>(*this);
3146 template <
typename ValueType,
typename std::enable_if <
3147 not std::is_pointer<ValueType>::value and
3148 not std::is_same<ValueType, typename string_t::value_type>::value
3149 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015 3150 and
not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
3197 if (idx < m_value.array->
size())
3198 return m_value.
array->
at(idx);
3199 Throw<std::out_of_range>(
"array index " + std::to_string(idx) +
" is out of range");
3203 Throw<std::domain_error>(
"cannot use at() with " + type_name());
3234 if (idx < m_value.array->
size())
3235 return m_value.
array->
at(idx);
3236 Throw<std::out_of_range>(
"array index " + std::to_string(idx) +
" is out of range");
3240 Throw<std::domain_error>(
"cannot use at() with " + type_name());
3275 if (m_value.object->count(key) > 0)
3277 Throw<std::out_of_range>(
"key '" + key +
"' not found");
3281 Throw<std::domain_error>(
"cannot use at() with " + type_name());
3316 if (m_value.object->count(key) > 0)
3318 Throw<std::out_of_range>(
"key '" + key +
"' not found");
3322 Throw<std::domain_error>(
"cannot use at() with " + type_name());
3357 m_value.array = create<array_t>();
3365 if (idx >= m_value.array->size())
3367 m_value.array->insert(m_value.array->end(),
3368 idx - m_value.array->size() + 1,
3372 return m_value.array->operator[](idx);
3376 Throw<std::domain_error>(
"cannot use operator[] with " + type_name());
3404 return m_value.
array->operator[](idx);
3408 Throw<std::domain_error>(
"cannot use operator[] with " + type_name());
3445 m_value.object = create<object_t>();
3452 return m_value.object->operator[](
key);
3456 Throw<std::domain_error>(
"cannot use operator[] with " + type_name());
3495 assert(m_value.object->find(key) != m_value.object->end());
3500 Throw<std::domain_error>(
"cannot use operator[] with " + type_name());
3531 template<
typename T, std::
size_t n>
3534 return operator[](static_cast<const T>(
key));
3566 template<
typename T, std::
size_t n>
3569 return operator[](static_cast<const T>(
key));
3599 template<
typename T>
3613 return m_value.object->operator[](
key);
3617 Throw<std::domain_error>(
"cannot use operator[] with " + type_name());
3651 template<
typename T>
3657 assert(m_value.object->find(key) != m_value.object->end());
3662 Throw<std::domain_error>(
"cannot use operator[] with " + type_name());
3714 template<
class ValueType,
typename std::enable_if<
3715 std::is_convertible<basic_json_t, ValueType>::value,
int>::type = 0>
3722 const auto it =
find(key);
3729 return default_value;
3734 Throw<std::domain_error>(
"cannot use value() with " + type_name());
3788 template<
class ValueType,
typename std::enable_if<
3789 std::is_convertible<basic_json_t, ValueType>::value,
int>::type = 0>
3795 return ptr.get_checked(
this);
3799 Throw<std::domain_error>(
"cannot use value() with " + type_name());
3942 template<
class IteratorType,
typename std::enable_if<
3943 std::is_same<IteratorType, typename basic_json_t::iterator>::value or
3944 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int>::type
3949 if (
this != pos.m_object)
3951 Throw<std::domain_error>(
"iterator does not fit current value");
3959 case value_t::number_float:
3960 case value_t::number_integer:
3961 case value_t::number_unsigned:
3964 if (
not pos.m_it.primitive_iterator.is_begin())
3966 Throw<std::out_of_range>(
"iterator out of range");
3971 AllocatorType<string_t> alloc;
3972 alloc.destroy(m_value.string);
3973 alloc.deallocate(m_value.string, 1);
3974 m_value.string =
nullptr;
3984 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
3990 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
3996 Throw<std::domain_error>(
"cannot use erase() with " + type_name());
4049 template<
class IteratorType,
typename std::enable_if<
4050 std::is_same<IteratorType, typename basic_json_t::iterator>::value or
4051 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int>::type
4056 if (
this != first.m_object or
this != last.m_object)
4058 Throw<std::domain_error>(
"iterators do not fit current value");
4066 case value_t::number_float:
4067 case value_t::number_integer:
4068 case value_t::number_unsigned:
4071 if (
not first.m_it.primitive_iterator.is_begin() or
not last.m_it.primitive_iterator.is_end())
4073 Throw<std::out_of_range>(
"iterators out of range");
4078 AllocatorType<string_t> alloc;
4079 alloc.destroy(m_value.string);
4080 alloc.deallocate(m_value.string, 1);
4081 m_value.string =
nullptr;
4091 result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
4092 last.m_it.object_iterator);
4098 result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
4099 last.m_it.array_iterator);
4105 Throw<std::domain_error>(
"cannot use erase() with " + type_name());
4146 return m_value.object->erase(key);
4150 Throw<std::domain_error>(
"cannot use erase() with " + type_name());
4185 Throw<std::out_of_range>(
"array index " + std::to_string(idx) +
" is out of range");
4188 m_value.array->erase(m_value.array->begin() +
static_cast<difference_type>(idx));
4192 Throw<std::domain_error>(
"cannot use erase() with " + type_name());
4230 result.m_it.object_iterator = m_value.object->find(key);
4246 result.m_it.object_iterator = m_value.object->find(key);
4273 return is_object() ? m_value.object->count(key) : 0;
4561 template<
typename IteratorType>
class iteration_proxy;
4577 return iteration_proxy<iterator>(cont);
4585 return iteration_proxy<const_iterator>(cont);
4648 return m_value.array->empty();
4654 return m_value.object->empty();
4716 return m_value.array->size();
4722 return m_value.object->size();
4776 return m_value.array->max_size();
4782 return m_value.object->max_size();
4832 case value_t::number_integer:
4834 m_value.number_integer = 0;
4838 case value_t::number_unsigned:
4840 m_value.number_unsigned = 0;
4844 case value_t::number_float:
4846 m_value.number_float = 0.0;
4852 m_value.boolean =
false;
4858 m_value.string->clear();
4864 m_value.array->clear();
4870 m_value.object->clear();
4904 if (
not(is_null() or is_array()))
4906 Throw<std::domain_error>(
"cannot use push_back() with " + type_name());
4920 val.m_type = value_t::null;
4940 if (
not(is_null() or is_array()))
4942 Throw<std::domain_error>(
"cannot use push_back() with " + type_name());
4954 m_value.array->push_back(val);
4990 if (
not(is_null() or is_object()))
4992 Throw<std::domain_error>(
"cannot use push_back() with " + type_name());
5004 m_value.object->insert(val);
5044 if (is_object() and init.size() == 2 and init.begin()->is_string())
5047 push_back(
typename object_t::value_type(key, *(init.begin() + 1)));
5093 if (pos.m_object !=
this)
5095 Throw<std::domain_error>(
"iterator does not fit current value");
5100 result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
5105 Throw<std::domain_error>(
"cannot use insert() with " + type_name());
5148 if (pos.m_object !=
this)
5150 Throw<std::domain_error>(
"iterator does not fit current value");
5155 result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
5160 Throw<std::domain_error>(
"cannot use insert() with " + type_name());
5199 Throw<std::domain_error>(
"cannot use insert() with " + type_name());
5203 if (pos.m_object !=
this)
5205 Throw<std::domain_error>(
"iterator does not fit current value");
5209 if (first.m_object != last.m_object)
5211 Throw<std::domain_error>(
"iterators do not fit");
5214 if (first.m_object ==
this or last.m_object ==
this)
5216 Throw<std::domain_error>(
"passed iterators may not belong to container");
5221 result.m_it.array_iterator = m_value.array->insert(
5222 pos.m_it.array_iterator,
5223 first.m_it.array_iterator,
5224 last.m_it.array_iterator);
5257 Throw<std::domain_error>(
"cannot use insert() with " + type_name());
5261 if (pos.m_object !=
this)
5263 Throw<std::domain_error>(
"iterator does not fit current value");
5268 result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
5290 std::is_nothrow_move_constructible<value_t>::value and
5291 std::is_nothrow_move_assignable<value_t>::value and
5292 std::is_nothrow_move_constructible<json_value>::value and
5293 std::is_nothrow_move_assignable<json_value>::value
5330 Throw<std::domain_error>(
"cannot use swap() with " + type_name());
5363 Throw<std::domain_error>(
"cannot use swap() with " + type_name());
5396 Throw<std::domain_error>(
"cannot use swap() with " + type_name());
5422 static constexpr std::array<uint8_t, 8> order = {{
5435 if (lhs == value_t::discarded or rhs == value_t::discarded)
5440 return order[
static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
5469 const auto lhs_type = lhs.type();
5470 const auto rhs_type = rhs.type();
5472 if (lhs_type == rhs_type)
5478 return *lhs.m_value.array == *rhs.m_value.array;
5482 return *lhs.m_value.object == *rhs.m_value.object;
5490 return *lhs.m_value.string == *rhs.m_value.string;
5494 return lhs.m_value.boolean == rhs.m_value.boolean;
5496 case value_t::number_integer:
5498 return lhs.m_value.number_integer == rhs.m_value.number_integer;
5500 case value_t::number_unsigned:
5502 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
5504 case value_t::number_float:
5506 return lhs.m_value.number_float == rhs.m_value.number_float;
5514 else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
5516 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
5518 else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
5520 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
5522 else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
5524 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
5526 else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
5528 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
5530 else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
5532 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
5534 else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
5536 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
5592 return not (lhs == rhs);
5615 return not v.is_null();
5624 return not v.is_null();
5653 const auto lhs_type = lhs.type();
5654 const auto rhs_type = rhs.type();
5656 if (lhs_type == rhs_type)
5662 return *lhs.m_value.array < *rhs.m_value.array;
5666 return *lhs.m_value.object < *rhs.m_value.object;
5674 return *lhs.m_value.string < *rhs.m_value.string;
5678 return lhs.m_value.boolean < rhs.m_value.boolean;
5680 case value_t::number_integer:
5682 return lhs.m_value.number_integer < rhs.m_value.number_integer;
5684 case value_t::number_unsigned:
5686 return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
5688 case value_t::number_float:
5690 return lhs.m_value.number_float < rhs.m_value.number_float;
5698 else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
5700 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
5702 else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
5704 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
5706 else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
5708 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
5710 else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
5712 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
5714 else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
5716 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
5718 else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
5720 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
5748 return not (rhs < lhs);
5770 return not (lhs <= rhs);
5792 return not (lhs < rhs);
5834 const bool pretty_print = (o.width() > 0);
5835 const auto indentation = (pretty_print ? o.width() : 0);
5841 const auto old_locale = o.imbue(std::locale::classic());
5848 const auto old_precision = o.precision(std::numeric_limits<double>::digits10);
5851 j.
dump(o, pretty_print, static_cast<unsigned int>(indentation));
5854 o.imbue(old_locale);
5855 o.precision(old_precision);
5905 template<
class T, std::
size_t N>
5940 template<
typename CharPT,
typename std::enable_if<
5941 std::is_pointer<CharPT>::value and
5947 return parser(reinterpret_cast<const char*>(s),
cb).parse();
6030 template<
class IteratorType,
typename std::enable_if<
6032 std::random_access_iterator_tag,
6033 typename std::iterator_traits<IteratorType>::iterator_category>::value,
int>::type = 0>
6039 assert(std::accumulate(first, last, std::make_pair<bool, int>(
true, 0),
6040 [&first](std::pair<bool, int>
res, decltype(*first)
val)
6042 res.first &= (val == *(
std::next(std::addressof(*first), res.second++)));
6047 static_assert(
sizeof(
typename std::iterator_traits<IteratorType>::value_type) == 1,
6048 "each element in the iterator range must have the size of 1 byte");
6054 return parser(
"").parse();
6057 return parser(first, last,
cb).parse();
6100 template<
class ContiguousContainer,
typename std::enable_if<
6101 not std::is_pointer<ContiguousContainer>::value and
6103 std::random_access_iterator_tag,
6104 typename std::iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::
value 6186 case value_t::discarded:
6203 return std::accumulate(s.begin(), s.end(),
size_t{},
6204 [](
size_t res,
typename string_t::value_type
c)
6222 if (c >= 0x00 and c <= 0x1f)
6251 const auto space = extra_space(s);
6261 for (
const auto& c : s)
6323 if (c >= 0x00 and c <= 0x1f)
6327 static const char hexify[16] =
6329 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
6330 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 6335 {
'u',
'0',
'0', hexify[c >> 4], hexify[c & 0x0f]
6373 void dump(std::ostream& o,
6374 const bool pretty_print,
6375 const unsigned int indent_step,
6376 const unsigned int current_indent = 0)
const 6379 unsigned int new_indent = current_indent;
6385 if (m_value.object->empty())
6396 new_indent += indent_step;
6400 for (
auto i = m_value.object->cbegin();
i != m_value.object->cend(); ++
i)
6402 if (
i != m_value.object->cbegin())
6404 o << (pretty_print ?
",\n" :
",");
6406 o <<
string_t(new_indent,
' ') <<
"\"" 6407 << escape_string(
i->first) <<
"\":" 6408 << (pretty_print ?
" " :
"");
6409 i->second.dump(o, pretty_print, indent_step, new_indent);
6415 new_indent -= indent_step;
6419 o <<
string_t(new_indent,
' ') +
"}";
6425 if (m_value.array->empty())
6436 new_indent += indent_step;
6440 for (
auto i = m_value.array->cbegin();
i != m_value.array->cend(); ++
i)
6442 if (
i != m_value.array->cbegin())
6444 o << (pretty_print ?
",\n" :
",");
6447 i->dump(o, pretty_print, indent_step, new_indent);
6453 new_indent -= indent_step;
6457 o <<
string_t(new_indent,
' ') <<
"]";
6463 o <<
string_t(
"\"") << escape_string(*m_value.string) <<
"\"";
6469 o << (m_value.boolean ?
"true" :
"false");
6473 case value_t::number_integer:
6475 o << m_value.number_integer;
6479 case value_t::number_unsigned:
6481 o << m_value.number_unsigned;
6485 case value_t::number_float:
6487 if (m_value.number_float == 0)
6490 o << (std::signbit(m_value.number_float) ?
"-0.0" :
"0.0");
6494 o << m_value.number_float;
6499 case value_t::discarded:
6522 json_value m_value = {};
6539 class primitive_iterator_t
6543 void set_begin() noexcept
6549 void set_end() noexcept
6555 constexpr
bool is_begin()
const noexcept
6557 return (m_it == begin_value);
6561 constexpr
bool is_end()
const noexcept
6563 return (m_it == end_value);
6583 difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
6593 struct internal_iterator
6596 typename object_t::iterator object_iterator;
6598 typename array_t::iterator array_iterator;
6600 primitive_iterator_t primitive_iterator;
6603 internal_iterator() noexcept
6604 : object_iterator(), array_iterator(), primitive_iterator()
6609 template<
typename IteratorType>
6610 class iteration_proxy
6614 class iteration_proxy_internal
6618 IteratorType anchor;
6620 size_t array_index = 0;
6623 explicit iteration_proxy_internal(IteratorType it) noexcept
6643 bool operator!= (
const iteration_proxy_internal& o)
const 6645 return anchor != o.anchor;
6651 assert(anchor.m_object !=
nullptr);
6653 switch (anchor.m_object->type())
6658 return std::to_string(array_index);
6664 return anchor.key();
6678 return anchor.value();
6692 iteration_proxy_internal begin() noexcept
6694 return iteration_proxy_internal(container.begin());
6698 iteration_proxy_internal
end() noexcept
6700 return iteration_proxy_internal(container.end());
6724 class const_iterator :
public std::iterator<std::random_access_iterator_tag, const basic_json>
6753 assert(m_object !=
nullptr);
6755 switch (m_object->m_type)
6759 m_it.object_iterator =
typename object_t::iterator();
6765 m_it.array_iterator =
typename array_t::iterator();
6771 m_it.primitive_iterator = primitive_iterator_t();
6783 : m_object(other.m_object)
6785 if (m_object !=
nullptr)
6787 switch (m_object->m_type)
6791 m_it.object_iterator = other.m_it.object_iterator;
6797 m_it.array_iterator = other.m_it.array_iterator;
6803 m_it.primitive_iterator = other.m_it.primitive_iterator;
6816 : m_object(other.m_object), m_it(other.m_it)
6825 std::is_nothrow_move_constructible<pointer>::value and
6826 std::is_nothrow_move_assignable<pointer>::value and
6827 std::is_nothrow_move_constructible<internal_iterator>::value and
6828 std::is_nothrow_move_assignable<internal_iterator>::value
6841 void set_begin() noexcept
6843 assert(m_object !=
nullptr);
6845 switch (m_object->m_type)
6849 m_it.object_iterator = m_object->m_value.object->begin();
6855 m_it.array_iterator = m_object->m_value.array->begin();
6862 m_it.primitive_iterator.set_end();
6868 m_it.primitive_iterator.set_begin();
6878 void set_end() noexcept
6880 assert(m_object !=
nullptr);
6882 switch (m_object->m_type)
6886 m_it.object_iterator = m_object->m_value.object->end();
6892 m_it.array_iterator = m_object->m_value.array->end();
6898 m_it.primitive_iterator.set_end();
6911 assert(m_object !=
nullptr);
6913 switch (m_object->m_type)
6917 assert(m_it.object_iterator != m_object->m_value.object->end());
6918 return m_it.object_iterator->second;
6923 assert(m_it.array_iterator != m_object->m_value.array->end());
6924 return *m_it.array_iterator;
6929 Throw<std::out_of_range>(
"cannot get value");
6934 if (m_it.primitive_iterator.is_begin())
6940 Throw<std::out_of_range>(
"cannot get value");
6952 assert(m_object !=
nullptr);
6954 switch (m_object->m_type)
6958 assert(m_it.object_iterator != m_object->m_value.object->end());
6959 return &(m_it.object_iterator->second);
6964 assert(m_it.array_iterator != m_object->m_value.array->end());
6965 return &*m_it.array_iterator;
6970 if (m_it.primitive_iterator.is_begin())
6976 Throw<std::out_of_range>(
"cannot get value");
6999 assert(m_object !=
nullptr);
7001 switch (m_object->m_type)
7017 ++m_it.primitive_iterator;
7042 assert(m_object !=
nullptr);
7044 switch (m_object->m_type)
7060 --m_it.primitive_iterator;
7075 if (m_object != other.m_object)
7077 Throw<std::domain_error>(
"cannot compare iterators of different containers");
7080 assert(m_object !=
nullptr);
7082 switch (m_object->m_type)
7086 return (m_it.object_iterator == other.m_it.object_iterator);
7091 return (m_it.array_iterator == other.m_it.array_iterator);
7096 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
7117 if (m_object != other.m_object)
7119 Throw<std::domain_error>(
"cannot compare iterators of different containers");
7122 assert(m_object !=
nullptr);
7124 switch (m_object->m_type)
7128 Throw<std::domain_error>(
"cannot compare order of object iterators");
7133 return (m_it.array_iterator < other.m_it.array_iterator);
7138 return (m_it.primitive_iterator < other.m_it.primitive_iterator);
7149 return not other.operator < (*this);
7176 assert(m_object !=
nullptr);
7178 switch (m_object->m_type)
7182 Throw<std::domain_error>(
"cannot use offsets with object iterators");
7193 m_it.primitive_iterator +=
i;
7238 assert(m_object !=
nullptr);
7240 switch (m_object->m_type)
7244 Throw<std::domain_error>(
"cannot use offsets with object iterators");
7249 return m_it.array_iterator - other.m_it.array_iterator;
7254 return m_it.primitive_iterator - other.m_it.primitive_iterator;
7265 assert(m_object !=
nullptr);
7267 switch (m_object->m_type)
7271 Throw<std::domain_error>(
"cannot use operator[] for object iterators");
7276 return *
std::next(m_it.array_iterator, n);
7281 Throw<std::out_of_range>(
"cannot get value");
7286 if (m_it.primitive_iterator == -n)
7292 Throw<std::out_of_range>(
"cannot get value");
7304 assert(m_object !=
nullptr);
7306 if (m_object->is_object())
7308 return m_it.object_iterator->first;
7312 Throw<std::domain_error>(
"cannot use key() for non-object iterators");
7329 internal_iterator m_it = internal_iterator();
7366 std::is_nothrow_move_constructible<pointer>::value and
7367 std::is_nothrow_move_assignable<pointer>::value and
7368 std::is_nothrow_move_constructible<internal_iterator>::value and
7369 std::is_nothrow_move_assignable<internal_iterator>::value
7372 base_iterator::operator=(other);
7385 return const_cast<pointer>(base_iterator::operator->());
7451 return base_iterator::operator-(other);
7457 return const_cast<reference>(base_iterator::operator[](n));
7463 return const_cast<reference>(base_iterator::value());
7484 template<
typename Base>
7555 return this->
base() - other.base();
7561 return *(this->operator+(n));
7567 auto it = --this->
base();
7574 auto it = --this->
base();
7575 return it.operator * ();
7596 enum class token_type
7615 using lexer_char_t =
unsigned char;
7618 lexer(
const lexer_char_t* buff,
const size_t len) noexcept
7621 assert(m_content !=
nullptr);
7622 m_start = m_cursor = m_content;
7623 m_limit = m_content +
len;
7627 explicit lexer(std::istream& s)
7628 : m_stream(&s), m_line_buffer()
7633 Throw<std::invalid_argument>(
"stream error: " +
std::string(strerror(errno)));
7640 if (m_line_buffer.size() >= 3 and m_line_buffer.substr(0, 3) ==
"\xEF\xBB\xBF")
7642 m_line_buffer[0] =
' ';
7643 m_line_buffer[1] =
' ';
7644 m_line_buffer[2] =
' ';
7650 lexer(
const lexer&) =
delete;
7651 lexer operator=(
const lexer&) =
delete;
7683 if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
7686 if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
7700 Throw<std::invalid_argument>(
"missing or wrong low surrogate");
7706 if (codepoint < 0x80)
7709 result.append(1, static_cast<typename string_t::value_type>(codepoint));
7711 else if (codepoint <= 0x7ff)
7714 result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
7715 result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
7717 else if (codepoint <= 0xffff)
7720 result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
7721 result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
7722 result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
7724 else if (codepoint <= 0x10ffff)
7727 result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
7728 result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
7729 result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
7730 result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
7734 Throw<std::out_of_range>(
"code points above 0x10FFFF are invalid");
7745 case token_type::uninitialized:
7746 return "<uninitialized>";
7747 case token_type::literal_true:
7748 return "true literal";
7749 case token_type::literal_false:
7750 return "false literal";
7751 case token_type::literal_null:
7752 return "null literal";
7753 case token_type::value_string:
7754 return "string literal";
7755 case token_type::value_number:
7756 return "number literal";
7757 case token_type::begin_array:
7759 case token_type::begin_object:
7761 case token_type::end_array:
7763 case token_type::end_object:
7765 case token_type::name_separator:
7767 case token_type::value_separator:
7769 case token_type::parse_error:
7770 return "<parse error>";
7771 case token_type::end_of_input:
7772 return "end of input";
7776 return "unknown token";
7811 assert(m_start !=
nullptr);
7816 unsigned int yyaccept = 0;
7817 static const unsigned char yybm[] =
7819 0, 0, 0, 0, 0, 0, 0, 0,
7820 0, 32, 32, 0, 0, 32, 0, 0,
7821 0, 0, 0, 0, 0, 0, 0, 0,
7822 0, 0, 0, 0, 0, 0, 0, 0,
7823 160, 128, 0, 128, 128, 128, 128, 128,
7824 128, 128, 128, 128, 128, 128, 128, 128,
7825 192, 192, 192, 192, 192, 192, 192, 192,
7826 192, 192, 128, 128, 128, 128, 128, 128,
7827 128, 128, 128, 128, 128, 128, 128, 128,
7828 128, 128, 128, 128, 128, 128, 128, 128,
7829 128, 128, 128, 128, 128, 128, 128, 128,
7830 128, 128, 128, 128, 0, 128, 128, 128,
7831 128, 128, 128, 128, 128, 128, 128, 128,
7832 128, 128, 128, 128, 128, 128, 128, 128,
7833 128, 128, 128, 128, 128, 128, 128, 128,
7834 128, 128, 128, 128, 128, 128, 128, 128,
7835 0, 0, 0, 0, 0, 0, 0, 0,
7836 0, 0, 0, 0, 0, 0, 0, 0,
7837 0, 0, 0, 0, 0, 0, 0, 0,
7838 0, 0, 0, 0, 0, 0, 0, 0,
7839 0, 0, 0, 0, 0, 0, 0, 0,
7840 0, 0, 0, 0, 0, 0, 0, 0,
7841 0, 0, 0, 0, 0, 0, 0, 0,
7842 0, 0, 0, 0, 0, 0, 0, 0,
7843 0, 0, 0, 0, 0, 0, 0, 0,
7844 0, 0, 0, 0, 0, 0, 0, 0,
7845 0, 0, 0, 0, 0, 0, 0, 0,
7846 0, 0, 0, 0, 0, 0, 0, 0,
7847 0, 0, 0, 0, 0, 0, 0, 0,
7848 0, 0, 0, 0, 0, 0, 0, 0,
7849 0, 0, 0, 0, 0, 0, 0, 0,
7850 0, 0, 0, 0, 0, 0, 0, 0,
7852 if ((m_limit - m_cursor) < 5)
7854 fill_line_buffer(5);
7857 if (yybm[0 + yych] & 32)
7859 goto basic_json_parser_6;
7869 goto basic_json_parser_2;
7873 goto basic_json_parser_4;
7875 goto basic_json_parser_9;
7881 goto basic_json_parser_4;
7885 goto basic_json_parser_10;
7887 goto basic_json_parser_12;
7896 goto basic_json_parser_4;
7900 goto basic_json_parser_13;
7902 goto basic_json_parser_15;
7908 goto basic_json_parser_17;
7912 goto basic_json_parser_4;
7914 goto basic_json_parser_19;
7926 goto basic_json_parser_21;
7928 goto basic_json_parser_4;
7934 goto basic_json_parser_23;
7938 goto basic_json_parser_4;
7940 goto basic_json_parser_24;
7949 goto basic_json_parser_25;
7951 goto basic_json_parser_4;
7957 goto basic_json_parser_26;
7961 goto basic_json_parser_28;
7963 goto basic_json_parser_4;
7967 basic_json_parser_2:
7970 last_token_type = token_type::end_of_input;
7973 basic_json_parser_4:
7975 basic_json_parser_5:
7977 last_token_type = token_type::parse_error;
7980 basic_json_parser_6:
7982 if (m_limit <= m_cursor)
7984 fill_line_buffer(1);
7987 if (yybm[0 + yych] & 32)
7989 goto basic_json_parser_6;
7994 basic_json_parser_9:
7996 yych = *(m_marker = ++m_cursor);
7999 goto basic_json_parser_5;
8003 goto basic_json_parser_31;
8007 goto basic_json_parser_5;
8011 goto basic_json_parser_31;
8013 goto basic_json_parser_5;
8014 basic_json_parser_10:
8017 last_token_type = token_type::value_separator;
8020 basic_json_parser_12:
8024 goto basic_json_parser_5;
8028 goto basic_json_parser_13;
8032 goto basic_json_parser_15;
8034 goto basic_json_parser_5;
8035 basic_json_parser_13:
8037 yych = *(m_marker = ++m_cursor);
8042 goto basic_json_parser_43;
8049 goto basic_json_parser_44;
8053 goto basic_json_parser_44;
8056 basic_json_parser_14:
8058 last_token_type = token_type::value_number;
8061 basic_json_parser_15:
8063 m_marker = ++m_cursor;
8064 if ((m_limit - m_cursor) < 3)
8066 fill_line_buffer(3);
8069 if (yybm[0 + yych] & 64)
8071 goto basic_json_parser_15;
8077 goto basic_json_parser_43;
8079 goto basic_json_parser_14;
8085 goto basic_json_parser_44;
8089 goto basic_json_parser_44;
8091 goto basic_json_parser_14;
8093 basic_json_parser_17:
8096 last_token_type = token_type::name_separator;
8099 basic_json_parser_19:
8102 last_token_type = token_type::begin_array;
8105 basic_json_parser_21:
8108 last_token_type = token_type::end_array;
8111 basic_json_parser_23:
8113 yych = *(m_marker = ++m_cursor);
8116 goto basic_json_parser_45;
8118 goto basic_json_parser_5;
8119 basic_json_parser_24:
8121 yych = *(m_marker = ++m_cursor);
8124 goto basic_json_parser_46;
8126 goto basic_json_parser_5;
8127 basic_json_parser_25:
8129 yych = *(m_marker = ++m_cursor);
8132 goto basic_json_parser_47;
8134 goto basic_json_parser_5;
8135 basic_json_parser_26:
8138 last_token_type = token_type::begin_object;
8141 basic_json_parser_28:
8144 last_token_type = token_type::end_object;
8147 basic_json_parser_30:
8149 if (m_limit <= m_cursor)
8151 fill_line_buffer(1);
8154 basic_json_parser_31:
8155 if (yybm[0 + yych] & 128)
8157 goto basic_json_parser_30;
8165 goto basic_json_parser_32;
8169 goto basic_json_parser_33;
8171 goto basic_json_parser_35;
8177 goto basic_json_parser_32;
8181 goto basic_json_parser_36;
8183 goto basic_json_parser_37;
8192 goto basic_json_parser_39;
8194 goto basic_json_parser_38;
8200 goto basic_json_parser_40;
8204 goto basic_json_parser_41;
8208 goto basic_json_parser_42;
8212 basic_json_parser_32:
8213 m_cursor = m_marker;
8216 goto basic_json_parser_5;
8220 goto basic_json_parser_14;
8222 basic_json_parser_33:
8225 last_token_type = token_type::value_string;
8228 basic_json_parser_35:
8230 if (m_limit <= m_cursor)
8232 fill_line_buffer(1);
8241 goto basic_json_parser_30;
8245 goto basic_json_parser_32;
8247 goto basic_json_parser_30;
8255 goto basic_json_parser_32;
8257 goto basic_json_parser_30;
8263 goto basic_json_parser_30;
8265 goto basic_json_parser_32;
8275 goto basic_json_parser_30;
8279 goto basic_json_parser_30;
8281 goto basic_json_parser_32;
8289 goto basic_json_parser_30;
8291 goto basic_json_parser_32;
8297 goto basic_json_parser_30;
8301 goto basic_json_parser_48;
8303 goto basic_json_parser_32;
8307 basic_json_parser_36:
8309 if (m_limit <= m_cursor)
8311 fill_line_buffer(1);
8316 goto basic_json_parser_32;
8320 goto basic_json_parser_30;
8322 goto basic_json_parser_32;
8323 basic_json_parser_37:
8325 if (m_limit <= m_cursor)
8327 fill_line_buffer(1);
8332 goto basic_json_parser_32;
8336 goto basic_json_parser_36;
8338 goto basic_json_parser_32;
8339 basic_json_parser_38:
8341 if (m_limit <= m_cursor)
8343 fill_line_buffer(1);
8348 goto basic_json_parser_32;
8352 goto basic_json_parser_36;
8354 goto basic_json_parser_32;
8355 basic_json_parser_39:
8357 if (m_limit <= m_cursor)
8359 fill_line_buffer(1);
8364 goto basic_json_parser_32;
8368 goto basic_json_parser_36;
8370 goto basic_json_parser_32;
8371 basic_json_parser_40:
8373 if (m_limit <= m_cursor)
8375 fill_line_buffer(1);
8380 goto basic_json_parser_32;
8384 goto basic_json_parser_38;
8386 goto basic_json_parser_32;
8387 basic_json_parser_41:
8389 if (m_limit <= m_cursor)
8391 fill_line_buffer(1);
8396 goto basic_json_parser_32;
8400 goto basic_json_parser_38;
8402 goto basic_json_parser_32;
8403 basic_json_parser_42:
8405 if (m_limit <= m_cursor)
8407 fill_line_buffer(1);
8412 goto basic_json_parser_32;
8416 goto basic_json_parser_38;
8418 goto basic_json_parser_32;
8419 basic_json_parser_43:
8423 goto basic_json_parser_32;
8427 goto basic_json_parser_49;
8429 goto basic_json_parser_32;
8430 basic_json_parser_44:
8436 goto basic_json_parser_51;
8438 goto basic_json_parser_32;
8444 goto basic_json_parser_51;
8448 goto basic_json_parser_32;
8452 goto basic_json_parser_52;
8454 goto basic_json_parser_32;
8456 basic_json_parser_45:
8460 goto basic_json_parser_54;
8462 goto basic_json_parser_32;
8463 basic_json_parser_46:
8467 goto basic_json_parser_55;
8469 goto basic_json_parser_32;
8470 basic_json_parser_47:
8474 goto basic_json_parser_56;
8476 goto basic_json_parser_32;
8477 basic_json_parser_48:
8479 if (m_limit <= m_cursor)
8481 fill_line_buffer(1);
8488 goto basic_json_parser_32;
8492 goto basic_json_parser_57;
8494 goto basic_json_parser_32;
8500 goto basic_json_parser_57;
8504 goto basic_json_parser_32;
8508 goto basic_json_parser_57;
8510 goto basic_json_parser_32;
8512 basic_json_parser_49:
8514 m_marker = ++m_cursor;
8515 if ((m_limit - m_cursor) < 3)
8517 fill_line_buffer(3);
8524 goto basic_json_parser_14;
8528 goto basic_json_parser_49;
8530 goto basic_json_parser_14;
8536 goto basic_json_parser_44;
8540 goto basic_json_parser_44;
8542 goto basic_json_parser_14;
8544 basic_json_parser_51:
8548 goto basic_json_parser_32;
8552 goto basic_json_parser_32;
8554 basic_json_parser_52:
8556 if (m_limit <= m_cursor)
8558 fill_line_buffer(1);
8563 goto basic_json_parser_14;
8567 goto basic_json_parser_52;
8569 goto basic_json_parser_14;
8570 basic_json_parser_54:
8574 goto basic_json_parser_58;
8576 goto basic_json_parser_32;
8577 basic_json_parser_55:
8581 goto basic_json_parser_59;
8583 goto basic_json_parser_32;
8584 basic_json_parser_56:
8588 goto basic_json_parser_61;
8590 goto basic_json_parser_32;
8591 basic_json_parser_57:
8593 if (m_limit <= m_cursor)
8595 fill_line_buffer(1);
8602 goto basic_json_parser_32;
8606 goto basic_json_parser_63;
8608 goto basic_json_parser_32;
8614 goto basic_json_parser_63;
8618 goto basic_json_parser_32;
8622 goto basic_json_parser_63;
8624 goto basic_json_parser_32;
8626 basic_json_parser_58:
8630 goto basic_json_parser_64;
8632 goto basic_json_parser_32;
8633 basic_json_parser_59:
8636 last_token_type = token_type::literal_null;
8639 basic_json_parser_61:
8642 last_token_type = token_type::literal_true;
8645 basic_json_parser_63:
8647 if (m_limit <= m_cursor)
8649 fill_line_buffer(1);
8656 goto basic_json_parser_32;
8660 goto basic_json_parser_66;
8662 goto basic_json_parser_32;
8668 goto basic_json_parser_66;
8672 goto basic_json_parser_32;
8676 goto basic_json_parser_66;
8678 goto basic_json_parser_32;
8680 basic_json_parser_64:
8683 last_token_type = token_type::literal_false;
8686 basic_json_parser_66:
8688 if (m_limit <= m_cursor)
8690 fill_line_buffer(1);
8697 goto basic_json_parser_32;
8701 goto basic_json_parser_30;
8703 goto basic_json_parser_32;
8709 goto basic_json_parser_30;
8713 goto basic_json_parser_32;
8717 goto basic_json_parser_30;
8719 goto basic_json_parser_32;
8725 return last_token_type;
8756 void fill_line_buffer(
size_t n = 0)
8759 assert(m_line_buffer.empty()
8760 or m_content ==
reinterpret_cast<const lexer_char_t*
>(m_line_buffer.data()));
8763 assert(m_line_buffer.empty()
8764 or m_limit == m_content + m_line_buffer.size());
8767 assert(m_content <= m_start);
8768 assert(m_start <= m_cursor);
8769 assert(m_cursor <= m_limit);
8770 assert(m_marker ==
nullptr or m_marker <= m_limit);
8773 const size_t num_processed_chars =
static_cast<size_t>(m_start - m_content);
8775 const auto offset_marker = (m_marker ==
nullptr) ? 0 : m_marker - m_start;
8777 const auto offset_cursor = m_cursor - m_start;
8780 if (m_stream ==
nullptr or m_stream->eof())
8785 m_line_buffer.assign(m_start, m_limit);
8789 m_line_buffer.append(1,
'\x00');
8792 m_line_buffer.append(
n - 1,
'\x01');
8798 m_line_buffer.erase(0, num_processed_chars);
8800 m_line_buffer_tmp.clear();
8801 std::getline(*m_stream, m_line_buffer_tmp,
'\n');
8804 m_line_buffer += m_line_buffer_tmp;
8805 m_line_buffer.push_back(
'\n');
8809 m_content =
reinterpret_cast<const lexer_char_t*
>(m_line_buffer.data());
8810 assert(m_content !=
nullptr);
8811 m_start = m_content;
8812 m_marker = m_start + offset_marker;
8813 m_cursor = m_start + offset_cursor;
8814 m_limit = m_start + m_line_buffer.size();
8820 assert(m_start !=
nullptr);
8821 return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
8822 static_cast<size_t>(m_cursor - m_start));
8884 assert(m_cursor - m_start >= 2);
8887 result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
8890 for (
const lexer_char_t*
i = m_start + 1;
i < m_cursor - 1; ++
i)
8897 for (
auto k =
i;
k <
e;
k++)
8899 result.push_back(static_cast<typename string_t::value_type>(*
k));
8957 auto codepoint = std::strtoul(
std::string(reinterpret_cast<typename string_t::const_pointer>(
i + 1),
8958 4).c_str(),
nullptr, 16);
8961 if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
8964 if ((
i + 6 >= m_limit) or * (
i + 5) !=
'\\' or * (
i + 6) !=
'u')
8966 Throw<std::invalid_argument>(
"missing low surrogate");
8970 auto codepoint2 = std::strtoul(
std::string(reinterpret_cast<typename string_t::const_pointer>
8971 (
i + 7), 4).c_str(),
nullptr, 16);
8972 result += to_unicode(codepoint, codepoint2);
8976 else if (codepoint >= 0xDC00 and codepoint <= 0xDFFF)
8979 Throw<std::invalid_argument>(
"missing high surrogate");
8984 result += to_unicode(codepoint);
9012 long double str_to_float_t(
long double* ,
char** endptr)
const 9014 return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
9032 double str_to_float_t(
double* ,
char** endptr)
const 9034 return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
9052 float str_to_float_t(
float* ,
char** endptr)
const 9054 return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
9080 assert(m_start !=
nullptr);
9082 const lexer::lexer_char_t* curptr = m_start;
9096 type = value_t::number_integer;
9102 type = value_t::number_unsigned;
9107 for (; curptr < m_cursor; curptr++)
9110 if (*curptr < '0' || *curptr >
'9')
9115 type = value_t::number_float;
9120 type = value_t::number_float;
9125 if (type != value_t::number_float)
9128 auto temp = value * 10 + *curptr -
'0';
9131 if (temp < value || temp > max)
9134 type = value_t::number_float;
9145 if (type == value_t::number_unsigned)
9147 result.m_value.number_unsigned = value;
9149 else if (type == value_t::number_integer)
9156 result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(
nullptr),
NULL);
9161 type = value_t::null;
9162 result.m_value = basic_json::json_value();
9167 result.m_type =
type;
9172 std::istream* m_stream =
nullptr;
9178 const lexer_char_t* m_content =
nullptr;
9180 const lexer_char_t* m_start =
nullptr;
9182 const lexer_char_t* m_marker =
nullptr;
9184 const lexer_char_t* m_cursor =
nullptr;
9186 const lexer_char_t* m_limit =
nullptr;
9188 token_type last_token_type = token_type::end_of_input;
9202 m_lexer(reinterpret_cast<const typename lexer::lexer_char_t*>(buff), std::strlen(buff))
9211 template<
class IteratorType,
typename std::enable_if<
9212 std::is_same<typename std::iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value
9217 m_lexer(reinterpret_cast<const typename lexer::lexer_char_t*>(&(*first)),
9228 result.assert_invariant();
9230 expect(lexer::token_type::end_of_input);
9245 case lexer::token_type::begin_object:
9259 if (last_token == lexer::token_type::end_object)
9270 unexpect(lexer::token_type::value_separator);
9276 if (last_token == lexer::token_type::value_separator)
9282 expect(lexer::token_type::value_string);
9283 const auto key = m_lexer.get_string();
9285 bool keep_tag =
false;
9301 expect(lexer::token_type::name_separator);
9305 auto value = parse_internal(keep);
9306 if (keep and keep_tag and
not value.is_discarded())
9311 while (last_token == lexer::token_type::value_separator);
9314 expect(lexer::token_type::end_object);
9324 case lexer::token_type::begin_array:
9338 if (last_token == lexer::token_type::end_array)
9349 unexpect(lexer::token_type::value_separator);
9355 if (last_token == lexer::token_type::value_separator)
9361 auto value = parse_internal(keep);
9362 if (keep and
not value.is_discarded())
9367 while (last_token == lexer::token_type::value_separator);
9370 expect(lexer::token_type::end_array);
9380 case lexer::token_type::literal_null:
9383 result.m_type = value_t::null;
9387 case lexer::token_type::value_string:
9389 const auto s = m_lexer.get_string();
9395 case lexer::token_type::literal_true:
9403 case lexer::token_type::literal_false:
9411 case lexer::token_type::value_number:
9413 m_lexer.get_number(
result);
9421 unexpect(last_token);
9433 typename lexer::token_type get_token()
9435 last_token = m_lexer.scan();
9439 void expect(
typename lexer::token_type
t)
const 9441 if (t != last_token)
9443 std::string error_msg =
"parse error - unexpected ";
9444 error_msg += (last_token == lexer::token_type::parse_error ? (
"'" + m_lexer.get_token_string() +
9446 lexer::token_type_name(last_token));
9447 error_msg +=
"; expected " + lexer::token_type_name(t);
9448 Throw<std::invalid_argument>(error_msg);
9452 void unexpect(
typename lexer::token_type t)
const 9454 if (t == last_token)
9456 std::string error_msg =
"parse error - unexpected ";
9457 error_msg += (last_token == lexer::token_type::parse_error ? (
"'" + m_lexer.get_token_string() +
9459 lexer::token_type_name(last_token));
9460 Throw<std::invalid_argument>(error_msg);
9470 typename lexer::token_type last_token = lexer::token_type::uninitialized;
9516 : reference_tokens(
split(s))
9536 return std::accumulate(reference_tokens.begin(),
9556 Throw<std::domain_error>(
"JSON pointer has no parent");
9559 auto last = reference_tokens.back();
9560 reference_tokens.pop_back();
9565 bool is_root()
const 9567 return reference_tokens.empty();
9574 Throw<std::domain_error>(
"JSON pointer has no parent");
9578 result.reference_tokens = {reference_tokens[0]};
9593 for (
const auto& reference_token : reference_tokens)
9595 switch (result->m_type)
9599 if (reference_token ==
"0")
9602 result = &result->operator[](0);
9607 result = &result->operator[](reference_token);
9615 result = &result->operator[](reference_token);
9622 result = &result->operator[](
static_cast<size_type>(std::stoi(reference_token)));
9635 Throw<std::domain_error>(
"invalid value to unflatten");
9664 for (
const auto& reference_token : reference_tokens)
9667 if (ptr->m_type == value_t::null)
9670 const bool nums = std::all_of(reference_token.begin(),
9671 reference_token.end(),
9674 return std::isdigit(
x);
9679 if (nums or reference_token ==
"-")
9689 switch (ptr->m_type)
9694 ptr = &ptr->operator[](reference_token);
9701 if (reference_token.size() > 1 and reference_token[0] ==
'0')
9703 Throw<std::domain_error>(
"array index must not begin with '0'");
9706 if (reference_token ==
"-")
9709 ptr = &ptr->operator[](ptr->m_value.array->size());
9714 ptr = &ptr->operator[](
static_cast<size_type>(std::stoi(reference_token)));
9721 Throw<std::out_of_range>(
"unresolved reference token '" + reference_token +
"'");
9731 for (
const auto& reference_token : reference_tokens)
9733 switch (ptr->m_type)
9738 ptr = &ptr->at(reference_token);
9744 if (reference_token ==
"-")
9747 Throw<std::out_of_range>(
"array index '-' (" +
9748 std::to_string(ptr->m_value.array->size()) +
9749 ") is out of range");
9753 if (reference_token.size() > 1 and reference_token[0] ==
'0')
9755 Throw<std::domain_error>(
"array index must not begin with '0'");
9759 ptr = &ptr->at(static_cast<size_type>(std::stoi(reference_token)));
9765 Throw<std::out_of_range>(
"unresolved reference token '" + reference_token +
"'");
9783 for (
const auto& reference_token : reference_tokens)
9785 switch (ptr->m_type)
9790 ptr = &ptr->operator[](reference_token);
9796 if (reference_token ==
"-")
9799 Throw<std::out_of_range>(
"array index '-' (" +
9800 std::to_string(ptr->m_value.array->size()) +
9801 ") is out of range");
9805 if (reference_token.size() > 1 and reference_token[0] ==
'0')
9807 Throw<std::domain_error>(
"array index must not begin with '0'");
9811 ptr = &ptr->operator[](
static_cast<size_type>(std::stoi(reference_token)));
9817 Throw<std::out_of_range>(
"unresolved reference token '" + reference_token +
"'");
9827 for (
const auto& reference_token : reference_tokens)
9829 switch (ptr->m_type)
9834 ptr = &ptr->at(reference_token);
9840 if (reference_token ==
"-")
9843 Throw<std::out_of_range>(
"array index '-' (" +
9844 std::to_string(ptr->m_value.array->size()) +
9845 ") is out of range");
9849 if (reference_token.size() > 1 and reference_token[0] ==
'0')
9851 Throw<std::domain_error>(
"array index must not begin with '0'");
9855 ptr = &ptr->at(static_cast<size_type>(std::stoi(reference_token)));
9861 Throw<std::out_of_range>(
"unresolved reference token '" + reference_token +
"'");
9872 std::vector<std::string>
result;
9875 if (reference_string.empty())
9881 if (reference_string[0] !=
'/')
9883 Throw<std::domain_error>(
"JSON pointer must be empty or begin with '/'");
9891 size_t slash = reference_string.find_first_of(
"/", 1),
9900 slash = reference_string.find_first_of(
"/",
start))
9904 auto reference_token = reference_string.substr(
start, slash -
start);
9907 for (
size_t pos = reference_token.find_first_of(
"~");
9908 pos != std::string::npos;
9909 pos = reference_token.find_first_of(
"~", pos + 1))
9911 assert(reference_token[pos] ==
'~');
9914 if (pos == reference_token.size() - 1 or
9915 (reference_token[pos + 1] !=
'0' and
9916 reference_token[pos + 1] !=
'1'))
9918 Throw<std::domain_error>(
"escape error: '~' must be followed with '0' or '1'");
9924 result.push_back(reference_token);
9949 assert(
not f.empty());
9952 size_t pos = s.find(f);
9953 pos != std::string::npos;
9954 s.replace(pos, f.size(),
t),
9955 pos = s.find(f, pos + t.size())
9963 replace_substring(s,
"~",
"~0");
9964 replace_substring(s,
"/",
"~1");
9972 replace_substring(s,
"~1",
"/");
9974 replace_substring(s,
"~0",
"~");
9988 switch (value.m_type)
9992 if (value.m_value.array->empty())
9995 result[reference_string] =
nullptr;
10000 for (
size_t i = 0;
i < value.m_value.array->size(); ++
i)
10002 flatten(reference_string +
"/" + std::to_string(
i),
10003 value.m_value.array->operator[](
i), result);
10011 if (value.m_value.object->empty())
10014 result[reference_string] =
nullptr;
10019 for (
const auto&
element : *value.m_value.object)
10031 result[reference_string] = value;
10046 Throw<std::domain_error>(
"only objects can be unflattened");
10052 for (
const auto&
element : *value.m_value.object)
10056 Throw<std::domain_error>(
"values in object must be primitive");
10072 std::vector<std::string> reference_tokens {};
10117 return ptr.get_unchecked(
this);
10144 return ptr.get_unchecked(
this);
10169 return ptr.get_checked(
this);
10194 return ptr.get_checked(
this);
10255 return json_pointer::unflatten(*
this);
10315 return patch_operations::add;
10317 if (op ==
"remove")
10321 if (op ==
"replace")
10353 if (top_pointer != ptr)
10355 result.
at(top_pointer);
10359 const auto last_path = ptr.pop_back();
10362 switch (parent.m_type)
10364 case value_t::null:
10368 parent[last_path] =
val;
10374 if (last_path ==
"-")
10381 const auto idx = std::stoi(last_path);
10382 if (static_cast<size_type>(idx) > parent.
size())
10385 Throw<std::out_of_range>(
"array index " + std::to_string(idx) +
" is out of range");
10409 const auto last_path = ptr.pop_back();
10416 auto it = parent.
find(last_path);
10417 if (it != parent.
end())
10423 Throw<std::out_of_range>(
"key '" + last_path +
"' not found");
10429 parent.
erase(static_cast<size_type>(std::stoi(last_path)));
10437 Throw<std::invalid_argument>(
"JSON patch must be an array of objects");
10441 for (
const auto&
val : json_patch)
10449 auto it =
val.m_value.object->find(member);
10452 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
10455 if (it ==
val.m_value.object->end())
10457 Throw<std::invalid_argument>(error_msg +
" must have member '" + member +
"'");
10461 if (string_type and
not it->second.is_string())
10463 Throw<std::invalid_argument>(error_msg +
" must have string member '" + member +
"'");
10471 if (
not val.is_object())
10473 Throw<std::invalid_argument>(
"JSON patch must be an array of objects");
10477 const std::string op = get_value(
"op",
"op",
true);
10481 switch (get_op(op))
10483 case patch_operations::add:
10485 operation_add(ptr, get_value(
"add",
"value",
false));
10491 operation_remove(ptr);
10498 result.
at(ptr) = get_value(
"replace",
"value",
false);
10504 const std::string from_path = get_value(
"move",
"from",
true);
10514 operation_remove(from_ptr);
10515 operation_add(ptr, v);
10521 const std::string from_path = get_value(
"copy",
"from",
true);;
10525 result[ptr] = result.
at(from_ptr);
10533 bool success = (result.
at(ptr) == get_value(
"test",
"value",
false));
10538 Throw<std::domain_error>(
"unsuccessful: " +
val.dump());
10548 Throw<std::invalid_argument>(
"operation value '" + op +
"' is invalid");
10596 if (source == target)
10601 if (source.
type() != target.
type())
10613 switch (source.
type())
10619 while (i < source.
size() and i < target.
size())
10622 auto temp_diff = diff(source[i], target[i],
path +
"/" + std::to_string(i));
10623 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
10632 while (i < source.
size())
10639 {
"path",
path +
"/" + std::to_string(i)}
10645 while (i < target.
size())
10650 {
"path",
path +
"/" + std::to_string(i)},
10651 {
"value", target[
i]}
10662 for (
auto it = source.
begin(); it != source.
end(); ++it)
10667 if (target.
find(it.key()) != target.
end())
10670 auto temp_diff = diff(it.value(), target[it.key()],
path +
"/" +
key);
10671 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
10685 for (
auto it = target.
begin(); it != target.
end(); ++it)
10687 if (source.
find(it.key()) == source.
end())
10695 {
"value", it.value()}
10755 is_nothrow_move_constructible<nlohmann::json>::value and
10756 is_nothrow_move_assignable<nlohmann::json>::value
10774 const auto&
h = hash<nlohmann::json::string_t>();
10775 return h(j.
dump());
10817 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) 10818 #pragma GCC diagnostic pop const_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:7174
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:7553
iterator operator++(int)
post-increment (it++)
Definition: json.hpp:7389
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:3270
iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:7419
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:7523
void swap(string_t &other)
exchanges the values
Definition: json.hpp:5387
GLint GLsizei count
Definition: gl2.h:421
const_iterator end() const noexcept
returns a const iterator to one past the last element
Definition: json.hpp:4391
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition: json.hpp:4769
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
Definition: json.hpp:2137
const value_type & const_reference
the type of an element const reference
Definition: json.hpp:299
bool operator<(const const_iterator &other) const
comparison: smaller
Definition: json.hpp:7114
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts elements
Definition: json.hpp:5194
typename basic_json::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:6733
std::bidirectional_iterator_tag iterator_category
the category of the iterator
Definition: json.hpp:6739
#define size
Definition: float-mm.c:27
unsigned long long uint64_t
Definition: ptypes.h:120
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:2341
json_reverse_iterator operator--(int)
post-decrement (it–)
Definition: json.hpp:7517
GLsizei GLsizei GLchar * source
Definition: gl2.h:451
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:5087
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
Definition: json.hpp:6824
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:7537
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.hpp:5651
GLint first
Definition: gl2.h:421
def copy(src_path, out_dir, rel_path)
Definition: blink-import.py:86
required HashAlgorithmIdentifier hash
Definition: WebCryptoAPI.idl:276
FloatPoint & operator+=(FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:184
std::vector< TraceArg > args
Definition: event_tracer.cc:256
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:302
ALWAYS_INLINE constexpr remove_reference< T >::type && move(T &&value)
Definition: StdLibExtras.h:464
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:7499
front< split_at< L, std::integral_constant< std::size_t, size< L >::value - N::value > >> pop_back
Definition: Brigand.h:674
iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:7412
object_t::key_type key() const
return the key of an object iterator
Definition: json.hpp:7302
const_iterator(pointer object) noexcept
constructor for a given JSON instance
Definition: json.hpp:6750
int c
Definition: cpp_unittests.cpp:275
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:2314
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:398
bool operator>=(const const_iterator &other) const
comparison: greater than or equal
Definition: json.hpp:7165
GLuint GLuint end
Definition: gl2ext.h:323
FloatPoint & operator-=(FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:196
static basic_json parse(T(&array)[N], const parser_callback_t cb=nullptr)
deserialize from an array
Definition: json.hpp:5906
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:307
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:4937
basic_json(const number_float_t val) noexcept
create a floating-point number (explicit)
Definition: json.hpp:1557
ResourceLoadPriority & operator--(ResourceLoadPriority &priority)
Definition: ResourceLoadPriority.h:49
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:4053
const_reference operator[](const typename object_t::key_type &key) const
read-only access specified object element
Definition: json.hpp:3490
const_iterator cend() const noexcept
returns a const iterator to one past the last element
Definition: json.hpp:4421
ValueType get() const
get a value (explicit)
Definition: json.hpp:2942
rtc::KeyType key_type
Definition: peerconnection_jni.cc:1854
a class to store JSON values
Definition: json.hpp:271
typename detail::push_back_impl< L, T... >::type push_back
Definition: Brigand.h:670
basic_json(const CompatibleStringType &val)
create a string (implicit)
Definition: json.hpp:1348
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition: json.hpp:10253
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:1873
Functor for_each(Functor f)
Definition: Brigand.h:1335
typename detail::make_map< Ts... >::type map
Definition: Brigand.h:223
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:2593
typename detail::transform< sizeof...(OpSeq2), Sequence1, OpSeq1, OpSeq2... >::type transform
Definition: Brigand.h:757
TimeDelta operator*(T a, TimeDelta td)
Definition: timedelta.h:123
constexpr const PointerType get_ptr() const noexcept
get a pointer value (implicit)
Definition: json.hpp:3050
reference value() const
return the value of an iterator
Definition: json.hpp:7320
EGLContext EGLenum target
Definition: eglext.h:192
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:3112
AVCFAssetRef CFArrayRef AVCFAssetLoadValuesCompletionCallback callback
Definition: AVFoundationCFSoftLinking.h:99
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
Definition: json.hpp:5831
reference value() const
return the value of an iterator
Definition: json.hpp:7572
bool t
Definition: UpdateContents.py:37
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:2472
iterator(pointer object) noexcept
constructor for a given JSON instance
Definition: json.hpp:7355
path
Definition: generate.py:74
a mutable random access iterator for the basic_json class
Definition: json.hpp:7344
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
Definition: json.hpp:10753
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:2522
PointerType get_ptr() noexcept
get a pointer value (implicit)
Definition: json.hpp:3022
double U(int64_t x, double alpha)
Definition: metric_recorder.cc:414
std::unique_ptr< Layout > create(RenderBlockFlow &)
Definition: SimpleLineLayout.cpp:861
Definition: videoengine_unittest.h:62
iterator & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:7426
const_iterator & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:7205
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:1127
const GLfloat * m
Definition: gl2ext.h:850
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:10167
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:4703
replace_if< Sequence, std::is_same< _1, pin< OldType > >, NewType > replace
Definition: Brigand.h:1632
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:329
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:2544
const_iterator operator-(difference_type i)
subtract from iterator
Definition: json.hpp:7225
basic_json(const CompatibleObjectType &val)
create an object (implicit)
Definition: json.hpp:1187
function[delay_struct, delayvalues]
Definition: plot_neteq_delay.m:1
basic_json(const CompatibleNumberFloatType val) noexcept
create an floating-point number (implicit)
Definition: json.hpp:1604
CFArrayRef array
Definition: AVFoundationCFSoftLinking.h:129
friend bool operator==(const_reference v, std::nullptr_t) noexcept
comparison: equal
Definition: json.hpp:5560
size_t escape(char *buffer, size_t buflen, const char *source, size_t srclen, const char *illegal, char escape)
Definition: stringencode.cc:25
std::integral_constant< std::int64_t, V > int64_t
Definition: Brigand.h:443
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:10142
basic_json(const typename string_t::value_type *val, typename string_t::size_type count)
Definition: json.hpp:1317
std::integral_constant< std::size_t, V > size_t
Definition: Brigand.h:447
OPENSSL_EXPORT const ASN1_OBJECT * obj
Definition: x509.h:1053
std::integral_constant< std::uint64_t, V > uint64_t
Definition: Brigand.h:445
ObjectType
Definition: ObjectType.h:34
reference operator+=(std::initializer_list< basic_json > init)
add an object to an object
Definition: json.hpp:5059
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:4381
const_iterator operator--(int)
post-decrement (it–)
Definition: json.hpp:7029
basic_json(const int val) noexcept
create an integer number from an enum type (explicit)
Definition: json.hpp:1431
basic_json(const CompatibleArrayType &val)
create an array (implicit)
Definition: json.hpp:1255
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:7377
reference back()
access the last element
Definition: json.hpp:3880
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition: json.hpp:4488
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:7494
const UChar space
Definition: CharacterNames.h:87
static basic_json object(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
explicitly create an object from an initializer list
Definition: json.hpp:1802
bool operator!=(const Handle< T > &a, const Handle< U > &b)
Definition: Handle.h:159
friend class basic_json
allow basic_json to access private members
Definition: json.hpp:6727
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:4961
static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
wrapper to access iterator member functions in range-based for
Definition: json.hpp:4583
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:761
static basic_json parse(std::istream &&i, const parser_callback_t cb=nullptr)
deserialize from stream
Definition: json.hpp:5983
Definition: float-mm.c:54
Definition: base64_test.cc:36
WEBCORE_EXPORT Node * last(const ContainerNode &)
Definition: NodeTraversal.cpp:106
typename basic_json::const_pointer pointer
defines a pointer to the type iterated over (value_type)
Definition: json.hpp:6735
basic_json(const value_t value_type)
create an empty value with a given type
Definition: json.hpp:1103
size_type count(typename object_t::key_type key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:4270
GLuint start
Definition: gl2ext.h:323
bool operator!=(const const_iterator &other) const
comparison: not equal
Definition: json.hpp:7105
static basic_json parse(const ContiguousContainer &c, const parser_callback_t cb=nullptr)
deserialize from a container with contiguous storage
Definition: json.hpp:6106
EGLStreamKHR EGLint n
Definition: eglext.h:984
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:7530
const_reverse_iterator rend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.hpp:4496
bool operator>(const const_iterator &other) const
comparison: greater than
Definition: json.hpp:7156
EGLSetBlobFuncANDROID EGLGetBlobFuncANDROID get
Definition: eglext.h:426
static basic_json parse(const CharPT s, const parser_callback_t cb=nullptr)
deserialize from string literal
Definition: json.hpp:5944
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:3311
basic_json(const object_t &val)
create an object (explicit)
Definition: json.hpp:1152
#define JSON_DEPRECATED
Definition: json.hpp:130
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition: json.hpp:4451
basic_json(const string_t &val)
create a string (explicit)
Definition: json.hpp:1285
WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrash()
Definition: Assertions.cpp:317
int top
Definition: float-mm.c:109
OPENSSL_EXPORT const ASN1_OBJECT int const unsigned char int len
Definition: x509.h:1053
DOMString k
Definition: WebCryptoAPI.idl:122
TestSubObjConstructor T
Definition: TestTypedefs.idl:84
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:7455
iterator find(typename object_t::key_type key)
find an element in a JSON object
Definition: json.hpp:4224
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:2415
void dump()
Definition: DumpRenderTree.mm:1676
EGLSurface EGLint x
Definition: eglext.h:950
#define isfinite
Definition: jsoncpp.cpp:4014
void swap(object_t &other)
exchanges the values
Definition: json.hpp:5354
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:550
const_reference operator[](T *key) const
read-only access specified object element
Definition: json.hpp:3652
Definition: interfaces.idl:172
reference operator[](T *(&key)[n])
access specified object element
Definition: json.hpp:3532
pointer operator->() const
dereference the iterator
Definition: json.hpp:7383
const_iterator(const iterator &other) noexcept
copy constructor given a non-const iterator
Definition: json.hpp:6782
EGLAttrib * value
Definition: eglext.h:120
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:7510
namespace for Niels Lohmann
Definition: json.hpp:138
parse_event_t
JSON callback events.
Definition: json.hpp:982
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:2284
unsigned char uint8_t
Definition: ptypes.h:89
Definition: RTCStatsReport.idl:41
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:1826
size_t unescape(char *buffer, size_t buflen, const char *source, size_t srclen, char escape)
Definition: stringencode.cc:47
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.hpp:4554
const_reference operator[](T *(&key)[n]) const
read-only access specified object element
Definition: json.hpp:3567
std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
per-element parser callback type
Definition: json.hpp:1052
typename detail::flatten_impl< Sequence > flatten
Definition: Brigand.h:1120
const_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:7040
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:2566
void advance(int nbodies, struct planet *bodies, double dt)
Definition: n-body.c:23
ValueType
Definition: WebKitPluginHostTypes.h:51
difference_type operator-(const iterator &other) const
return difference
Definition: json.hpp:7449
basic_json value_type
the type of elements in a basic_json container
Definition: json.hpp:294
basic_json(boolean_t val) noexcept
create a boolean (explicit)
Definition: json.hpp:1368
std::string to_string() const noexcept
return a string representation of the JSON pointer
Definition: json.hpp:9534
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:2100
static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
explicitly create an array from an initializer list
Definition: json.hpp:1762
void test(int32_t count, function< MediaTime(int32_t)> generator)
Definition: main.cpp:57
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:6146
basic_json(const typename string_t::value_type *val)
create a string (explicit)
Definition: json.hpp:1311
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.hpp:5467
JSON Pointer.
Definition: json.hpp:9487
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
Definition: json.hpp:5863
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
Definition: json.hpp:6136
ValueType value(const typename object_t::key_type &key, ValueType default_value) const
access specified object element with default value
Definition: json.hpp:3716
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
Definition: json.hpp:5289
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:7559
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:5011
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:304
static iteration_proxy< iterator > iterator_wrapper(reference cont)
wrapper to access iterator member functions in range-based for
Definition: json.hpp:4575
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:4927
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:3351
const_iterator begin() const noexcept
returns a const iterator to the first element
Definition: json.hpp:4320
friend bool operator!=(const_reference v, std::nullptr_t) noexcept
comparison: not equal
Definition: json.hpp:5613
typename basic_json::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:6731
GLboolean GLboolean GLboolean GLboolean a
Definition: gl2ext.h:306
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:7263
GLint GLenum GLsizei GLsizei GLsizei depth
Definition: gl2ext.h:572
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.hpp:4525
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:2500
string_t dump(const int indent=-1) const
serialization
Definition: json.hpp:2242
GLenum void ** pointer
Definition: gl2.h:460
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition: json.hpp:4350
std::size_t operator()(const nlohmann::json &j) const
return a hash value for a JSON object
Definition: json.hpp:10771
GLint reference
Definition: gl2ext.h:922
array (ordered collection of values)
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:2444
#define N
Definition: gcc-loops.cpp:14
basic_json(const CompatibleNumberUnsignedType val) noexcept
create an unsigned number (implicit)
Definition: json.hpp:1526
static basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition: json.hpp:10588
json_reverse_iterator operator++(int)
post-increment (it++)
Definition: json.hpp:7504
GLfloat f
Definition: gl2.h:417
const_reference back() const
access the last element
Definition: json.hpp:3890
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:2385
detail::split_helper< TList, TDelim > split
Definition: Brigand.h:1696
const GLfloat * v
Definition: gl2.h:514
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4901
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:312
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:3099
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.hpp:5768
const_reverse_iterator rbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.hpp:4459
int boolean
Definition: dry.c:154
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:622
iterator operator--(int)
post-decrement (it–)
Definition: json.hpp:7404
bool operator==(const Handle< T > &a, const Handle< U > &b)
Definition: Handle.h:144
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
Definition: json.hpp:10303
Definition: safe_conversions.h:16
basic_json(const number_unsigned_t val) noexcept
create an unsigned integer number (explicit)
Definition: json.hpp:1495
iterator insert(const_iterator pos, basic_json &&val)
inserts element
Definition: json.hpp:5113
bool empty() const noexcept
checks whether the container is empty
Definition: json.hpp:4635
EGLenum type
Definition: eglext.h:63
def hexify(s)
Definition: util.py:149
JSON_DEPRECATED basic_json(std::istream &i, const parser_callback_t cb=nullptr)
construct a JSON value given an input stream
Definition: json.hpp:1991
basic_json(const number_integer_t val) noexcept
create an integer number (explicit)
Definition: json.hpp:1400
GLsizei const GLchar *const * string
Definition: gl2.h:479
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:2363
result
Definition: target-blank-opener-post-window.php:5
void init()
Definition: HTMLNames.cpp:1637
iterator operator+(difference_type i)
add to iterator
Definition: json.hpp:7433
double max
Definition: DeviceProximityEvent.idl:32
const_iterator find(typename object_t::key_type key) const
find an element in a JSON object
Definition: json.hpp:4240
GLfloat GLfloat GLfloat GLfloat h
Definition: gl2ext.h:3060
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
Definition: json.hpp:1679
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:310
bool is(Ref< ArgType > &source)
Definition: Ref.h:220
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:10115
std::integral_constant< std::ptrdiff_t, V > ptrdiff_t
Definition: Brigand.h:449
#define m_type
Definition: user_mbuf.h:248
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:10192
for i
Definition: complexityMeasures.m:24
const_reference front() const
access the first element
Definition: json.hpp:3845
value_t
the JSON type enumeration
Definition: json.hpp:792
constexpr bool operator<=(const UnexpectedType< E > &lhs, const UnexpectedType< E > &rhs)
Definition: Expected.h:61
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:3946
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:3229
iterator & operator++()
pre-increment (++it)
Definition: json.hpp:7397
json_pointer(const std::string &s="")
create JSON pointer
Definition: json.hpp:9515
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:3192
difference_type operator-(const const_iterator &other) const
return difference
Definition: json.hpp:7236
GLsizei GLsizei GLfloat distance
Definition: gl2ext.h:2866
basic_json(const CompatibleNumberIntegerType val) noexcept
create an integer number (implicit)
Definition: json.hpp:1468
const
Definition: upload.py:398
object_t::key_type key() const
return the key of an object iterator
Definition: json.hpp:7565
#define NULL
Definition: common_types.h:41
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:4987
iterator operator-(difference_type i)
subtract from iterator
Definition: json.hpp:7441
static basic_json parse(std::istream &i, const parser_callback_t cb=nullptr)
deserialize from stream
Definition: json.hpp:5974
object (unordered set of name/value pairs)
string_t value(const json_pointer &ptr, const char *default_value) const
overload for a default value of type const char*
Definition: json.hpp:3807
DOMString e
Definition: WebCryptoAPI.idl:115
friend bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:5420
EGLenum EGLObjectKHR object
Definition: eglext.h:121
const_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:6997
basic_json(const array_t &val)
create an array (explicit)
Definition: json.hpp:1215
string_t value(const typename object_t::key_type &key, const char *default_value) const
overload for a default value of type const char*
Definition: json.hpp:3742
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:6909
ValueType value(const json_pointer &ptr, ValueType default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:3790
std::unique_ptr< ParsedNode > parse(VM *vm, const SourceCode &source, const Identifier &name, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, SourceParseMode parseMode, SuperBinding superBinding, ParserError &error, JSTextPosition *positionBeforeLastNewline=nullptr, ConstructorKind defaultConstructorKind=ConstructorKind::None, DerivedContextType derivedContextType=DerivedContextType::None, EvalContextType evalContextType=EvalContextType::None, DebuggerParseData *debuggerParseData=nullptr)
Definition: Parser.h:1887
GLboolean GLboolean GLboolean b
Definition: gl2ext.h:306
typename basic_json::const_reference reference
defines a reference to the type iterated over (value_type)
Definition: json.hpp:6737
iterator(const iterator &other) noexcept
copy constructor
Definition: json.hpp:7360
pointer operator->() const
dereference the iterator
Definition: json.hpp:6950
reference value() const
return the value of an iterator
Definition: json.hpp:7461
constexpr bool operator<(const UnexpectedType< E > &lhs, const UnexpectedType< E > &rhs)
Definition: Expected.h:59
basic_json<> json
default JSON class
Definition: json.hpp:10736
iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
inserts elements
Definition: json.hpp:5252
typename detail::insert_impl< L, T >::type insert
Definition: Brigand.h:2317
bool operator<=(const const_iterator &other) const
comparison: less than or equal
Definition: json.hpp:7147
res
Definition: harness.py:111
#define NO_RETURN
Definition: typedefs.h:108
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:4141
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:4178
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:477
void clear() noexcept
clears the contents
Definition: json.hpp:4828
a const random access iterator for the basic_json class
Definition: json.hpp:6724
a template for a reverse iterator class
Definition: json.hpp:281
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:693
#define ASSERT(assertion)
Definition: Assertions.h:283
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adaptor
Definition: json.hpp:7489
CFArrayRef CFTypeRef key
Definition: AVFoundationCFSoftLinking.h:129
const_iterator operator++(int)
post-increment (it++)
Definition: json.hpp:6986
SubsamplingLevel & operator++(SubsamplingLevel &subsamplingLevel)
Definition: ImageFrame.h:51
reference operator[](T *key)
access specified object element
Definition: json.hpp:3600
friend bool operator!=(std::nullptr_t, const_reference v) noexcept
comparison: not equal
Definition: json.hpp:5622
Parser & parser
Definition: XPathGrammar.cpp:1193
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:7491
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
Definition: json.hpp:7365
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.hpp:5746
for for j
Definition: complexityMeasures.m:25
temp
Definition: parse_delay_file.m:64
GLuint GLsizei GLsizei GLfloat * val
Definition: gl2ext.h:3301
void swap(optional< T > &x, optional< T > &y) __NOEXCEPT_(__NOEXCEPT_(x.swap(y)))
Definition: Optional.h:1047
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:5790
const_iterator operator+(difference_type i)
add to iterator
Definition: json.hpp:7214
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.hpp:5590
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:3399
bool operator==(const const_iterator &other) const
comparison: equal
Definition: json.hpp:7072
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:4310
StringType string_t
a type for a string
Definition: json.hpp:524
static basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr)
deserialize from an iterator range with contiguous storage
Definition: json.hpp:6034
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:7545
reference front()
access the first element
Definition: json.hpp:3837
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts elements
Definition: json.hpp:5142
friend bool operator==(std::nullptr_t, const_reference v) noexcept
comparison: equal
Definition: json.hpp:5569
ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json > >> object_t
a type for an object
Definition: json.hpp:431
value_type & reference
the type of an element reference
Definition: json.hpp:297
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:2023
CVPixelBufferRef CVOptionFlags lockFlags CFAllocatorRef allocator
Definition: CoreVideoSoftLink.cpp:56
#define T(a)
Definition: row_common.cc:1964
~basic_json()
destructor
Definition: json.hpp:2170
basic_json flatten() const
return flattened JSON value
Definition: json.hpp:10219
void push_back(std::initializer_list< basic_json > init)
add an object to an object
Definition: json.hpp:5042
const_iterator(const const_iterator &other) noexcept
copy constructor
Definition: json.hpp:6815
typename lazy::remove< L, T >::type remove
Definition: Brigand.h:1595
void swap(array_t &other)
exchanges the values
Definition: json.hpp:5321
reference operator[](const typename object_t::key_type &key)
access specified object element
Definition: json.hpp:3439