From 1eead99b5651d30c80607d51229d472c01ee1c40 Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Wed, 8 Nov 2023 12:54:27 -0500 Subject: [PATCH] basic_json_location --- include/jsoncons_ext/jsonpath/expression.hpp | 12 +++++------ .../jsoncons_ext/jsonpath/json_location.hpp | 20 ++++++++++--------- .../jsonpath/jsonpath_expression.hpp | 6 +++--- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/jsoncons_ext/jsonpath/expression.hpp b/include/jsoncons_ext/jsonpath/expression.hpp index 3170c7c3d3..e8e59760a7 100644 --- a/include/jsoncons_ext/jsonpath/expression.hpp +++ b/include/jsoncons_ext/jsonpath/expression.hpp @@ -2070,7 +2070,7 @@ namespace detail { using reference = JsonReference; using value_pointer = typename std::conditional::type>::value,typename Json::const_pointer,typename Json::pointer>::type; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using path_pointer = const path_node_type*; json_location_type path_; @@ -2131,7 +2131,7 @@ namespace detail { using reference = JsonReference; using value_pointer = typename std::conditional::type>::value,typename Json::const_pointer,typename Json::pointer>::type; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using path_pointer = const path_node_type*; private: const path_node_type* last_ptr_; @@ -2177,7 +2177,7 @@ namespace detail { using char_type = typename Json::char_type; using string_type = typename Json::string_type; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using path_value_pair_type = path_value_pair; allocator_type alloc_; @@ -2320,7 +2320,7 @@ namespace detail { using pointer = typename std::conditional::type>::value,typename Json::const_pointer,typename Json::pointer>::type; using path_value_pair_type = path_value_pair; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using node_receiver_type = node_receiver; using selector_type = jsonpath_selector; @@ -3005,7 +3005,7 @@ namespace detail { using char_type = typename Json::char_type; using string_type = typename Json::string_type; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; private: allocator_type alloc_; Callback& callback_; @@ -3041,7 +3041,7 @@ namespace detail { using reference_arg_type = typename std::conditional::type>::value, const_reference_arg_t,reference_arg_t>::type; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using selector_type = jsonpath_selector; private: allocator_type alloc_; diff --git a/include/jsoncons_ext/jsonpath/json_location.hpp b/include/jsoncons_ext/jsonpath/json_location.hpp index b8f56f9eec..07bdd089cb 100644 --- a/include/jsoncons_ext/jsonpath/json_location.hpp +++ b/include/jsoncons_ext/jsonpath/json_location.hpp @@ -20,7 +20,7 @@ namespace jsoncons { namespace jsonpath { - template + template class basic_json_location; enum class path_node_kind { root, index, name }; @@ -28,7 +28,7 @@ namespace jsonpath { template class path_node { - template friend class basic_json_location; + template friend class basic_json_location; public: using string_view_type = jsoncons::basic_string_view; using char_type = CharT; @@ -316,13 +316,15 @@ namespace jsonpath { } // namespace detail - template + template > class basic_json_location { public: - using allocator_type = typename Json::allocator_type; - using string_type = typename Json::string_type; - using path_node_type = path_node; + using char_type = CharT; + using allocator_type = Allocator; + using char_allocator_type = typename std::allocator_traits:: template rebind_alloc; + using string_type = std::basic_string,char_allocator_type>; + using path_node_type = path_node; private: allocator_type alloc_; std::vector nodes_; @@ -454,7 +456,7 @@ namespace jsonpath { }; template - Json* select(Json& root, const basic_json_location::type>& path) + Json* select(Json& root, const basic_json_location& path) { Json* current = std::addressof(root); for (const auto& path_node : path) @@ -484,8 +486,8 @@ namespace jsonpath { return current; } - using json_location = basic_json_location; - using wjson_location = basic_json_location; + using json_location = basic_json_location; + using wjson_location = basic_json_location; } // namespace jsonpath } // namespace jsoncons diff --git a/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp b/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp index 31cbb5190d..ab5f6788a3 100644 --- a/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp +++ b/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp @@ -111,7 +111,7 @@ namespace detail { using token_type = token; using path_expression_type = path_expression; using expression_type = expression; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using path_node_type = path_node; using selector_type = jsonpath_selector; @@ -2497,7 +2497,7 @@ namespace detail { using allocator_type = typename value_type::allocator_type; using evaluator_type = typename jsoncons::jsonpath::detail::jsonpath_evaluator; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using path_expression_type = jsoncons::jsonpath::detail::path_expression; using path_pointer = const path_node_type*; }; @@ -2516,7 +2516,7 @@ namespace detail { using allocator_type = typename value_type::allocator_type; using evaluator_type = typename jsoncons::jsonpath::detail::jsonpath_evaluator; using path_node_type = path_node; - using json_location_type = basic_json_location; + using json_location_type = basic_json_location; using path_expression_type = jsoncons::jsonpath::detail::path_expression; using path_pointer = const path_node_type*; };