From 510d6cd5ae1ee086ca3562c88f358e45ceed717c Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Tue, 7 Nov 2023 18:56:05 -0500 Subject: [PATCH] path_node w string_view --- include/jsoncons_ext/jsonpath/expression.hpp | 22 +++++++++---------- .../jsoncons_ext/jsonpath/json_location.hpp | 11 +++++----- .../jsonpath/jsonpath_expression.hpp | 6 ++--- .../jsonpath/jsonpath_selector.hpp | 4 ++-- test/jsonpath/src/json_location_tests.cpp | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/jsoncons_ext/jsonpath/expression.hpp b/include/jsoncons_ext/jsonpath/expression.hpp index 5c623616cb..87b252efec 100644 --- a/include/jsoncons_ext/jsonpath/expression.hpp +++ b/include/jsoncons_ext/jsonpath/expression.hpp @@ -2069,7 +2069,7 @@ namespace detail { using value_type = Json; 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 path_node_type = path_node; using json_location_type = json_location; using path_pointer = const path_node_type*; @@ -2130,7 +2130,7 @@ namespace detail { using value_type = Json; 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 path_node_type = path_node; using json_location_type = json_location; using path_pointer = const path_node_type*; private: @@ -2160,7 +2160,7 @@ namespace detail { using char_type = typename Json::char_type; using string_type = typename Json::string_type; using reference = JsonReference; - using path_node_type = path_node; + using path_node_type = path_node; virtual ~node_receiver() noexcept = default; @@ -2176,7 +2176,7 @@ namespace detail { using reference = JsonReference; using char_type = typename Json::char_type; using string_type = typename Json::string_type; - using path_node_type = path_node; + using path_node_type = path_node; using json_location_type = json_location; using path_value_pair_type = path_value_pair; @@ -2202,7 +2202,7 @@ namespace detail { using reference = JsonReference; using char_type = typename Json::char_type; using string_type = typename Json::string_type; - using path_node_type = path_node; + using path_node_type = path_node; using path_stem_value_pair_type = path_component_value_pair; std::vector nodes; @@ -2222,7 +2222,7 @@ namespace detail { using string_type = typename Json::string_type; using reference = JsonReference; using pointer = typename std::conditional::type>::value,typename Json::const_pointer,typename Json::pointer>::type; - using path_node_type = path_node; + using path_node_type = path_node; using path_stem_value_pair_type = path_component_value_pair; allocator_type alloc_; @@ -2319,7 +2319,7 @@ namespace detail { using reference = JsonReference; 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 path_node_type = path_node; using json_location_type = json_location; using node_receiver_type = node_receiver; using selector_type = jsonpath_selector; @@ -2623,7 +2623,7 @@ namespace detail { using reference = JsonReference; 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 path_node_type = path_node; virtual ~expression_base() noexcept = default; @@ -3004,7 +3004,7 @@ namespace detail { using reference = JsonReference; using char_type = typename Json::char_type; using string_type = typename Json::string_type; - using path_node_type = path_node; + using path_node_type = path_node; using json_location_type = json_location; private: allocator_type alloc_; @@ -3040,7 +3040,7 @@ namespace detail { using token_type = token; using reference_arg_type = typename std::conditional::type>::value, const_reference_arg_t,reference_arg_t>::type; - using path_node_type = path_node; + using path_node_type = path_node; using json_location_type = json_location; using selector_type = jsonpath_selector; private: @@ -3238,7 +3238,7 @@ namespace detail { using token_type = token; using reference_arg_type = typename std::conditional::type>::value, const_reference_arg_t,reference_arg_t>::type; - using path_node_type = path_node; + using path_node_type = path_node; using stack_item_type = value_or_pointer; private: std::vector token_list_; diff --git a/include/jsoncons_ext/jsonpath/json_location.hpp b/include/jsoncons_ext/jsonpath/json_location.hpp index da5bff3b4f..c49f682dd6 100644 --- a/include/jsoncons_ext/jsonpath/json_location.hpp +++ b/include/jsoncons_ext/jsonpath/json_location.hpp @@ -25,13 +25,14 @@ namespace jsonpath { enum class path_node_kind { root, index, name }; - template + template class path_node { - friend class json_location; + template friend class json_location; + //friend class json_location; public: - using string_view_type = typename Json::string_view_type; - using char_type = typename string_view_type::value_type; + using string_view_type = jsoncons::basic_string_view; + using char_type = CharT; private: char_type root_; @@ -311,7 +312,7 @@ namespace jsonpath { public: using allocator_type = typename Json::allocator_type; using string_type = typename Json::string_type; - using path_node_type = path_node; + using path_node_type = path_node; private: allocator_type alloc_; std::vector nodes_; diff --git a/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp b/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp index 93e7b3cf18..3d6f7c01b7 100644 --- a/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp +++ b/include/jsoncons_ext/jsonpath/jsonpath_expression.hpp @@ -112,7 +112,7 @@ namespace detail { using path_expression_type = path_expression; using expression_type = expression; using json_location_type = json_location; - using path_node_type = path_node; + using path_node_type = path_node; using selector_type = jsonpath_selector; private: @@ -2496,7 +2496,7 @@ namespace detail { using pointer = typename std::conditional::type>::value, typename Json::const_pointer, typename Json::pointer>::type; using allocator_type = typename value_type::allocator_type; using evaluator_type = typename jsoncons::jsonpath::detail::jsonpath_evaluator; - using path_node_type = path_node; + using path_node_type = path_node; using json_location_type = json_location; using path_expression_type = jsoncons::jsonpath::detail::path_expression; using path_pointer = const path_node_type*; @@ -2515,7 +2515,7 @@ namespace detail { using pointer = typename std::conditional::type>::value, typename Json::const_pointer, typename Json::pointer>::type; using allocator_type = typename value_type::allocator_type; using evaluator_type = typename jsoncons::jsonpath::detail::jsonpath_evaluator; - using path_node_type = path_node; + using path_node_type = path_node; using json_location_type = json_location; using path_expression_type = jsoncons::jsonpath::detail::path_expression; using path_pointer = const path_node_type*; diff --git a/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp b/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp index 3bc76bc621..8d95cb3ae1 100644 --- a/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp +++ b/include/jsoncons_ext/jsonpath/jsonpath_selector.hpp @@ -114,7 +114,7 @@ namespace detail { using reference = JsonReference; using char_type = typename Json::char_type; using string_type = typename Json::string_type; - using path_node_type = path_node; + using path_node_type = path_node; Json* val; @@ -135,7 +135,7 @@ namespace detail { using char_type = typename Json::char_type; using string_view_type = typename Json::string_view_type; using string_type = typename Json::string_type; - using path_node_type = path_node; + using path_node_type = path_node; static const path_node_type& generate(dynamic_resources& resources, const path_node_type& last, diff --git a/test/jsonpath/src/json_location_tests.cpp b/test/jsonpath/src/json_location_tests.cpp index ff21dd4796..9de4a59fca 100644 --- a/test/jsonpath/src/json_location_tests.cpp +++ b/test/jsonpath/src/json_location_tests.cpp @@ -9,7 +9,7 @@ #include #include -using path_node = jsoncons::jsonpath::path_node; +using path_node = jsoncons::jsonpath::path_node; using json_location = jsoncons::jsonpath::json_location; TEST_CASE("test json_location equals")