@@ -22,6 +22,7 @@ labelt::labelt(std::vector<std::string> components) : components(components)
2222 });
2323 }));
2424}
25+
2526std::string labelt::camel_case () const
2627{
2728 std::ostringstream output;
@@ -30,18 +31,21 @@ std::string labelt::camel_case() const
3031 output, std::next (components.begin ()), components.end (), " " , capitalize);
3132 return output.str ();
3233}
34+
3335std::string labelt::snake_case () const
3436{
3537 std::ostringstream output;
3638 join_strings (output, components.begin (), components.end (), ' _' );
3739 return output.str ();
3840}
41+
3942std::string labelt::kebab_case () const
4043{
4144 std::ostringstream output;
4245 join_strings (output, components.begin (), components.end (), ' -' );
4346 return output.str ();
4447}
48+
4549std::string labelt::pretty () const
4650{
4751 std::ostringstream output;
@@ -53,33 +57,40 @@ std::string labelt::pretty() const
5357 join_strings (output, range.begin (), range.end (), ' ' );
5458 return output.str ();
5559}
60+
5661bool labelt::operator <(const labelt &other) const
5762{
5863 return components < other.components ;
5964}
65+
6066structured_data_entryt structured_data_entryt::data_node (const jsont &data)
6167{
6268 // Structured data (e.g. arrays and objects) should use an entry
6369 PRECONDITION (!(data.is_array () || data.is_object ()));
6470 return structured_data_entryt (data);
6571}
72+
6673structured_data_entryt
6774structured_data_entryt::entry (std::map<labelt, structured_data_entryt> children)
6875{
6976 return structured_data_entryt (children);
7077}
78+
7179structured_data_entryt::structured_data_entryt (const jsont &data) : data(data)
7280{
7381}
82+
7483structured_data_entryt::structured_data_entryt (
7584 std::map<labelt, structured_data_entryt> children)
7685 : _children(std::move(children))
7786{
7887}
88+
7989bool structured_data_entryt::is_leaf () const
8090{
8191 return _children.empty ();
8292}
93+
8394std::string structured_data_entryt::leaf_data () const
8495{
8596 return data.value ;
@@ -89,10 +100,12 @@ structured_data_entryt::children() const
89100{
90101 return _children;
91102}
103+
92104jsont structured_data_entryt::leaf_object () const
93105{
94106 return data;
95107}
108+
96109structured_datat::structured_datat (
97110 std::map<labelt, structured_data_entryt> data)
98111 : _data(std::move(data))
@@ -153,6 +166,7 @@ std::string to_pretty(const structured_datat &data)
153166 join_strings (output, flattened_lines.begin (), flattened_lines.end (), " \n " );
154167 return output.str ();
155168}
169+
156170const std::map<labelt, structured_data_entryt> &structured_datat::data () const
157171{
158172 return _data;
0 commit comments