From e5275e30efc1a4f991fd6bd087bcf643a119a515 Mon Sep 17 00:00:00 2001 From: Kevin Xu Date: Mon, 6 Dec 2021 15:23:45 -0500 Subject: [PATCH] make LexerType template arg --- include/nlohmann/detail/input/parser.hpp | 4 ++-- include/nlohmann/detail/macro_scope.hpp | 5 +++-- include/nlohmann/json.hpp | 6 +++--- include/nlohmann/json_fwd.hpp | 9 ++++++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index 99cdd05ec..70ea6cdb7 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -48,14 +48,14 @@ using parser_callback_t = This class implements a recursive descent parser. */ -template +template class LexerType, typename BasicJsonType, typename InputAdapterType> class parser { using number_integer_t = typename BasicJsonType::number_integer_t; using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; - using lexer_t = lexer; + using lexer_t = LexerType; using token_type = typename lexer_t::token_type; public: diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index c2a65bdda..ee5519b76 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -132,12 +132,13 @@ class NumberUnsignedType, class NumberFloatType, \ template class AllocatorType, \ template class JSONSerializer, \ - class BinaryType> + class BinaryType, \ + template class LexerType> #define NLOHMANN_BASIC_JSON_TPL \ basic_json + AllocatorType, JSONSerializer, BinaryType, LexerType> // Macros to simplify conversion from/to types diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 7ea86c38c..318da5e28 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -199,17 +199,17 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec JSON_PRIVATE_UNLESS_TESTED: // convenience aliases for types residing in namespace detail; - using lexer = ::nlohmann::detail::lexer_base; + // using lexer = ::nlohmann::detail::lexer_base; template - static ::nlohmann::detail::parser parser( + static ::nlohmann::detail::parser parser( InputAdapterType adapter, detail::parser_callback_tcb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false ) { - return ::nlohmann::detail::parser(std::move(adapter), + return ::nlohmann::detail::parser(std::move(adapter), std::move(cb), allow_exceptions, ignore_comments); } diff --git a/include/nlohmann/json_fwd.hpp b/include/nlohmann/json_fwd.hpp index 332227c1b..dead19b0d 100644 --- a/include/nlohmann/json_fwd.hpp +++ b/include/nlohmann/json_fwd.hpp @@ -24,6 +24,12 @@ for serialization. template struct adl_serializer; +namespace detail +{ +template +class lexer; +} + template class ObjectType = std::map, template class ArrayType = std::vector, @@ -34,7 +40,8 @@ template class ObjectType = template class AllocatorType = std::allocator, template class JSONSerializer = adl_serializer, - class BinaryType = std::vector> + class BinaryType = std::vector, + template class LexerType = detail::lexer> class basic_json; /*!