C++QEDCore  2.100.2 (v2 Milestone 10 Development branch)
a framework for simulating open quantum dynamics – core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
KeyPrinter.h
Go to the documentation of this file.
1 // Copyright András Vukics 2006–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
3 // -*- C++ -*-
4 #ifndef CPPQEDCORE_UTILS_KEYPRINTER_H_INCLUDED
5 #define CPPQEDCORE_UTILS_KEYPRINTER_H_INCLUDED
6 
7 #include "KeyPrinterFwd.h"
8 
9 #include <initializer_list>
10 #include <list>
11 #include <string>
12 #include <utility>
13 
14 
15 namespace cpputils {
16 
17 
19 
25 {
26 public:
27  typedef std::list<std::string> KeyLabels;
28  typedef std::initializer_list<std::string> KeyLabelsInitializer;
29 
31  template<typename... KeyLabelsPack>
32  KeyPrinter(const std::string& keyTitle, KeyLabelsPack&&... keyLabelsPack) : keyTitle_(keyTitle), keyLabels_(std::forward<KeyLabelsPack>(keyLabelsPack)...) {}
33 
35  KeyPrinter(const std::string& keyTitle, KeyLabelsInitializer il) : keyTitle_(keyTitle), keyLabels_(il) {}
36 
37  size_t length () const {return keyLabels_.size();}
38  std::ostream& displayKey(std::ostream&, size_t&) const;
39 
41 
42  const std::string& getTitle () const {return keyTitle_ ;}
43  const KeyLabels & getLabels() const {return keyLabels_;}
45 
46 private:
47  const std::string keyTitle_ ;
48  const KeyLabels keyLabels_;
49 };
50 
51 
52 } // cpputils
53 
54 #endif // CPPQEDCORE_UTILS_KEYPRINTER_H_INCLUDED
Namespace comprising otherwise hard-to-classify generic utilities.
Definition: Algorithm.h:10
std::list< std::string > KeyLabels
the list of labels
Definition: KeyPrinter.h:27
std::initializer_list< std::string > KeyLabelsInitializer
convenience typedef for initialization with an initializer_list
Definition: KeyPrinter.h:28
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
Definition: KeyPrinter.h:35
size_t length() const
number of elements in the key
Definition: KeyPrinter.h:37
KeyPrinter(const std::string &keyTitle, KeyLabelsPack &&...keyLabelsPack)
construction from an arbitrary set of arguments capable to construct an object of type KeyLabels ...
Definition: KeyPrinter.h:32
Stores and prints a “key” (a.k.a. legend) to data, that is, an explanation to each element of a cer...
Definition: KeyPrinter.h:24