PrintFormatting.h
Go to the documentation of this file.
1 #ifndef art_Framework_Art_detail_PrintFormatting_h
2 #define art_Framework_Art_detail_PrintFormatting_h
3 
6 
7 #include <ostream>
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
12 namespace art::detail {
13 
14  //==========================================================================
15 
16  inline std::string
17  indent(std::size_t const i)
18  {
19  return std::string(i, ' ');
20  }
21  inline std::string
23  {
24  return indent(3);
25  }
26  inline std::string
28  {
29  return indent(4);
30  }
31  inline std::string
33  {
34  return indent(8);
35  }
36 
37  //==========================================================================
38 
39  template <typename T, typename Elem>
40  std::size_t
41  columnWidth(T const& coll,
42  std::string const Elem::*cp,
43  std::string const& header)
44  {
45  std::size_t s{header.size()};
47  coll, [&s, cp](auto const& elem) { s = std::max(s, (elem.*cp).size()); });
48  return s;
49  }
50 
51  inline std::size_t
53  std::string const& (LibraryInfo::*fp)() const,
54  std::string const& header)
55  {
56  std::size_t s{header.size()};
58  coll, [&s, fp](auto const& li) { s = std::max(s, (li.*fp)().size()); });
59  return s;
60  }
61 
62  //==========================================================================
63  // horizontal rules
64 
65  using Widths = std::vector<std::size_t>;
66 
67  inline std::size_t
68  rule_size(Widths const& widths)
69  {
70  std::size_t result{indent0().size()};
71  for (std::size_t const w : widths)
72  result += w;
73  return result +=
74  (widths.size() - 1) * 4u; // Account for space between columns;
75  }
76 } // namespace art::detail
77 
78 #endif /* art_Framework_Art_detail_PrintFormatting_h */
79 
80 // Local variables:
81 // mode: c++
82 // End:
std::vector< std::size_t > Widths
T max(const caf::Proxy< T > &a, T b)
std::size_t columnWidth(T const &coll, std::string const Elem::*cp, std::string const &header)
std::size_t rule_size(Widths const &widths)
const XML_Char * s
Definition: expat.h:262
std::string indent_1()
std::string indent__2()
std::string indent(std::size_t const i)
auto for_all(FwdCont &, Func)
std::string indent0()
FILE * fp
double T
Definition: Xdiff_gwt.C:5
Float_t w
Definition: plot.C:20
std::multiset< LibraryInfo > LibraryInfoCollection
enum BeamMode string