Bayeux  3.4.1
Core Foundation library for SuperNEMO
i_tree_dump.h
Go to the documentation of this file.
1 #ifndef DATATOOLS_I_TREE_DUMP_H
3 #define DATATOOLS_I_TREE_DUMP_H
4 
5 // Standard Library:
6 #include <iostream>
7 #include <string>
8 
9 // Third party:
10 // - Boost:
11 #ifdef __clang__
12 #pragma clang diagnostic push
13 #pragma clang diagnostic ignored "-Wshadow"
14 #endif
15 #ifdef __GNUC__
16 #pragma GCC diagnostic push
17 #pragma GCC diagnostic ignored "-Wshadow"
18 #endif
19 #include <boost/property_tree/ptree.hpp>
20 #ifdef __GNUC__
21 #pragma GCC diagnostic pop
22 #endif
23 #ifdef __clang__
24 #pragma clang diagnostic pop
25 #endif
26 
27 // This project:
29 #ifndef Q_MOC_RUN
31 #endif // Q_MOC_RUN
32 
33 namespace datatools {
34 
37  {
38  public:
39 
41  struct tags {
42  static const std::string & item();
43  static const std::string & last_item();
44  static const std::string & skip_item();
45  static const std::string & last_skip_item();
46  static const std::string & item(bool last_, bool skip_);
47  };
48 
49  static const boost::property_tree::ptree & empty_options();
50  static boost::property_tree::ptree make_base_print_options(const std::string & title_,
51  const std::string & indent_ = "",
52  const bool inherit_ = false);
53 
56 
57  bool inherit = false;
58  std::string title;
59  std::string indent;
60 
61  void configure_from(const boost::property_tree::ptree &);
62  void export_to(boost::property_tree::ptree &);
63  void reset();
64 
65  static const std::string & inherit_key();
66  static const std::string & title_key();
67  static const std::string & indent_key();
68  static boost::property_tree::ptree force_inheritance(const boost::property_tree::ptree &);
69 
70  };
71 
73  enum ostream_type {
77  };
78 
81 
83  virtual ~i_tree_dumpable();
84 
85  static std::ostream & last_skip_tag(std::ostream & out_);
86 
87  static std::ostream & skip_tag(std::ostream & out_);
88 
89  static std::ostream & last_tag(std::ostream & out_);
90 
91  static std::ostream & tag(std::ostream & out_);
92 
94  virtual void print_tree(std::ostream & out_ = std::clog,
95  const boost::property_tree::ptree & options_ = empty_options()) const;
96 
98  virtual void tree_dump(std::ostream & out_ = std::clog,
99  const std::string & title_ = "",
100  const std::string & indent_ = "",
101  bool inherit_ = false) const;
102 
104  void print_tree_json(std::ostream & out_ = std::clog,
105  const std::string & json_options_ = "") const;
106 
108  void print_tree_json(std::ostream & out_ = std::clog,
109  const char * json_options_ = nullptr) const;
110 
111  void tree_dump_id(const int out_type_ = OSTREAM_CLOG,
112  const std::string & title_ = "",
113  const std::string & indent_ = "",
114  const bool inherit_ = false) const;
115 
116  void tree_print_id(const int out_type_ = OSTREAM_CLOG,
117  const std::string & title_ = "") const;
118 
119  void smart_print_id(const int out_type_ = OSTREAM_CLOG,
120  const std::string & title_ = "",
121  const std::string & indent_ = "") const;
122 
125  {
126  public:
127 
128  inherit_tag(bool inherit_);
129 
130  friend std::ostream & operator<<(std::ostream & out_,
131  const inherit_tag & last_tag_);
132 
133  private:
134 
135  bool _inherit_;
136 
137  };
138 
141  {
142  public:
143 
144  inherit_skip_tag(bool inherit_);
145 
146  friend std::ostream& operator<<(std::ostream & out_,
147  const inherit_skip_tag & last_tag_);
148  private:
149 
150  bool _inherit_;
151 
152  };
153 
154 #ifndef Q_MOC_RUN
155  DR_CLASS_RTTI()
156 #endif // Q_MOC_RUN
157 
158  };
159 
160 } // end of namespace datatools
161 
162 #ifndef Q_MOC_RUN
163 // Activate reflection layer for the 'datatools::i_tree_dumpable' class:
165 #endif // Q_MOC_RUN
166 
167 #endif // DATATOOLS_I_TREE_DUMP_H
168 
169 // Local Variables: --
170 // mode: c++ --
171 // c-file-style: "gnu" --
172 // tab-width: 2 --
173 // End: --
static const boost::property_tree::ptree & empty_options()
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
Output stream manipulator.
Definition: i_tree_dump.h:140
Output stream manipulator.
Definition: i_tree_dump.h:124
friend std::ostream & operator<<(std::ostream &out_, const inherit_skip_tag &last_tag_)
void smart_print_id(const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="") const
static const std::string & last_skip_item()
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
static std::ostream & skip_tag(std::ostream &out_)
static const std::string & indent_key()
void tree_print_id(const int out_type_=OSTREAM_CLOG, const std::string &title_="") const
Default print options POD.
Definition: i_tree_dump.h:55
void tree_dump_id(const int out_type_=OSTREAM_CLOG, const std::string &title_="", const std::string &indent_="", const bool inherit_=false) const
bool inherit
Definition: i_tree_dump.h:57
static std::ostream & last_skip_tag(std::ostream &out_)
virtual ~i_tree_dumpable()
Destructor.
static const std::string & title_key()
static const std::string & inherit_key()
static std::ostream & last_tag(std::ostream &out_)
ostream_type
Enumeration for standard output streams.
Definition: i_tree_dump.h:73
std::string title
Definition: i_tree_dump.h:58
void configure_from(const boost::property_tree::ptree &)
friend std::ostream & operator<<(std::ostream &out_, const inherit_tag &last_tag_)
i_tree_dumpable()
Constructor.
Default tags for tree-formated print.
Definition: i_tree_dump.h:41
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Main old interface method for printing.
virtual void print_tree(std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const
Main new interface method for printing.
void export_to(boost::property_tree::ptree &)
Definition: i_tree_dump.h:76
static boost::property_tree::ptree make_base_print_options(const std::string &title_, const std::string &indent_="", const bool inherit_=false)
static const std::string & item()
static std::ostream & tag(std::ostream &out_)
Definition: i_tree_dump.h:74
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
static const std::string & last_item()
static boost::property_tree::ptree force_inheritance(const boost::property_tree::ptree &)
Definition: i_tree_dump.h:75
Describe the datatools API configuration.
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
std::string indent
Definition: i_tree_dump.h:59
void print_tree_json(std::ostream &out_=std::clog, const std::string &json_options_="") const
Printing with jsonized options.
static const std::string & skip_item()