Skip to content

Commit 4fa9921

Browse files
author
thk123
committed
Make structured_data_entry use consistent naming and return reference
1 parent 8637391 commit 4fa9921

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/util/json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ jsont json_node(const structured_data_entryt &entry)
214214
else
215215
{
216216
json_objectt result;
217-
for(const auto sub_entry : entry.get_children())
217+
for(const auto sub_entry : entry.children())
218218
{
219219
result[sub_entry.first.camel_case()] = json_node(sub_entry.second);
220220
}

src/util/structured_data.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,21 @@ structured_data_entryt::structured_data_entryt(const jsont &data) : data(data)
8080
}
8181
structured_data_entryt::structured_data_entryt(
8282
std::map<labelt, structured_data_entryt> children)
83-
: children(std::move(children))
83+
: _children(std::move(children))
8484
{
8585
}
8686
bool structured_data_entryt::is_leaf() const
8787
{
88-
return children.empty();
88+
return _children.empty();
8989
}
9090
std::string structured_data_entryt::leaf_data() const
9191
{
9292
return data.value;
9393
}
94-
std::map<labelt, structured_data_entryt>
95-
structured_data_entryt::get_children() const
94+
const std::map<labelt, structured_data_entryt> &
95+
structured_data_entryt::children() const
9696
{
97-
return children;
97+
return _children;
9898
}
9999
jsont structured_data_entryt::leaf_object() const
100100
{
@@ -121,7 +121,7 @@ pretty_node(const std::pair<labelt, structured_data_entryt> &entry)
121121
{
122122
const auto indent = [](const std::string line) { return "\t" + line; };
123123

124-
const auto &children = data.get_children();
124+
const auto &children = data.children();
125125
std::vector<std::vector<std::string>> lines =
126126
make_range(children)
127127
.map(pretty_node)

src/util/structured_data.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ struct structured_data_entryt
3838
bool is_leaf() const;
3939
std::string leaf_data() const;
4040
jsont leaf_object() const;
41-
std::map<labelt, structured_data_entryt> get_children() const;
41+
const std::map<labelt, structured_data_entryt> &children() const;
4242

4343
private:
4444
explicit structured_data_entryt(const jsont &data);
4545
explicit structured_data_entryt(
4646
std::map<labelt, structured_data_entryt> children);
4747

4848
jsont data;
49-
std::map<labelt, structured_data_entryt> children;
49+
std::map<labelt, structured_data_entryt> _children;
5050
};
5151

5252
/// A way of representing nested key/value data. Used for logging on any
@@ -74,7 +74,7 @@ class structured_datat
7474
{
7575
public:
7676
explicit structured_datat(std::map<labelt, structured_data_entryt> data);
77-
const std::map<labelt, structured_data_entryt> & data() const;
77+
const std::map<labelt, structured_data_entryt> &data() const;
7878

7979
private:
8080
std::map<labelt, structured_data_entryt> _data;

src/util/xml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ xmlt xml_node(const std::pair<labelt, structured_data_entryt> &entry)
270270
}
271271
else
272272
{
273-
const auto &children = data.get_children();
273+
const auto &children = data.children();
274274
output_data.elements =
275275
make_range(children).map(xml_node).collect<std::list<xmlt>>();
276276
}

0 commit comments

Comments
 (0)