4 #ifndef CPPQEDCORE_UTILS_KEYPRINTER_H_INCLUDED
5 #define CPPQEDCORE_UTILS_KEYPRINTER_H_INCLUDED
7 #include "KeyPrinterFwd.h"
9 #include <initializer_list>
31 template<
typename... KeyLabelsPack>
32 KeyPrinter(
const std::string& keyTitle, KeyLabelsPack&&... keyLabelsPack) : keyTitle_(keyTitle), keyLabels_(std::forward<KeyLabelsPack>(keyLabelsPack)...) {}
35 KeyPrinter(
const std::string& keyTitle, KeyLabelsInitializer il) : keyTitle_(keyTitle), keyLabels_(il) {}
37 size_t length ()
const {
return keyLabels_.size();}
38 std::ostream&
displayKey(std::ostream&,
size_t&)
const;
42 const std::string& getTitle ()
const {
return keyTitle_ ;}
43 const KeyLabels & getLabels()
const {
return keyLabels_;}
47 const std::string keyTitle_ ;
48 const KeyLabels keyLabels_;
54 #endif // CPPQEDCORE_UTILS_KEYPRINTER_H_INCLUDED
Namespace comprising otherwise hard-to-classify generic utilities.
std::list< std::string > KeyLabels
the list of labels
std::initializer_list< std::string > KeyLabelsInitializer
convenience typedef for initialization with an initializer_list
std::ostream & displayKey(std::ostream &, size_t &) const
displays the stored key in a nicely tabulated format
KeyPrinter(const std::string &keyTitle, KeyLabelsInitializer il)
construction from a KeyLabelsInitializer list
size_t length() const
number of elements in the key
KeyPrinter(const std::string &keyTitle, KeyLabelsPack &&...keyLabelsPack)
construction from an arbitrary set of arguments capable to construct an object of type KeyLabels ...
Stores and prints a “key” (a.k.a. legend) to data, that is, an explanation to each element of a cer...