LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 "boost/any.hpp"
14 
15 #include <string>
16 
17 namespace fhicl {
18  namespace detail {
19 
20  inline std::string
21  nl(std::size_t i = 1)
22  {
23  return std::string(i, '\n');
24  }
25 
26  std::string printed_suffix(std::string const& key, std::size_t const sz);
27 
28  std::string print_prefix_annotated_info(std::string const& curr_info);
29 
30  std::string print_annotated_info(std::string const& curr_info,
31  std::string const& cached_info);
32 
33  namespace table {
34  inline std::string
36  {
37  return "{";
38  }
39  inline std::string
41  {
42  return "}";
43  }
44  std::string printed_prefix(std::string const& key);
45  }
46 
47  namespace sequence {
48  inline std::string
50  {
51  return "[";
52  }
53  inline std::string
55  {
56  return "]";
57  }
58  std::string printed_prefix(std::string const& key);
59  }
60 
61  namespace atom {
62  std::string printed_prefix(std::string const& key);
63  std::string value(boost::any const&);
64  }
65 
66  inline bool
67  is_sequence_element(std::string const& key)
68  {
69  auto pos = key.find_last_of(sequence::closing_brace());
70  return pos != std::string::npos && pos == key.size() - 1;
71  }
72 
73  inline bool
74  is_table_member(std::string const& key)
75  {
76  auto pos1 = key.find_last_of(".");
77  if (pos1 == std::string::npos)
78  return false;
79 
80  return is_sequence_element(key) ? false : true;
81  }
82  }
83 }
84 
85 #endif /* fhiclcpp_detail_printing_helpers_h */
86 
87 // Local variables:
88 // mode: c++
89 // End:
std::string printed_suffix(std::string const &key, std::size_t const sz)
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 print_prefix_annotated_info(std::string const &curr_info)
std::string printed_prefix(std::string const &key)
parameter set interface
std::string value(boost::any const &)
bool is_table_member(std::string const &key)
std::string nl(std::size_t i=1)
std::string closing_brace()