MetadataSummaryForSource.h
Go to the documentation of this file.
1 #ifndef art_Framework_Art_detail_md_summary_MetadataSummaryForSource_h
2 #define art_Framework_Art_detail_md_summary_MetadataSummaryForSource_h
3 
7 
8 #include <iomanip>
9 #include <sstream>
10 #include <string>
11 
12 namespace art::detail {
13 
14  template <>
16  public:
18  : coll_{coll}
19  , widths_{std::to_string(coll.size()).size(),
20  columnWidth(coll, &LibraryInfo::short_spec, "module_type"),
21  columnWidth(coll, &LibraryInfo::provider, "Provider"),
22  columnWidth(coll, &LibraryInfo::path, "Source location")}
23  {}
24 
25  private:
28 
29  Widths const&
30  doWidths() const override
31  {
32  return widths_;
33  }
34 
36  doHeader() const override
37  {
38  std::ostringstream result;
39  result << indent(widths_[0] + 2) << std::setw(widths_[1] + 4) << std::left
40  << "module_type" << std::setw(widths_[2] + 4) << std::left
41  << "Provider" << std::left << "Source location";
42  return result.str();
43  }
44 
45  Summary
46  doSummary(LibraryInfo const& li, std::size_t const entry) const override
47  {
48  auto const count = std::count_if(
49  coll_.cbegin(), coll_.cend(), LibraryInfoMatch{li.short_spec()});
50  bool const is_duplicate = count != 1;
51  auto const dupl = is_duplicate ? '*' : ' ';
52 
53  std::ostringstream result;
54  result << std::setw(widths_[0]) << std::right << entry << '.' << dupl
55  << std::setw(widths_[1] + 4) << std::left << li.short_spec()
56  << std::setw(widths_[2] + 4) << std::left << li.provider()
57  << std::left << li.path() << "\n";
58  return {result.str(), is_duplicate};
59  }
60  };
61 
62 } // namespace art::detail
63 
64 #endif /* art_Framework_Art_detail_md_summary_MetadataSummaryForSource_h */
65 
66 // Local variables:
67 // mode: c++
68 // End:
std::vector< std::size_t > Widths
QList< Entry > entry
static QCString result
std::string string
Definition: nybbler.cc:12
std::size_t columnWidth(T const &coll, std::string const Elem::*cp, std::string const &header)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
std::string indent(std::size_t const i)
Summary doSummary(LibraryInfo const &li, std::size_t const entry) const override
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::string const & short_spec() const
Definition: LibraryInfo.h:43
std::string const & provider() const
Definition: LibraryInfo.h:63
std::string const & path() const
Definition: LibraryInfo.h:53
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
std::multiset< LibraryInfo > LibraryInfoCollection