printing_helpers.h
Go to the documentation of this file.
1 #ifndef fhiclcpp_detail_printing_helpers_h
2 #define fhiclcpp_detail_printing_helpers_h
3 
4 // ===================================================
5 //
6 // Various printing helpers
7 //
8 // These helpers are used by the 'Prettifier' classes.
9 //
10 // ===================================================
11 
12 #include <any>
13 #include <string>
14 
15 namespace fhicl::detail {
16 
17  inline std::string
18  nl(std::size_t i = 1)
19  {
20  return std::string(i, '\n');
21  }
22 
23  std::string printed_suffix(std::string const& key, std::size_t const sz);
24 
26 
28  std::string const& cached_info);
29 
30  namespace table {
31  inline std::string
33  {
34  return "{";
35  }
36  inline std::string
38  {
39  return "}";
40  }
42  }
43 
44  namespace sequence {
45  inline std::string
47  {
48  return "[";
49  }
50  inline std::string
52  {
53  return "]";
54  }
56  }
57 
58  namespace atom {
60  std::string value(std::any const&);
61  }
62 
63  inline bool
65  {
66  auto pos = key.find_last_of(sequence::closing_brace());
67  return pos != std::string::npos && pos == key.size() - 1;
68  }
69 
70  inline bool
72  {
73  auto pos1 = key.find_last_of(".");
74  if (pos1 == std::string::npos)
75  return false;
76 
77  return not is_sequence_element(key);
78  }
79 
80  std::size_t index_for_sequence_element(std::string const& name);
81 }
82 
83 #endif /* fhiclcpp_detail_printing_helpers_h */
84 
85 // Local variables:
86 // mode: c++
87 // End:
std::string printed_suffix(std::string const &key, std::size_t const sz)
static QCString name
Definition: declinfo.cpp:673
std::string print_annotated_info(std::string const &curr_info, std::string const &cached_info)
bool is_sequence_element(std::string const &key)
std::string opening_brace()
std::string string
Definition: nybbler.cc:12
std::string print_prefix_annotated_info(std::string const &curr_info)
std::string printed_prefix(std::string const &key)
def key(type, name=None)
Definition: graph.py:13
std::size_t index_for_sequence_element(std::string const &name)
std::string value(std::any const &)
bool is_table_member(std::string const &key)
std::string nl(std::size_t i=1)
std::string closing_brace()