Skip to content

Commit f85537d

Browse files
committed
node_accumulator -> node_receiver
1 parent 64c2945 commit f85537d

File tree

2 files changed

+98
-98
lines changed

2 files changed

+98
-98
lines changed

include/jsoncons_ext/jsonpath/expression.hpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,21 +2141,21 @@ namespace detail {
21412141
};
21422142

21432143
template <class Json,class JsonReference>
2144-
class node_accumulator
2144+
class node_receiver
21452145
{
21462146
public:
21472147
using char_type = typename Json::char_type;
21482148
using reference = JsonReference;
21492149
using json_location_node_type = json_location_node<char_type>;
21502150

2151-
virtual ~node_accumulator() noexcept = default;
2151+
virtual ~node_receiver() noexcept = default;
21522152

2153-
virtual void add_node(const json_location_node_type& path_tail,
2154-
reference value) = 0;
2153+
virtual void add(const json_location_node_type& path_tail,
2154+
reference value) = 0;
21552155
};
21562156

21572157
template <class Json,class JsonReference>
2158-
class path_value_accumulator : public node_accumulator<Json,JsonReference>
2158+
class path_value_receiver : public node_receiver<Json,JsonReference>
21592159
{
21602160
public:
21612161
using reference = JsonReference;
@@ -2166,15 +2166,15 @@ namespace detail {
21662166

21672167
std::vector<path_value_pair_type> nodes;
21682168

2169-
void add_node(const json_location_node_type& path_tail,
2170-
reference value) override
2169+
void add(const json_location_node_type& path_tail,
2170+
reference value) override
21712171
{
21722172
nodes.emplace_back(json_location_type(path_tail), std::addressof(value));
21732173
}
21742174
};
21752175

21762176
template <class Json,class JsonReference>
2177-
class path_stem_value_accumulator : public node_accumulator<Json,JsonReference>
2177+
class path_stem_value_receiver : public node_receiver<Json,JsonReference>
21782178
{
21792179
public:
21802180
using reference = JsonReference;
@@ -2184,8 +2184,8 @@ namespace detail {
21842184

21852185
std::vector<path_stem_value_pair_type> nodes;
21862186

2187-
void add_node(const json_location_node_type& path_tail,
2188-
reference value) override
2187+
void add(const json_location_node_type& path_tail,
2188+
reference value) override
21892189
{
21902190
nodes.emplace_back(path_tail, value);
21912191
}
@@ -2277,7 +2277,7 @@ namespace detail {
22772277
using path_value_pair_type = path_value_pair<Json,JsonReference>;
22782278
using json_location_node_type = json_location_node<char_type>;
22792279
using json_location_type = json_location<char_type>;
2280-
using node_accumulator_type = node_accumulator<Json,JsonReference>;
2280+
using node_receiver_type = node_receiver<Json,JsonReference>;
22812281
using selector_type = jsonpath_selector<Json,JsonReference>;
22822282

22832283
jsonpath_selector(bool is_path,
@@ -2308,7 +2308,7 @@ namespace detail {
23082308
reference root,
23092309
const json_location_node_type& path_tail,
23102310
reference val,
2311-
node_accumulator_type& accumulator,
2311+
node_receiver_type& receiver,
23122312
result_options options) const = 0;
23132313

23142314
virtual reference evaluate(dynamic_resources<Json,JsonReference>& resources,
@@ -2928,7 +2928,7 @@ namespace detail {
29282928
};
29292929

29302930
template <class Callback, class Json,class JsonReference>
2931-
class callback_accumulator : public node_accumulator<Json,JsonReference>
2931+
class callback_receiver : public node_receiver<Json,JsonReference>
29322932
{
29332933
Callback& callback_;
29342934
public:
@@ -2937,13 +2937,13 @@ namespace detail {
29372937
using json_location_node_type = json_location_node<char_type>;
29382938
using json_location_type = json_location<char_type>;
29392939

2940-
callback_accumulator(Callback& callback)
2940+
callback_receiver(Callback& callback)
29412941
: callback_(callback)
29422942
{
29432943
}
29442944

2945-
void add_node(const json_location_node_type& path_tail,
2946-
reference value) override
2945+
void add(const json_location_node_type& path_tail,
2946+
reference value) override
29472947
{
29482948
callback_(json_location_type(path_tail), value);
29492949
}
@@ -3036,35 +3036,35 @@ namespace detail {
30363036

30373037
if ((options & require_more) != result_options())
30383038
{
3039-
path_value_accumulator<Json,JsonReference> accumulator;
3040-
selector_->select(resources, root, path, current, accumulator, options);
3039+
path_value_receiver<Json,JsonReference> receiver;
3040+
selector_->select(resources, root, path, current, receiver, options);
30413041

3042-
if (accumulator.nodes.size() > 1 && (options & result_options::sort) == result_options::sort)
3042+
if (receiver.nodes.size() > 1 && (options & result_options::sort) == result_options::sort)
30433043
{
3044-
std::sort(accumulator.nodes.begin(), accumulator.nodes.end(), path_value_pair_less_type());
3044+
std::sort(receiver.nodes.begin(), receiver.nodes.end(), path_value_pair_less_type());
30453045
}
30463046

3047-
if (accumulator.nodes.size() > 1 && (options & result_options::nodups) == result_options::nodups)
3047+
if (receiver.nodes.size() > 1 && (options & result_options::nodups) == result_options::nodups)
30483048
{
30493049
if ((options & result_options::sort) == result_options::sort)
30503050
{
3051-
auto last = std::unique(accumulator.nodes.begin(),accumulator.nodes.end(),path_value_pair_equal_type());
3052-
accumulator.nodes.erase(last,accumulator.nodes.end());
3053-
for (auto& node : accumulator.nodes)
3051+
auto last = std::unique(receiver.nodes.begin(),receiver.nodes.end(),path_value_pair_equal_type());
3052+
receiver.nodes.erase(last,receiver.nodes.end());
3053+
for (auto& node : receiver.nodes)
30543054
{
30553055
callback(node.path(), node.value());
30563056
}
30573057
}
30583058
else
30593059
{
3060-
std::vector<path_value_pair_type> index(accumulator.nodes);
3060+
std::vector<path_value_pair_type> index(receiver.nodes);
30613061
std::sort(index.begin(), index.end(), path_value_pair_less_type());
30623062
auto last = std::unique(index.begin(),index.end(),path_value_pair_equal_type());
30633063
index.erase(last,index.end());
30643064

30653065
std::vector<path_value_pair_type> temp2;
30663066
temp2.reserve(index.size());
3067-
for (auto&& node : accumulator.nodes)
3067+
for (auto&& node : receiver.nodes)
30683068
{
30693069
auto it = std::lower_bound(index.begin(),index.end(),node, path_value_pair_less_type());
30703070
if (it != index.end() && it->path() == node.path())
@@ -3081,16 +3081,16 @@ namespace detail {
30813081
}
30823082
else
30833083
{
3084-
for (auto& node : accumulator.nodes)
3084+
for (auto& node : receiver.nodes)
30853085
{
30863086
callback(node.path(), node.value());
30873087
}
30883088
}
30893089
}
30903090
else
30913091
{
3092-
callback_accumulator<Callback,Json,JsonReference> accumulator(callback);
3093-
selector_->select(resources, root, path, current, accumulator, options);
3092+
callback_receiver<Callback,Json,JsonReference> receiver(callback);
3093+
selector_->select(resources, root, path, current, receiver, options);
30943094
}
30953095
}
30963096

0 commit comments

Comments
 (0)