LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 
5 #include "cetlib/container_algorithms.h"
6 
7 #include <ostream>
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
12 namespace art {
13  namespace detail {
14 
15  //==========================================================================
16 
17  inline std::string
18  indent(std::size_t const i)
19  {
20  return std::string(i, ' ');
21  }
22  inline std::string
24  {
25  return indent(3);
26  }
27  inline std::string
29  {
30  return indent(4);
31  }
32  inline std::string
34  {
35  return indent(8);
36  }
37 
38  //==========================================================================
39 
40  template <typename T, typename Elem>
41  std::size_t
42  columnWidth(T const& coll,
43  std::string const Elem::*cp,
44  std::string const& header)
45  {
46  std::size_t s{header.size()};
47  cet::for_all(coll, [&s, cp](auto const& elem) {
48  s = std::max(s, (elem.*cp).size());
49  });
50  return s;
51  }
52 
53  inline std::size_t
55  std::string const& (LibraryInfo::*fp)() const,
56  std::string const& header)
57  {
58  std::size_t s{header.size()};
59  cet::for_all(
60  coll, [&s, fp](auto const& li) { s = std::max(s, (li.*fp)().size()); });
61  return s;
62  }
63 
64  //==========================================================================
65  // horizontal rules
66 
67  using Widths = std::vector<std::size_t>;
68 
69  inline std::size_t
70  rule_size(Widths const& widths)
71  {
72  std::size_t result{indent0().size()};
73  for (std::size_t const w : widths)
74  result += w;
75  return result +=
76  (widths.size() - 1) * 4u; // Account for space between columns;
77  }
78  }
79 }
80 
81 #endif /* art_Framework_Art_detail_PrintFormatting_h */
82 
83 // Local variables:
84 // mode: c++
85 // End:
std::vector< std::size_t > Widths
Float_t s
Definition: plot.C:23
std::size_t columnWidth(T const &coll, std::string const Elem::*cp, std::string const &header)
std::size_t rule_size(Widths const &widths)
Int_t max
Definition: plot.C:27
std::string indent_1()
std::string indent__2()
std::string indent(std::size_t const i)
FILE * fp
Definition: plot.C:36
std::string indent0()
HLT enums.
Float_t w
Definition: plot.C:23
std::multiset< LibraryInfo > LibraryInfoCollection