aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/nlohmann_json/include/nlohmann/detail/input
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2023-12-14 07:54:29 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2023-12-14 08:21:54 +0300
commitdb7f91de8c86629d479db1daf8dddf9704186478 (patch)
treed0175a4e634ef25468fa1b78c8ef71c56f074e53 /contrib/restricted/nlohmann_json/include/nlohmann/detail/input
parente938f3027e06f8f4f3f2f0d79d0262d91caac192 (diff)
downloadydb-db7f91de8c86629d479db1daf8dddf9704186478.tar.gz
Update contrib/restricted/nlohmann_json to 3.11.3
Diffstat (limited to 'contrib/restricted/nlohmann_json/include/nlohmann/detail/input')
-rw-r--r--contrib/restricted/nlohmann_json/include/nlohmann/detail/input/binary_reader.hpp31
-rw-r--r--contrib/restricted/nlohmann_json/include/nlohmann/detail/input/input_adapters.hpp16
-rw-r--r--contrib/restricted/nlohmann_json/include/nlohmann/detail/input/json_sax.hpp21
-rw-r--r--contrib/restricted/nlohmann_json/include/nlohmann/detail/input/lexer.hpp33
-rw-r--r--contrib/restricted/nlohmann_json/include/nlohmann/detail/input/parser.hpp18
-rw-r--r--contrib/restricted/nlohmann_json/include/nlohmann/detail/input/position_t.hpp4
6 files changed, 66 insertions, 57 deletions
diff --git a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/binary_reader.hpp b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/binary_reader.hpp
index 634615d35e..a6e100e761 100644
--- a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/binary_reader.hpp
+++ b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/binary_reader.hpp
@@ -1,9 +1,9 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#pragma once
@@ -55,7 +55,6 @@ static inline bool little_endianness(int num = 1) noexcept
return *reinterpret_cast<char*>(&num) == 1;
}
-
///////////////////
// binary reader //
///////////////////
@@ -73,7 +72,7 @@ class binary_reader
using binary_t = typename BasicJsonType::binary_t;
using json_sax_t = SAX;
using char_type = typename InputAdapterType::char_type;
- using char_int_type = typename std::char_traits<char_type>::int_type;
+ using char_int_type = typename char_traits<char_type>::int_type;
public:
/*!
@@ -146,7 +145,7 @@ class binary_reader
get();
}
- if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char_type>::eof()))
+ if (JSON_HEDLEY_UNLIKELY(current != char_traits<char_type>::eof()))
{
return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
exception_message(input_format, concat("expected end of input; last byte: 0x", get_token_string()), "value"), nullptr));
@@ -229,7 +228,7 @@ class binary_reader
exception_message(input_format_t::bson, concat("string length must be at least 1, is ", std::to_string(len)), "string"), nullptr));
}
- return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) && get() != std::char_traits<char_type>::eof();
+ return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) && get() != char_traits<char_type>::eof();
}
/*!
@@ -330,7 +329,7 @@ class binary_reader
{
std::array<char, 3> cr{{}};
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
- std::string cr_str{cr.data()};
+ const std::string cr_str{cr.data()};
return sax->parse_error(element_type_parse_position, cr_str,
parse_error::create(114, element_type_parse_position, concat("Unsupported BSON record type 0x", cr_str), nullptr));
}
@@ -423,7 +422,7 @@ class binary_reader
switch (get_char ? get() : current)
{
// EOF
- case std::char_traits<char_type>::eof():
+ case char_traits<char_type>::eof():
return unexpect_eof(input_format_t::cbor, "value");
// Integer 0x00..0x17 (0..23)
@@ -1198,7 +1197,7 @@ class binary_reader
switch (get())
{
// EOF
- case std::char_traits<char_type>::eof():
+ case char_traits<char_type>::eof():
return unexpect_eof(input_format_t::msgpack, "value");
// positive fixint
@@ -2153,7 +2152,7 @@ class binary_reader
}
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
{
- return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimentional vector is not allowed", "size"), nullptr));
+ return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr));
}
std::vector<size_t> dim;
if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim)))
@@ -2265,7 +2264,7 @@ class binary_reader
exception_message(input_format, concat("expected '#' after type information; last byte: 0x", last_token), "size"), nullptr));
}
- bool is_error = get_ubjson_size_value(result.first, is_ndarray);
+ const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
if (input_format == input_format_t::bjdata && is_ndarray)
{
if (inside_ndarray)
@@ -2280,7 +2279,7 @@ class binary_reader
if (current == '#')
{
- bool is_error = get_ubjson_size_value(result.first, is_ndarray);
+ const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
if (input_format == input_format_t::bjdata && is_ndarray)
{
return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
@@ -2300,7 +2299,7 @@ class binary_reader
{
switch (prefix)
{
- case std::char_traits<char_type>::eof(): // EOF
+ case char_traits<char_type>::eof(): // EOF
return unexpect_eof(input_format, "value");
case 'T': // true
@@ -2745,7 +2744,7 @@ class binary_reader
This function provides the interface to the used input adapter. It does
not throw in case the input reached EOF, but returns a -'ve valued
- `std::char_traits<char_type>::eof()` in that case.
+ `char_traits<char_type>::eof()` in that case.
@return character read from the input
*/
@@ -2887,7 +2886,7 @@ class binary_reader
JSON_HEDLEY_NON_NULL(3)
bool unexpect_eof(const input_format_t format, const char* context) const
{
- if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char_type>::eof()))
+ if (JSON_HEDLEY_UNLIKELY(current == char_traits<char_type>::eof()))
{
return sax->parse_error(chars_read, "<end of file>",
parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr));
@@ -2954,7 +2953,7 @@ class binary_reader
InputAdapterType ia;
/// the current character
- char_int_type current = std::char_traits<char_type>::eof();
+ char_int_type current = char_traits<char_type>::eof();
/// the number of characters read
std::size_t chars_read = 0;
diff --git a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/input_adapters.hpp b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/input_adapters.hpp
index cf53b1d572..33fca3e4b9 100644
--- a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/input_adapters.hpp
+++ b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/input_adapters.hpp
@@ -1,9 +1,9 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#pragma once
@@ -25,6 +25,7 @@
#include <nlohmann/detail/iterators/iterator_traits.hpp>
#include <nlohmann/detail/macro_scope.hpp>
+#include <nlohmann/detail/meta/type_traits.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
@@ -71,7 +72,6 @@ class file_input_adapter
std::FILE* m_file;
};
-
/*!
Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
beginning of input. Does not support changing the underlying std::streambuf
@@ -145,16 +145,16 @@ class iterator_input_adapter
: current(std::move(first)), end(std::move(last))
{}
- typename std::char_traits<char_type>::int_type get_character()
+ typename char_traits<char_type>::int_type get_character()
{
if (JSON_HEDLEY_LIKELY(current != end))
{
- auto result = std::char_traits<char_type>::to_int_type(*current);
+ auto result = char_traits<char_type>::to_int_type(*current);
std::advance(current, 1);
return result;
}
- return std::char_traits<char_type>::eof();
+ return char_traits<char_type>::eof();
}
private:
@@ -170,7 +170,6 @@ class iterator_input_adapter
}
};
-
template<typename BaseInputAdapter, size_t T>
struct wide_string_input_helper;
@@ -294,7 +293,7 @@ struct wide_string_input_helper<BaseInputAdapter, 2>
}
};
-// Wraps another input apdater to convert wide character types into individual bytes.
+// Wraps another input adapter to convert wide character types into individual bytes.
template<typename BaseInputAdapter, typename WideCharType>
class wide_string_input_adapter
{
@@ -339,7 +338,6 @@ class wide_string_input_adapter
std::size_t utf8_bytes_filled = 0;
};
-
template<typename IteratorType, typename Enable = void>
struct iterator_input_adapter_factory
{
diff --git a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/json_sax.hpp b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/json_sax.hpp
index 5bd5c51c02..c772521cd8 100644
--- a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/json_sax.hpp
+++ b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/json_sax.hpp
@@ -1,9 +1,9 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#pragma once
@@ -142,7 +142,6 @@ struct json_sax
virtual ~json_sax() = default;
};
-
namespace detail
{
/*!
@@ -244,7 +243,7 @@ class json_sax_dom_parser
JSON_ASSERT(ref_stack.back()->is_object());
// add null at given key and store the reference for later
- object_element = &(ref_stack.back()->m_value.object->operator[](val));
+ object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
return true;
}
@@ -319,8 +318,8 @@ class json_sax_dom_parser
if (ref_stack.back()->is_array())
{
- ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
- return &(ref_stack.back()->m_value.array->back());
+ ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
+ return &(ref_stack.back()->m_data.m_value.array->back());
}
JSON_ASSERT(ref_stack.back()->is_object());
@@ -439,7 +438,7 @@ class json_sax_dom_callback_parser
// add discarded value at given key and store the reference for later
if (keep && ref_stack.back())
{
- object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
+ object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
}
return true;
@@ -524,7 +523,7 @@ class json_sax_dom_callback_parser
// remove discarded value
if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
{
- ref_stack.back()->m_value.array->pop_back();
+ ref_stack.back()->m_data.m_value.array->pop_back();
}
return true;
@@ -591,7 +590,7 @@ class json_sax_dom_callback_parser
if (ref_stack.empty())
{
root = std::move(value);
- return {true, &root};
+ return {true, & root};
}
// skip this value if we already decided to skip the parent
@@ -607,8 +606,8 @@ class json_sax_dom_callback_parser
// array
if (ref_stack.back()->is_array())
{
- ref_stack.back()->m_value.array->emplace_back(std::move(value));
- return {true, &(ref_stack.back()->m_value.array->back())};
+ ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
+ return {true, & (ref_stack.back()->m_data.m_value.array->back())};
}
// object
diff --git a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/lexer.hpp b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/lexer.hpp
index 72e9951081..4b3bf77d62 100644
--- a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/lexer.hpp
+++ b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/lexer.hpp
@@ -1,9 +1,9 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#pragma once
@@ -21,6 +21,7 @@
#include <nlohmann/detail/input/input_adapters.hpp>
#include <nlohmann/detail/input/position_t.hpp>
#include <nlohmann/detail/macro_scope.hpp>
+#include <nlohmann/detail/meta/type_traits.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
@@ -115,7 +116,7 @@ class lexer : public lexer_base<BasicJsonType>
using number_float_t = typename BasicJsonType::number_float_t;
using string_t = typename BasicJsonType::string_t;
using char_type = typename InputAdapterType::char_type;
- using char_int_type = typename std::char_traits<char_type>::int_type;
+ using char_int_type = typename char_traits<char_type>::int_type;
public:
using token_type = typename lexer_base<BasicJsonType>::token_type;
@@ -222,7 +223,7 @@ class lexer : public lexer_base<BasicJsonType>
for (auto range = ranges.begin(); range != ranges.end(); ++range)
{
get();
- if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
+ if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) // NOLINT(bugprone-inc-dec-in-conditions)
{
add(current);
}
@@ -265,7 +266,7 @@ class lexer : public lexer_base<BasicJsonType>
switch (get())
{
// end of file while parsing string
- case std::char_traits<char_type>::eof():
+ case char_traits<char_type>::eof():
{
error_message = "invalid string: missing closing quote";
return token_type::parse_error;
@@ -854,7 +855,7 @@ class lexer : public lexer_base<BasicJsonType>
{
case '\n':
case '\r':
- case std::char_traits<char_type>::eof():
+ case char_traits<char_type>::eof():
case '\0':
return true;
@@ -871,7 +872,7 @@ class lexer : public lexer_base<BasicJsonType>
{
switch (get())
{
- case std::char_traits<char_type>::eof():
+ case char_traits<char_type>::eof():
case '\0':
{
error_message = "invalid comment; missing closing '*/'";
@@ -1300,10 +1301,10 @@ scan_number_done:
token_type scan_literal(const char_type* literal_text, const std::size_t length,
token_type return_type)
{
- JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
+ JSON_ASSERT(char_traits<char_type>::to_char_type(current) == literal_text[0]);
for (std::size_t i = 1; i < length; ++i)
{
- if (JSON_HEDLEY_UNLIKELY(std::char_traits<char_type>::to_char_type(get()) != literal_text[i]))
+ if (JSON_HEDLEY_UNLIKELY(char_traits<char_type>::to_char_type(get()) != literal_text[i]))
{
error_message = "invalid literal";
return token_type::parse_error;
@@ -1321,7 +1322,7 @@ scan_number_done:
{
token_buffer.clear();
token_string.clear();
- token_string.push_back(std::char_traits<char_type>::to_char_type(current));
+ token_string.push_back(char_traits<char_type>::to_char_type(current));
}
/*
@@ -1329,7 +1330,7 @@ scan_number_done:
This function provides the interface to the used input adapter. It does
not throw in case the input reached EOF, but returns a
- `std::char_traits<char>::eof()` in that case. Stores the scanned characters
+ `char_traits<char>::eof()` in that case. Stores the scanned characters
for use in error messages.
@return character read from the input
@@ -1349,9 +1350,9 @@ scan_number_done:
current = ia.get_character();
}
- if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
+ if (JSON_HEDLEY_LIKELY(current != char_traits<char_type>::eof()))
{
- token_string.push_back(std::char_traits<char_type>::to_char_type(current));
+ token_string.push_back(char_traits<char_type>::to_char_type(current));
}
if (current == '\n')
@@ -1390,7 +1391,7 @@ scan_number_done:
--position.chars_read_current_line;
}
- if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
+ if (JSON_HEDLEY_LIKELY(current != char_traits<char_type>::eof()))
{
JSON_ASSERT(!token_string.empty());
token_string.pop_back();
@@ -1584,7 +1585,7 @@ scan_number_done:
// end of input (the null byte is needed when parsing from
// string literals)
case '\0':
- case std::char_traits<char_type>::eof():
+ case char_traits<char_type>::eof():
return token_type::end_of_input;
// error
@@ -1602,7 +1603,7 @@ scan_number_done:
const bool ignore_comments = false;
/// the current character
- char_int_type current = std::char_traits<char_type>::eof();
+ char_int_type current = char_traits<char_type>::eof();
/// whether the next get() call should just return current
bool next_unget = false;
diff --git a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/parser.hpp b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/parser.hpp
index 8acbd4fcad..bdf85ba292 100644
--- a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/parser.hpp
+++ b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/parser.hpp
@@ -1,9 +1,9 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#pragma once
@@ -341,13 +341,25 @@ class parser
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr));
}
+ case token_type::end_of_input:
+ {
+ if (JSON_HEDLEY_UNLIKELY(m_lexer.get_position().chars_read_total == 1))
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ "attempting to parse an empty input; check that your input string or stream contains the expected JSON", nullptr));
+ }
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), nullptr));
+ }
case token_type::uninitialized:
case token_type::end_array:
case token_type::end_object:
case token_type::name_separator:
case token_type::value_separator:
- case token_type::end_of_input:
case token_type::literal_or_value:
default: // the last token was unexpected
{
diff --git a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/position_t.hpp b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/position_t.hpp
index 396db0e16b..8ac7c78cfd 100644
--- a/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/position_t.hpp
+++ b/contrib/restricted/nlohmann_json/include/nlohmann/detail/input/position_t.hpp
@@ -1,9 +1,9 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
-// | | |__ | | | | | | version 3.11.2
+// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
-// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
+// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#pragma once