CBMC
structured_data.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Classes for representing generic structured data
4 
5 Author: Thomas Kiley
6 
7 \*******************************************************************/
8 #ifndef CPROVER_UTIL_STRUCTURED_DATA_H
9 #define CPROVER_UTIL_STRUCTURED_DATA_H
10 
11 #include "json.h"
12 
13 #include <string>
14 #include <vector>
15 
16 struct labelt
17 {
18 public:
19  explicit labelt(std::vector<std::string> components);
20 
21  std::string camel_case() const;
22  std::string snake_case() const;
23  std::string kebab_case() const;
24  std::string pretty() const;
25 
26  bool operator<(const labelt &other) const;
27 
28 private:
29  std::vector<std::string> components;
30 };
31 
33 {
36  entry(std::map<labelt, structured_data_entryt> children);
37 
38  bool is_leaf() const;
39  std::string leaf_data() const;
40  jsont leaf_object() const;
41  const std::map<labelt, structured_data_entryt> &children() const;
42 
43 private:
45  explicit structured_data_entryt(
46  std::map<labelt, structured_data_entryt> children);
47 
49  std::map<labelt, structured_data_entryt> _children;
50 };
51 
74 {
75 public:
76  explicit structured_datat(std::map<labelt, structured_data_entryt> data);
77  const std::map<labelt, structured_data_entryt> &data() const;
78 
79 private:
80  std::map<labelt, structured_data_entryt> _data;
81 };
82 
90 std::string to_pretty(const structured_datat &);
91 
92 #endif // CPROVER_UTIL_STRUCTURED_DATA_H
structured_data_entryt::data_node
static structured_data_entryt data_node(const jsont &data)
Definition: structured_data.cpp:64
structured_data_entryt
Definition: structured_data.h:32
structured_data_entryt::data
jsont data
Definition: structured_data.h:48
structured_data_entryt::_children
std::map< labelt, structured_data_entryt > _children
Definition: structured_data.h:49
structured_datat::data
const std::map< labelt, structured_data_entryt > & data() const
Definition: structured_data.cpp:169
structured_datat::_data
std::map< labelt, structured_data_entryt > _data
Definition: structured_data.h:80
jsont
Definition: json.h:26
structured_data_entryt::structured_data_entryt
structured_data_entryt(jsont data)
Definition: structured_data.cpp:77
structured_data_entryt::is_leaf
bool is_leaf() const
Definition: structured_data.cpp:88
labelt::camel_case
std::string camel_case() const
Definition: structured_data.cpp:24
to_pretty
std::string to_pretty(const structured_datat &)
Convert the structured_data into plain text.
Definition: structured_data.cpp:149
structured_data_entryt::entry
static structured_data_entryt entry(std::map< labelt, structured_data_entryt > children)
Definition: structured_data.cpp:72
labelt::operator<
bool operator<(const labelt &other) const
Definition: structured_data.cpp:59
labelt::pretty
std::string pretty() const
Definition: structured_data.cpp:47
labelt::snake_case
std::string snake_case() const
Definition: structured_data.cpp:33
labelt
Definition: structured_data.h:16
structured_data_entryt::leaf_data
std::string leaf_data() const
Definition: structured_data.cpp:93
structured_data_entryt::children
const std::map< labelt, structured_data_entryt > & children() const
Definition: structured_data.cpp:98
structured_datat
A way of representing nested key/value data.
Definition: structured_data.h:73
labelt::labelt
labelt(std::vector< std::string > components)
Definition: structured_data.cpp:14
labelt::components
std::vector< std::string > components
Definition: structured_data.h:29
labelt::kebab_case
std::string kebab_case() const
Definition: structured_data.cpp:40
json.h
structured_data_entryt::leaf_object
jsont leaf_object() const
Definition: structured_data.cpp:103
structured_datat::structured_datat
structured_datat(std::map< labelt, structured_data_entryt > data)
Definition: structured_data.cpp:108