File indexing completed on 2024-04-06 12:13:12
0001 #ifndef FWCore_Utilities_interface_OStreamColumn_h
0002 #define FWCore_Utilities_interface_OStreamColumn_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 #include <iomanip>
0041 #include <string>
0042
0043 namespace edm {
0044
0045 class OStreamColumn;
0046
0047 template <typename T>
0048 struct OStreamColumnEntry {
0049 OStreamColumn const& col;
0050 T t;
0051 };
0052
0053 class OStreamColumn {
0054 public:
0055 explicit OStreamColumn(std::string const& t);
0056 explicit OStreamColumn(std::string const& t, std::size_t const w);
0057
0058 template <typename T>
0059 auto operator()(T const& t) const {
0060 return OStreamColumnEntry<T>{*this, t};
0061 }
0062
0063 std::size_t width() const { return width_; }
0064
0065 private:
0066 std::string title_;
0067 std::size_t width_;
0068
0069 friend std::ostream& operator<<(std::ostream&, OStreamColumn const&);
0070
0071 template <typename E>
0072 friend std::ostream& operator<<(std::ostream&, OStreamColumnEntry<E> const&);
0073 };
0074
0075 std::ostream& operator<<(std::ostream& t, OStreamColumn const& c);
0076
0077 template <typename E>
0078 std::ostream& operator<<(std::ostream& t, OStreamColumnEntry<E> const& ce) {
0079 t << std::setw(ce.col.width_) << ce.t;
0080 return t;
0081 }
0082
0083 }
0084
0085 #endif