Skip to content

Commit

Permalink
Merge cf81aa7 into fac07e2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfishgait1234 committed Sep 29, 2023
2 parents fac07e2 + cf81aa7 commit 7637dfc
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6903,7 +6903,10 @@ class json_sax_dom_parser
/// the parsed JSON value
BasicJsonType& root;
/// stack to model hierarchy of values
std::vector<BasicJsonType*> ref_stack {};


using allocator_type = typename BasicJsonType::allocator_type;
std::vector<BasicJsonType*,allocator_type> ref_stack {};
/// helper to hold the reference for the next object element
BasicJsonType* object_element = nullptr;
/// whether a syntax error occurred
Expand Down Expand Up @@ -8915,8 +8918,10 @@ class lexer : public lexer_base<BasicJsonType>
position_t position {};

/// raw input token string (for error messages)
std::vector<char_type> token_string {};

using allocator_type = typename BasicJsonType::allocator_type;

std::vector<char_type,allocator_type> token_string {};
/// buffer for variable-length tokens (numbers, strings)
string_t token_buffer {};

Expand Down Expand Up @@ -11791,7 +11796,7 @@ class binary_reader
case token_type::value_unsigned:
return sax->number_unsigned(number_lexer.get_number_unsigned());
case token_type::value_float:
return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
return sax->number_float(number_lexer.get_number_float(), std::move(static_cast<string_t>(number_string)));
case token_type::uninitialized:
case token_type::literal_true:
case token_type::literal_false:
Expand Down Expand Up @@ -12165,7 +12170,7 @@ class parser
using string_t = typename BasicJsonType::string_t;
using lexer_t = lexer<BasicJsonType, InputAdapterType>;
using token_type = typename lexer_t::token_type;

using allocator_type = typename BasicJsonType::string_t::allocator_type;
public:
/// a parser reading from an input adapter
explicit parser(InputAdapterType&& adapter,
Expand Down Expand Up @@ -12279,9 +12284,10 @@ class parser
JSON_HEDLEY_NON_NULL(2)
bool sax_parse_internal(SAX* sax)
{
using allocator_type = typename BasicJsonType::allocator_type;
// stack to remember the hierarchy of structured values we are parsing
// true = array; false = object
std::vector<bool> states;
std::vector<bool,allocator_type> states;
// value to avoid a goto (see comment where set to true)
bool skip_to_state_evaluation = false;

Expand Down Expand Up @@ -14950,7 +14956,10 @@ class output_adapter
public:
template<typename AllocatorType = std::allocator<CharType>>
output_adapter(std::vector<CharType, AllocatorType>& vec)
: oa(std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
{
AllocatorType alloc;
oa = std::allocate_shared<output_vector_adapter<CharType, AllocatorType>>(alloc ,vec);
}

#ifndef JSON_NO_IO
output_adapter(std::basic_ostream<CharType>& s)
Expand Down Expand Up @@ -16061,7 +16070,7 @@ class binary_writer

const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast<std::size_t>(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el)
{
return result + calc_bson_element_size(std::to_string(array_index++), el);
return result + calc_bson_element_size(static_cast<string_t>(std::to_string(array_index++)), el);
});

return sizeof(std::int32_t) + embedded_document_size + 1ul;
Expand All @@ -16088,7 +16097,7 @@ class binary_writer

for (const auto& el : value)
{
write_bson_element(std::to_string(array_index++), el);
write_bson_element(static_cast<string_t>(std::to_string(array_index++)), el);
}

oa->write_character(to_char_type(0x00));
Expand Down Expand Up @@ -19780,7 +19789,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
if (t == value_t::array || t == value_t::object)
{
// flatten the current json_value to a heap-allocated stack
std::vector<basic_json> stack;
std::vector<basic_json,AllocatorType<basic_json>> stack;

// move the top-level items to stack
if (t == value_t::array)
Expand Down

0 comments on commit 7637dfc

Please sign in to comment.