🔨 split "parsing" directory to "input" and "output"
This commit is contained in:
parent
05f49fa401
commit
6855bbb902
10 changed files with 102 additions and 103 deletions
28
Makefile
28
Makefile
|
@ -2,28 +2,28 @@
|
||||||
|
|
||||||
SRCS = develop/json.hpp \
|
SRCS = develop/json.hpp \
|
||||||
develop/json_fwd.hpp \
|
develop/json_fwd.hpp \
|
||||||
develop/detail/macro_scope.hpp \
|
develop/adl_serializer.hpp \
|
||||||
develop/detail/macro_unscope.hpp \
|
|
||||||
develop/detail/meta.hpp \
|
|
||||||
develop/detail/exceptions.hpp \
|
|
||||||
develop/detail/value_t.hpp \
|
|
||||||
develop/detail/conversions/from_json.hpp \
|
develop/detail/conversions/from_json.hpp \
|
||||||
develop/detail/conversions/to_chars.hpp \
|
develop/detail/conversions/to_chars.hpp \
|
||||||
develop/detail/conversions/to_json.hpp \
|
develop/detail/conversions/to_json.hpp \
|
||||||
develop/detail/parsing/input_adapters.hpp \
|
develop/detail/exceptions.hpp \
|
||||||
develop/detail/parsing/lexer.hpp \
|
develop/detail/input/binary_reader.hpp \
|
||||||
develop/detail/parsing/parser.hpp \
|
develop/detail/input/input_adapters.hpp \
|
||||||
develop/detail/iterators/primitive_iterator.hpp \
|
develop/detail/input/lexer.hpp \
|
||||||
|
develop/detail/input/parser.hpp \
|
||||||
develop/detail/iterators/internal_iterator.hpp \
|
develop/detail/iterators/internal_iterator.hpp \
|
||||||
develop/detail/iterators/iter_impl.hpp \
|
develop/detail/iterators/iter_impl.hpp \
|
||||||
develop/detail/iterators/iteration_proxy.hpp \
|
develop/detail/iterators/iteration_proxy.hpp \
|
||||||
develop/detail/iterators/json_reverse_iterator.hpp \
|
develop/detail/iterators/json_reverse_iterator.hpp \
|
||||||
develop/detail/parsing/output_adapters.hpp \
|
develop/detail/iterators/primitive_iterator.hpp \
|
||||||
develop/detail/parsing/binary_reader.hpp \
|
|
||||||
develop/detail/parsing/binary_writer.hpp \
|
|
||||||
develop/detail/serializer.hpp \
|
|
||||||
develop/detail/json_ref.hpp \
|
develop/detail/json_ref.hpp \
|
||||||
develop/adl_serializer.hpp
|
develop/detail/macro_scope.hpp \
|
||||||
|
develop/detail/macro_unscope.hpp \
|
||||||
|
develop/detail/meta.hpp \
|
||||||
|
develop/detail/output/binary_writer.hpp \
|
||||||
|
develop/detail/output/output_adapters.hpp \
|
||||||
|
develop/detail/output/serializer.hpp \
|
||||||
|
develop/detail/value_t.hpp
|
||||||
|
|
||||||
UNAME = $(shell uname)
|
UNAME = $(shell uname)
|
||||||
CXX=clang++
|
CXX=clang++
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include "detail/exceptions.hpp"
|
#include "detail/exceptions.hpp"
|
||||||
#include "detail/macro_scope.hpp"
|
#include "detail/macro_scope.hpp"
|
||||||
#include "detail/parsing/input_adapters.hpp"
|
|
||||||
#include "detail/value_t.hpp"
|
#include "detail/value_t.hpp"
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
|
@ -64,7 +63,7 @@ class binary_reader
|
||||||
if (strict)
|
if (strict)
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof(true);
|
expect_eof();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +84,7 @@ class binary_reader
|
||||||
if (strict)
|
if (strict)
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof(true);
|
expect_eof();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +105,7 @@ class binary_reader
|
||||||
if (strict)
|
if (strict)
|
||||||
{
|
{
|
||||||
get_ignore_noop();
|
get_ignore_noop();
|
||||||
check_eof(true);
|
expect_eof();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +204,6 @@ class binary_reader
|
||||||
|
|
||||||
case 0x38: // Negative integer (one-byte uint8_t follows)
|
case 0x38: // Negative integer (one-byte uint8_t follows)
|
||||||
{
|
{
|
||||||
// must be uint8_t !
|
|
||||||
return static_cast<number_integer_t>(-1) - get_number<uint8_t>();
|
return static_cast<number_integer_t>(-1) - get_number<uint8_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,9 +394,9 @@ class binary_reader
|
||||||
case 0xF9: // Half-Precision Float (two-byte IEEE 754)
|
case 0xF9: // Half-Precision Float (two-byte IEEE 754)
|
||||||
{
|
{
|
||||||
const int byte1 = get();
|
const int byte1 = get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
const int byte2 = get();
|
const int byte2 = get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
// code from RFC 7049, Appendix D, Figure 3:
|
// code from RFC 7049, Appendix D, Figure 3:
|
||||||
// As half-precision floating-point numbers were only added
|
// As half-precision floating-point numbers were only added
|
||||||
|
@ -831,7 +829,7 @@ class binary_reader
|
||||||
for (std::size_t i = 0; i < sizeof(NumberType); ++i)
|
for (std::size_t i = 0; i < sizeof(NumberType); ++i)
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
// reverse byte order prior to conversion if necessary
|
// reverse byte order prior to conversion if necessary
|
||||||
if (is_little_endian)
|
if (is_little_endian)
|
||||||
|
@ -856,7 +854,7 @@ class binary_reader
|
||||||
@param[in] len number of bytes to read
|
@param[in] len number of bytes to read
|
||||||
|
|
||||||
@note We can not reserve @a len bytes for the result, because @a len
|
@note We can not reserve @a len bytes for the result, because @a len
|
||||||
may be too large. Usually, @ref check_eof() detects the end of
|
may be too large. Usually, @ref unexpect_eof() detects the end of
|
||||||
the input before we run out of string memory.
|
the input before we run out of string memory.
|
||||||
|
|
||||||
@return string created by reading @a len bytes
|
@return string created by reading @a len bytes
|
||||||
|
@ -870,7 +868,7 @@ class binary_reader
|
||||||
std::generate_n(std::back_inserter(result), len, [this]()
|
std::generate_n(std::back_inserter(result), len, [this]()
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
return static_cast<char>(current);
|
return static_cast<char>(current);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
@ -890,7 +888,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
std::string get_cbor_string()
|
std::string get_cbor_string()
|
||||||
{
|
{
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
|
@ -948,7 +946,7 @@ class binary_reader
|
||||||
std::string result;
|
std::string result;
|
||||||
while (get() != 0xFF)
|
while (get() != 0xFF)
|
||||||
{
|
{
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
result.push_back(static_cast<char>(current));
|
result.push_back(static_cast<char>(current));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1003,7 +1001,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
std::string get_msgpack_string()
|
std::string get_msgpack_string()
|
||||||
{
|
{
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
|
@ -1119,7 +1117,7 @@ class binary_reader
|
||||||
get(); // TODO: may we ignore N here?
|
get(); // TODO: may we ignore N here?
|
||||||
}
|
}
|
||||||
|
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
|
@ -1159,7 +1157,7 @@ class binary_reader
|
||||||
if (current == '$')
|
if (current == '$')
|
||||||
{
|
{
|
||||||
tc = get(); // must not ignore 'N', because 'N' maybe the type
|
tc = get(); // must not ignore 'N', because 'N' maybe the type
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
get_ignore_noop();
|
get_ignore_noop();
|
||||||
if (current != '#')
|
if (current != '#')
|
||||||
|
@ -1212,7 +1210,7 @@ class binary_reader
|
||||||
case 'C': // char
|
case 'C': // char
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
if (JSON_UNLIKELY(current > 127))
|
if (JSON_UNLIKELY(current > 127))
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -1321,26 +1319,28 @@ class binary_reader
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief check if input ended
|
@brief throw if end of input is not reached
|
||||||
@throw parse_error.110 if input ended
|
@throw parse_error.110 if input not ended
|
||||||
*/
|
*/
|
||||||
void check_eof(const bool expect_eof = false) const
|
void expect_eof() const
|
||||||
{
|
|
||||||
if (expect_eof)
|
|
||||||
{
|
{
|
||||||
if (JSON_UNLIKELY(current != std::char_traits<char>::eof()))
|
if (JSON_UNLIKELY(current != std::char_traits<char>::eof()))
|
||||||
{
|
{
|
||||||
JSON_THROW(parse_error::create(110, chars_read, "expected end of input"));
|
JSON_THROW(parse_error::create(110, chars_read, "expected end of input"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/*!
|
||||||
|
@briefthrow if end of input is reached
|
||||||
|
@throw parse_error.110 if input ended
|
||||||
|
*/
|
||||||
|
void unexpect_eof() const
|
||||||
{
|
{
|
||||||
if (JSON_UNLIKELY(current == std::char_traits<char>::eof()))
|
if (JSON_UNLIKELY(current == std::char_traits<char>::eof()))
|
||||||
{
|
{
|
||||||
JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input"));
|
JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// input adapter
|
/// input adapter
|
|
@ -11,7 +11,7 @@
|
||||||
#include <vector> // vector
|
#include <vector> // vector
|
||||||
|
|
||||||
#include "detail/macro_scope.hpp"
|
#include "detail/macro_scope.hpp"
|
||||||
#include "detail/parsing/input_adapters.hpp"
|
#include "detail/input/input_adapters.hpp"
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
{
|
{
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include "detail/exceptions.hpp"
|
#include "detail/exceptions.hpp"
|
||||||
#include "detail/macro_scope.hpp"
|
#include "detail/macro_scope.hpp"
|
||||||
#include "detail/parsing/input_adapters.hpp"
|
#include "detail/input/input_adapters.hpp"
|
||||||
#include "detail/parsing/lexer.hpp"
|
#include "detail/input/lexer.hpp"
|
||||||
#include "detail/value_t.hpp"
|
#include "detail/value_t.hpp"
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
|
@ -6,8 +6,8 @@
|
||||||
#include <cstring> // memcpy
|
#include <cstring> // memcpy
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
|
|
||||||
#include "detail/parsing/binary_reader.hpp"
|
#include "detail/input/binary_reader.hpp"
|
||||||
#include "detail/parsing/output_adapters.hpp"
|
#include "detail/output/output_adapters.hpp"
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
{
|
{
|
|
@ -17,7 +17,7 @@
|
||||||
#include "detail/conversions/to_chars.hpp"
|
#include "detail/conversions/to_chars.hpp"
|
||||||
#include "detail/macro_scope.hpp"
|
#include "detail/macro_scope.hpp"
|
||||||
#include "detail/meta.hpp"
|
#include "detail/meta.hpp"
|
||||||
#include "detail/parsing/output_adapters.hpp"
|
#include "detail/output/output_adapters.hpp"
|
||||||
#include "detail/value_t.hpp"
|
#include "detail/value_t.hpp"
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
|
@ -48,18 +48,18 @@ SOFTWARE.
|
||||||
#include "detail/value_t.hpp"
|
#include "detail/value_t.hpp"
|
||||||
#include "detail/conversions/from_json.hpp"
|
#include "detail/conversions/from_json.hpp"
|
||||||
#include "detail/conversions/to_json.hpp"
|
#include "detail/conversions/to_json.hpp"
|
||||||
#include "detail/parsing/input_adapters.hpp"
|
#include "detail/input/input_adapters.hpp"
|
||||||
#include "detail/parsing/lexer.hpp"
|
#include "detail/input/lexer.hpp"
|
||||||
#include "detail/parsing/parser.hpp"
|
#include "detail/input/parser.hpp"
|
||||||
#include "detail/iterators/primitive_iterator.hpp"
|
#include "detail/iterators/primitive_iterator.hpp"
|
||||||
#include "detail/iterators/internal_iterator.hpp"
|
#include "detail/iterators/internal_iterator.hpp"
|
||||||
#include "detail/iterators/iter_impl.hpp"
|
#include "detail/iterators/iter_impl.hpp"
|
||||||
#include "detail/iterators/iteration_proxy.hpp"
|
#include "detail/iterators/iteration_proxy.hpp"
|
||||||
#include "detail/iterators/json_reverse_iterator.hpp"
|
#include "detail/iterators/json_reverse_iterator.hpp"
|
||||||
#include "detail/parsing/output_adapters.hpp"
|
#include "detail/output/output_adapters.hpp"
|
||||||
#include "detail/parsing/binary_reader.hpp"
|
#include "detail/input/binary_reader.hpp"
|
||||||
#include "detail/parsing/binary_writer.hpp"
|
#include "detail/output/binary_writer.hpp"
|
||||||
#include "detail/serializer.hpp"
|
#include "detail/output/serializer.hpp"
|
||||||
#include "detail/json_ref.hpp"
|
#include "detail/json_ref.hpp"
|
||||||
#include "adl_serializer.hpp"
|
#include "adl_serializer.hpp"
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class json_pointer
|
||||||
*/
|
*/
|
||||||
static int array_index(const std::string& s)
|
static int array_index(const std::string& s)
|
||||||
{
|
{
|
||||||
size_t processed_chars = 0;
|
std::size_t processed_chars = 0;
|
||||||
const int res = std::stoi(s, &processed_chars);
|
const int res = std::stoi(s, &processed_chars);
|
||||||
|
|
||||||
// check if the string was completely read
|
// check if the string was completely read
|
||||||
|
|
75
src/json.hpp
75
src/json.hpp
|
@ -1543,7 +1543,7 @@ constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "detail/parsing/input_adapters.hpp"
|
// #include "detail/input/input_adapters.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm> // min
|
#include <algorithm> // min
|
||||||
|
@ -1808,7 +1808,7 @@ class input_adapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "detail/parsing/lexer.hpp"
|
// #include "detail/input/lexer.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <clocale> // localeconv
|
#include <clocale> // localeconv
|
||||||
|
@ -1823,7 +1823,7 @@ class input_adapter
|
||||||
|
|
||||||
// #include "detail/macro_scope.hpp"
|
// #include "detail/macro_scope.hpp"
|
||||||
|
|
||||||
// #include "detail/parsing/input_adapters.hpp"
|
// #include "detail/input/input_adapters.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
|
@ -3088,7 +3088,7 @@ scan_number_done:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "detail/parsing/parser.hpp"
|
// #include "detail/input/parser.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <cassert> // assert
|
#include <cassert> // assert
|
||||||
|
@ -3102,9 +3102,9 @@ scan_number_done:
|
||||||
|
|
||||||
// #include "detail/macro_scope.hpp"
|
// #include "detail/macro_scope.hpp"
|
||||||
|
|
||||||
// #include "detail/parsing/input_adapters.hpp"
|
// #include "detail/input/input_adapters.hpp"
|
||||||
|
|
||||||
// #include "detail/parsing/lexer.hpp"
|
// #include "detail/input/lexer.hpp"
|
||||||
|
|
||||||
// #include "detail/value_t.hpp"
|
// #include "detail/value_t.hpp"
|
||||||
|
|
||||||
|
@ -4678,7 +4678,7 @@ class json_reverse_iterator : public std::reverse_iterator<Base>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "detail/parsing/output_adapters.hpp"
|
// #include "detail/output/output_adapters.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm> // copy
|
#include <algorithm> // copy
|
||||||
|
@ -4793,7 +4793,7 @@ class output_adapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "detail/parsing/binary_reader.hpp"
|
// #include "detail/input/binary_reader.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm> // generate_n
|
#include <algorithm> // generate_n
|
||||||
|
@ -4815,8 +4815,6 @@ class output_adapter
|
||||||
|
|
||||||
// #include "detail/macro_scope.hpp"
|
// #include "detail/macro_scope.hpp"
|
||||||
|
|
||||||
// #include "detail/parsing/input_adapters.hpp"
|
|
||||||
|
|
||||||
// #include "detail/value_t.hpp"
|
// #include "detail/value_t.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -4864,7 +4862,7 @@ class binary_reader
|
||||||
if (strict)
|
if (strict)
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof(true);
|
expect_eof();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -4885,7 +4883,7 @@ class binary_reader
|
||||||
if (strict)
|
if (strict)
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof(true);
|
expect_eof();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -4906,7 +4904,7 @@ class binary_reader
|
||||||
if (strict)
|
if (strict)
|
||||||
{
|
{
|
||||||
get_ignore_noop();
|
get_ignore_noop();
|
||||||
check_eof(true);
|
expect_eof();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -5005,7 +5003,6 @@ class binary_reader
|
||||||
|
|
||||||
case 0x38: // Negative integer (one-byte uint8_t follows)
|
case 0x38: // Negative integer (one-byte uint8_t follows)
|
||||||
{
|
{
|
||||||
// must be uint8_t !
|
|
||||||
return static_cast<number_integer_t>(-1) - get_number<uint8_t>();
|
return static_cast<number_integer_t>(-1) - get_number<uint8_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5196,9 +5193,9 @@ class binary_reader
|
||||||
case 0xF9: // Half-Precision Float (two-byte IEEE 754)
|
case 0xF9: // Half-Precision Float (two-byte IEEE 754)
|
||||||
{
|
{
|
||||||
const int byte1 = get();
|
const int byte1 = get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
const int byte2 = get();
|
const int byte2 = get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
// code from RFC 7049, Appendix D, Figure 3:
|
// code from RFC 7049, Appendix D, Figure 3:
|
||||||
// As half-precision floating-point numbers were only added
|
// As half-precision floating-point numbers were only added
|
||||||
|
@ -5631,7 +5628,7 @@ class binary_reader
|
||||||
for (std::size_t i = 0; i < sizeof(NumberType); ++i)
|
for (std::size_t i = 0; i < sizeof(NumberType); ++i)
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
// reverse byte order prior to conversion if necessary
|
// reverse byte order prior to conversion if necessary
|
||||||
if (is_little_endian)
|
if (is_little_endian)
|
||||||
|
@ -5656,7 +5653,7 @@ class binary_reader
|
||||||
@param[in] len number of bytes to read
|
@param[in] len number of bytes to read
|
||||||
|
|
||||||
@note We can not reserve @a len bytes for the result, because @a len
|
@note We can not reserve @a len bytes for the result, because @a len
|
||||||
may be too large. Usually, @ref check_eof() detects the end of
|
may be too large. Usually, @ref unexpect_eof() detects the end of
|
||||||
the input before we run out of string memory.
|
the input before we run out of string memory.
|
||||||
|
|
||||||
@return string created by reading @a len bytes
|
@return string created by reading @a len bytes
|
||||||
|
@ -5670,7 +5667,7 @@ class binary_reader
|
||||||
std::generate_n(std::back_inserter(result), len, [this]()
|
std::generate_n(std::back_inserter(result), len, [this]()
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
return static_cast<char>(current);
|
return static_cast<char>(current);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
@ -5690,7 +5687,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
std::string get_cbor_string()
|
std::string get_cbor_string()
|
||||||
{
|
{
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
|
@ -5748,7 +5745,7 @@ class binary_reader
|
||||||
std::string result;
|
std::string result;
|
||||||
while (get() != 0xFF)
|
while (get() != 0xFF)
|
||||||
{
|
{
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
result.push_back(static_cast<char>(current));
|
result.push_back(static_cast<char>(current));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -5803,7 +5800,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
std::string get_msgpack_string()
|
std::string get_msgpack_string()
|
||||||
{
|
{
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
|
@ -5919,7 +5916,7 @@ class binary_reader
|
||||||
get(); // TODO: may we ignore N here?
|
get(); // TODO: may we ignore N here?
|
||||||
}
|
}
|
||||||
|
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
switch (current)
|
switch (current)
|
||||||
{
|
{
|
||||||
|
@ -5959,7 +5956,7 @@ class binary_reader
|
||||||
if (current == '$')
|
if (current == '$')
|
||||||
{
|
{
|
||||||
tc = get(); // must not ignore 'N', because 'N' maybe the type
|
tc = get(); // must not ignore 'N', because 'N' maybe the type
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
|
|
||||||
get_ignore_noop();
|
get_ignore_noop();
|
||||||
if (current != '#')
|
if (current != '#')
|
||||||
|
@ -6012,7 +6009,7 @@ class binary_reader
|
||||||
case 'C': // char
|
case 'C': // char
|
||||||
{
|
{
|
||||||
get();
|
get();
|
||||||
check_eof();
|
unexpect_eof();
|
||||||
if (JSON_UNLIKELY(current > 127))
|
if (JSON_UNLIKELY(current > 127))
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -6121,26 +6118,28 @@ class binary_reader
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief check if input ended
|
@brief throw if end of input is not reached
|
||||||
@throw parse_error.110 if input ended
|
@throw parse_error.110 if input not ended
|
||||||
*/
|
*/
|
||||||
void check_eof(const bool expect_eof = false) const
|
void expect_eof() const
|
||||||
{
|
|
||||||
if (expect_eof)
|
|
||||||
{
|
{
|
||||||
if (JSON_UNLIKELY(current != std::char_traits<char>::eof()))
|
if (JSON_UNLIKELY(current != std::char_traits<char>::eof()))
|
||||||
{
|
{
|
||||||
JSON_THROW(parse_error::create(110, chars_read, "expected end of input"));
|
JSON_THROW(parse_error::create(110, chars_read, "expected end of input"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/*!
|
||||||
|
@briefthrow if end of input is reached
|
||||||
|
@throw parse_error.110 if input ended
|
||||||
|
*/
|
||||||
|
void unexpect_eof() const
|
||||||
{
|
{
|
||||||
if (JSON_UNLIKELY(current == std::char_traits<char>::eof()))
|
if (JSON_UNLIKELY(current == std::char_traits<char>::eof()))
|
||||||
{
|
{
|
||||||
JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input"));
|
JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// input adapter
|
/// input adapter
|
||||||
|
@ -6158,7 +6157,7 @@ class binary_reader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "detail/parsing/binary_writer.hpp"
|
// #include "detail/output/binary_writer.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm> // reverse
|
#include <algorithm> // reverse
|
||||||
|
@ -6167,9 +6166,9 @@ class binary_reader
|
||||||
#include <cstring> // memcpy
|
#include <cstring> // memcpy
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
|
|
||||||
// #include "detail/parsing/binary_reader.hpp"
|
// #include "detail/input/binary_reader.hpp"
|
||||||
|
|
||||||
// #include "detail/parsing/output_adapters.hpp"
|
// #include "detail/output/output_adapters.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
|
@ -7070,7 +7069,7 @@ class binary_writer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include "detail/serializer.hpp"
|
// #include "detail/output/serializer.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm> // reverse, remove, fill, find, none_of
|
#include <algorithm> // reverse, remove, fill, find, none_of
|
||||||
|
@ -8186,7 +8185,7 @@ char* to_chars(char* first, char* last, FloatType value)
|
||||||
|
|
||||||
// #include "detail/meta.hpp"
|
// #include "detail/meta.hpp"
|
||||||
|
|
||||||
// #include "detail/parsing/output_adapters.hpp"
|
// #include "detail/output/output_adapters.hpp"
|
||||||
|
|
||||||
// #include "detail/value_t.hpp"
|
// #include "detail/value_t.hpp"
|
||||||
|
|
||||||
|
@ -8993,7 +8992,7 @@ class json_pointer
|
||||||
*/
|
*/
|
||||||
static int array_index(const std::string& s)
|
static int array_index(const std::string& s)
|
||||||
{
|
{
|
||||||
size_t processed_chars = 0;
|
std::size_t processed_chars = 0;
|
||||||
const int res = std::stoi(s, &processed_chars);
|
const int res = std::stoi(s, &processed_chars);
|
||||||
|
|
||||||
// check if the string was completely read
|
// check if the string was completely read
|
||||||
|
|
Loading…
Reference in a new issue