1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-31 10:24:23 +03:00

🔨 add NLOHMANN_JSON prefix and undef macros

This commit is contained in:
Niels Lohmann
2019-07-01 22:24:39 +02:00
parent 1720bfedd1
commit 897362191d
20 changed files with 4055 additions and 2294 deletions

View File

@ -319,7 +319,7 @@ class basic_json
@since 2.1.0
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json meta()
{
basic_json result;
@ -824,7 +824,7 @@ class basic_json
/// helper for exception-safe object creation
template<typename T, typename... Args>
HEDLEY_RETURNS_NON_NULL
NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL
static T* create(Args&& ... args)
{
AllocatorType<T> alloc;
@ -951,7 +951,7 @@ class basic_json
default:
{
object = nullptr; // silence warning, see #821
if (HEDLEY_UNLIKELY(t == value_t::null))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(t == value_t::null))
{
JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE
}
@ -1428,7 +1428,7 @@ class basic_json
}
// if object is wanted but impossible, throw an exception
if (HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object))
{
JSON_THROW(type_error::create(301, "cannot create object from initializer list"));
}
@ -1495,7 +1495,7 @@ class basic_json
@since version 1.0.0
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json array(initializer_list_t init = {})
{
return basic_json(init, false, value_t::array);
@ -1539,7 +1539,7 @@ class basic_json
@since version 1.0.0
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json object(initializer_list_t init = {})
{
return basic_json(init, false, value_t::object);
@ -1638,7 +1638,7 @@ class basic_json
assert(last.m_object != nullptr);
// make sure iterator fits the current value
if (HEDLEY_UNLIKELY(first.m_object != last.m_object))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(201, "iterators are not compatible"));
}
@ -1655,8 +1655,8 @@ class basic_json
case value_t::number_unsigned:
case value_t::string:
{
if (HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin()
or not last.m_it.primitive_iterator.is_end()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin()
or not last.m_it.primitive_iterator.is_end()))
{
JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
}
@ -2369,7 +2369,7 @@ class basic_json
/// get a boolean (explicit)
boolean_t get_impl(boolean_t* /*unused*/) const
{
if (HEDLEY_LIKELY(is_boolean()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_boolean()))
{
return m_value.boolean;
}
@ -2478,7 +2478,7 @@ class basic_json
// delegate the call to get_ptr<>()
auto ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
if (HEDLEY_LIKELY(ptr != nullptr))
if (NLOHMANN_JSON_HEDLEY_LIKELY(ptr != nullptr))
{
return *ptr;
}
@ -2929,7 +2929,7 @@ class basic_json
reference at(size_type idx)
{
// at only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
JSON_TRY
{
@ -2976,7 +2976,7 @@ class basic_json
const_reference at(size_type idx) const
{
// at only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
JSON_TRY
{
@ -3027,7 +3027,7 @@ class basic_json
reference at(const typename object_t::key_type& key)
{
// at only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
JSON_TRY
{
@ -3078,7 +3078,7 @@ class basic_json
const_reference at(const typename object_t::key_type& key) const
{
// at only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
JSON_TRY
{
@ -3132,7 +3132,7 @@ class basic_json
}
// operator[] only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
// fill up array with null values if given idx is outside range
if (idx >= m_value.array->size())
@ -3170,7 +3170,7 @@ class basic_json
const_reference operator[](size_type idx) const
{
// const operator[] only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
return m_value.array->operator[](idx);
}
@ -3216,7 +3216,7 @@ class basic_json
}
// operator[] only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
return m_value.object->operator[](key);
}
@ -3257,7 +3257,7 @@ class basic_json
const_reference operator[](const typename object_t::key_type& key) const
{
// const operator[] only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
assert(m_value.object->find(key) != m_value.object->end());
return m_value.object->find(key)->second;
@ -3294,7 +3294,7 @@ class basic_json
@since version 1.1.0
*/
template<typename T>
HEDLEY_NON_NULL(2)
NLOHMANN_JSON_HEDLEY_NON_NULL(2)
reference operator[](T* key)
{
// implicitly convert null to object
@ -3306,7 +3306,7 @@ class basic_json
}
// at only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
return m_value.object->operator[](key);
}
@ -3345,11 +3345,11 @@ class basic_json
@since version 1.1.0
*/
template<typename T>
HEDLEY_NON_NULL(2)
NLOHMANN_JSON_HEDLEY_NON_NULL(2)
const_reference operator[](T* key) const
{
// at only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
assert(m_value.object->find(key) != m_value.object->end());
return m_value.object->find(key)->second;
@ -3413,7 +3413,7 @@ class basic_json
ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
{
// at only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
// if key is found, return value and given default value otherwise
const auto it = find(key);
@ -3485,7 +3485,7 @@ class basic_json
ValueType value(const json_pointer& ptr, const ValueType& default_value) const
{
// at only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
// if pointer resolves a value, return it or use default value
JSON_TRY
@ -3505,7 +3505,7 @@ class basic_json
@brief overload for a default value of type const char*
@copydoc basic_json::value(const json_pointer&, ValueType) const
*/
HEDLEY_NON_NULL(3)
NLOHMANN_JSON_HEDLEY_NON_NULL(3)
string_t value(const json_pointer& ptr, const char* default_value) const
{
return value(ptr, string_t(default_value));
@ -3650,7 +3650,7 @@ class basic_json
IteratorType erase(IteratorType pos)
{
// make sure iterator fits the current value
if (HEDLEY_UNLIKELY(this != pos.m_object))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != pos.m_object))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
}
@ -3665,7 +3665,7 @@ class basic_json
case value_t::number_unsigned:
case value_t::string:
{
if (HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
{
JSON_THROW(invalid_iterator::create(205, "iterator out of range"));
}
@ -3755,7 +3755,7 @@ class basic_json
IteratorType erase(IteratorType first, IteratorType last)
{
// make sure iterator fits the current value
if (HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object))
{
JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value"));
}
@ -3770,8 +3770,8 @@ class basic_json
case value_t::number_unsigned:
case value_t::string:
{
if (HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin()
or not last.m_it.primitive_iterator.is_end()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin()
or not last.m_it.primitive_iterator.is_end()))
{
JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
}
@ -3842,7 +3842,7 @@ class basic_json
size_type erase(const typename object_t::key_type& key)
{
// this erase only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
return m_value.object->erase(key);
}
@ -3877,9 +3877,9 @@ class basic_json
void erase(const size_type idx)
{
// this erase only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
if (HEDLEY_UNLIKELY(idx >= size()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(idx >= size()))
{
JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
}
@ -4355,7 +4355,7 @@ class basic_json
future 4.0.0 of the library. Please use @ref items() instead;
that is, replace `json::iterator_wrapper(j)` with `j.items()`.
*/
HEDLEY_DEPRECATED(3.1.0)
NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0)
static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
{
return ref.items();
@ -4364,7 +4364,7 @@ class basic_json
/*!
@copydoc iterator_wrapper(reference)
*/
HEDLEY_DEPRECATED(3.1.0)
NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0)
static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
{
return ref.items();
@ -4783,7 +4783,7 @@ class basic_json
void push_back(basic_json&& val)
{
// push_back only works for null objects or arrays
if (HEDLEY_UNLIKELY(not(is_null() or is_array())))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
}
@ -4820,7 +4820,7 @@ class basic_json
void push_back(const basic_json& val)
{
// push_back only works for null objects or arrays
if (HEDLEY_UNLIKELY(not(is_null() or is_array())))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
}
@ -4870,7 +4870,7 @@ class basic_json
void push_back(const typename object_t::value_type& val)
{
// push_back only works for null objects or objects
if (HEDLEY_UNLIKELY(not(is_null() or is_object())))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
}
@ -4971,7 +4971,7 @@ class basic_json
void emplace_back(Args&& ... args)
{
// emplace_back only works for null objects or arrays
if (HEDLEY_UNLIKELY(not(is_null() or is_array())))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array())))
{
JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name())));
}
@ -5019,7 +5019,7 @@ class basic_json
std::pair<iterator, bool> emplace(Args&& ... args)
{
// emplace only works for null objects or arrays
if (HEDLEY_UNLIKELY(not(is_null() or is_object())))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object())))
{
JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name())));
}
@ -5087,10 +5087,10 @@ class basic_json
iterator insert(const_iterator pos, const basic_json& val)
{
// insert only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
// check if iterator pos fits to this JSON value
if (HEDLEY_UNLIKELY(pos.m_object != this))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
}
@ -5138,10 +5138,10 @@ class basic_json
iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
{
// insert only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
// check if iterator pos fits to this JSON value
if (HEDLEY_UNLIKELY(pos.m_object != this))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
}
@ -5186,24 +5186,24 @@ class basic_json
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
{
// insert only works for arrays
if (HEDLEY_UNLIKELY(not is_array()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
}
// check if iterator pos fits to this JSON value
if (HEDLEY_UNLIKELY(pos.m_object != this))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
}
// check if range iterators belong to the same JSON object
if (HEDLEY_UNLIKELY(first.m_object != last.m_object))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
}
if (HEDLEY_UNLIKELY(first.m_object == this))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object == this))
{
JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container"));
}
@ -5239,13 +5239,13 @@ class basic_json
iterator insert(const_iterator pos, initializer_list_t ilist)
{
// insert only works for arrays
if (HEDLEY_UNLIKELY(not is_array()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
}
// check if iterator pos fits to this JSON value
if (HEDLEY_UNLIKELY(pos.m_object != this))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
}
@ -5280,19 +5280,19 @@ class basic_json
void insert(const_iterator first, const_iterator last)
{
// insert only works for objects
if (HEDLEY_UNLIKELY(not is_object()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
}
// check if range iterators belong to the same JSON object
if (HEDLEY_UNLIKELY(first.m_object != last.m_object))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
}
// passed iterators must belong to objects
if (HEDLEY_UNLIKELY(not first.m_object->is_object()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object()))
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
}
@ -5329,11 +5329,11 @@ class basic_json
assert_invariant();
}
if (HEDLEY_UNLIKELY(not is_object()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
}
if (HEDLEY_UNLIKELY(not j.is_object()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
}
@ -5380,20 +5380,20 @@ class basic_json
assert_invariant();
}
if (HEDLEY_UNLIKELY(not is_object()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
}
// check if range iterators belong to the same JSON object
if (HEDLEY_UNLIKELY(first.m_object != last.m_object))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
}
// passed iterators must belong to objects
if (HEDLEY_UNLIKELY(not first.m_object->is_object()
or not last.m_object->is_object()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object()
or not last.m_object->is_object()))
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
}
@ -5456,7 +5456,7 @@ class basic_json
void swap(array_t& other)
{
// swap only works for arrays
if (HEDLEY_LIKELY(is_array()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array()))
{
std::swap(*(m_value.array), other);
}
@ -5489,7 +5489,7 @@ class basic_json
void swap(object_t& other)
{
// swap only works for objects
if (HEDLEY_LIKELY(is_object()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object()))
{
std::swap(*(m_value.object), other);
}
@ -5522,7 +5522,7 @@ class basic_json
void swap(string_t& other)
{
// swap only works for strings
if (HEDLEY_LIKELY(is_string()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(is_string()))
{
std::swap(*(m_value.string), other);
}
@ -6032,7 +6032,7 @@ class basic_json
instead; that is, replace calls like `j >> o;` with `o << j;`.
@since version 1.0.0; deprecated since version 3.0.0
*/
HEDLEY_DEPRECATED(3.0.0)
NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0)
friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
{
return o << j;
@ -6111,7 +6111,7 @@ class basic_json
@since version 2.0.3 (contiguous containers)
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json parse(detail::input_adapter&& i,
const parser_callback_t cb = nullptr,
const bool allow_exceptions = true)
@ -6180,7 +6180,7 @@ class basic_json
@since version 3.2.0
*/
template <typename SAX>
HEDLEY_NON_NULL(2)
NLOHMANN_JSON_HEDLEY_NON_NULL(2)
static bool sax_parse(detail::input_adapter&& i, SAX* sax,
input_format_t format = input_format_t::json,
const bool strict = true)
@ -6266,7 +6266,7 @@ class basic_json
std::is_base_of<
std::random_access_iterator_tag,
typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
HEDLEY_NON_NULL(3)
NLOHMANN_JSON_HEDLEY_NON_NULL(3)
static bool sax_parse(IteratorType first, IteratorType last, SAX* sax)
{
return parser(detail::input_adapter(first, last)).sax_parse(sax);
@ -6280,7 +6280,7 @@ class basic_json
instead; that is, replace calls like `j << i;` with `i >> j;`.
@since version 1.0.0; deprecated since version 3.0.0
*/
HEDLEY_DEPRECATED(3.0.0)
NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0)
friend std::istream& operator<<(basic_json& j, std::istream& i)
{
return operator>>(i, j);
@ -6353,7 +6353,7 @@ class basic_json
@since version 1.0.0, public since 2.1.0, `const char*` and `noexcept`
since 3.0.0
*/
HEDLEY_RETURNS_NON_NULL
NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL
const char* type_name() const noexcept
{
{
@ -6883,7 +6883,7 @@ class basic_json
@a strict parameter since 3.0.0; added @a allow_exceptions parameter
since 3.2.0
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_cbor(detail::input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
@ -6899,7 +6899,7 @@ class basic_json
*/
template<typename A1, typename A2,
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_cbor(A1 && a1, A2 && a2,
const bool strict = true,
const bool allow_exceptions = true)
@ -6992,7 +6992,7 @@ class basic_json
@a strict parameter since 3.0.0; added @a allow_exceptions parameter
since 3.2.0
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_msgpack(detail::input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
@ -7008,7 +7008,7 @@ class basic_json
*/
template<typename A1, typename A2,
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_msgpack(A1 && a1, A2 && a2,
const bool strict = true,
const bool allow_exceptions = true)
@ -7080,7 +7080,7 @@ class basic_json
@since version 3.1.0; added @a allow_exceptions parameter since 3.2.0
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_ubjson(detail::input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
@ -7096,7 +7096,7 @@ class basic_json
*/
template<typename A1, typename A2,
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_ubjson(A1 && a1, A2 && a2,
const bool strict = true,
const bool allow_exceptions = true)
@ -7167,7 +7167,7 @@ class basic_json
@sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
related UBJSON format
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_bson(detail::input_adapter&& i,
const bool strict = true,
const bool allow_exceptions = true)
@ -7183,7 +7183,7 @@ class basic_json
*/
template<typename A1, typename A2,
detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json from_bson(A1 && a1, A2 && a2,
const bool strict = true,
const bool allow_exceptions = true)
@ -7557,7 +7557,7 @@ class basic_json
else
{
const auto idx = json_pointer::array_index(last_path);
if (HEDLEY_UNLIKELY(static_cast<size_type>(idx) > parent.size()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(static_cast<size_type>(idx) > parent.size()))
{
// avoid undefined behavior
JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
@ -7588,7 +7588,7 @@ class basic_json
{
// perform range check
auto it = parent.find(last_path);
if (HEDLEY_LIKELY(it != parent.end()))
if (NLOHMANN_JSON_HEDLEY_LIKELY(it != parent.end()))
{
parent.erase(it);
}
@ -7605,7 +7605,7 @@ class basic_json
};
// type check: top level value must be an array
if (HEDLEY_UNLIKELY(not json_patch.is_array()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not json_patch.is_array()))
{
JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
}
@ -7625,13 +7625,13 @@ class basic_json
const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'";
// check if desired value is present
if (HEDLEY_UNLIKELY(it == val.m_value.object->end()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end()))
{
JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'"));
}
// check if result is of type string
if (HEDLEY_UNLIKELY(string_type and not it->second.is_string()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string()))
{
JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'"));
}
@ -7641,7 +7641,7 @@ class basic_json
};
// type check: every element of the array must be an object
if (HEDLEY_UNLIKELY(not val.is_object()))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not val.is_object()))
{
JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
}
@ -7719,7 +7719,7 @@ class basic_json
}
// throw an exception if test fails
if (HEDLEY_UNLIKELY(not success))
if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not success))
{
JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump()));
}
@ -7772,7 +7772,7 @@ class basic_json
@since version 2.0.0
*/
HEDLEY_WARN_UNUSED_RESULT
NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT
static basic_json diff(const basic_json& source, const basic_json& target,
const std::string& path = "")
{
@ -8064,7 +8064,7 @@ if no parse error occurred.
@since version 1.0.0
*/
HEDLEY_NON_NULL(1)
NLOHMANN_JSON_HEDLEY_NON_NULL(1)
inline nlohmann::json operator "" _json(const char* s, std::size_t n)
{
return nlohmann::json::parse(s, s + n);
@ -8083,7 +8083,7 @@ object if no parse error occurred.
@since version 2.0.0
*/
HEDLEY_NON_NULL(1)
NLOHMANN_JSON_HEDLEY_NON_NULL(1)
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
{
return nlohmann::json::json_pointer(std::string(s, n));