4 #ifndef CPPQEDCORE_UTILS_PARS_H_INCLUDED
5 #define CPPQEDCORE_UTILS_PARS_H_INCLUDED
12 #include <boost/ptr_container/ptr_list.hpp>
21 const size_t maxTypeLabelLength=24;
26 void update(ParameterTable& p,
29 const std::string& prefix=
"--"
52 const std::string& getName()
const {
return name_;}
55 const std::string name_;
89 const std::string& getS()
const {
return s_;}
90 const std::string& getD()
const {
return d_;}
92 void print(
size_t smw,
size_t tmw,
size_t dmw)
const {print_v(smw,tmw,dmw);}
93 void read(std::istream& is) {read_v(is);}
96 virtual void read_v(std::istream&) = 0;
99 virtual void print_v(
size_t,
size_t,
size_t)
const = 0;
101 const std::string s_;
102 const std::string d_;
114 const std::string& d,
118 const T&
get()
const {
return v_;}
119 T&
get() {
return const_cast<T&
>(
static_cast<const Parameter*
>(
this)->
get());}
122 void read_v(std::istream& is) {is>>v_;}
125 void print_v(
size_t smw,
size_t tmw,
size_t dmw)
const;
139 ParameterTable() : table_(), smwidth_(0), tmwidth_(6), dmwidth_(0), stream_(), parsedCommandLine_(std::make_shared<std::string>(
"")) {}
175 template<
typename T> T&
add(
const std::string& s,
176 const std::string& d,
187 bool&
add(
const std::string& s,
const std::string& d,
bool v);
191 template<
typename T> T&
addMod(
const std::string& s,
const std::string& mod,
const std::string& d,
const T& v)
193 return add(s+mod,d,v);
214 typedef boost::ptr_list<ParameterBase> Impl;
222 std::stringstream stream_;
224 ParsedCommandLine parsedCommandLine_;
232 #endif // CPPQEDCORE_UTILS_PARS_H_INCLUDED
The class that is (meant to be, at least) the base of all exceptions in the framework.
const ParsedCommandLine getParsedCommandLine() const
Getter for the full command line set by the update() function.
Template containing value for the given parameter.
ParameterTable & addTitle(const std::string &s, const std::string &mod="")
This adds a dummy “parameter” whose only effect is to cause a newline and a title to be printed for...
The parameter table according to which the command line will be parsed by update() ...
T & add(const std::string &s, const std::string &d, const T &v)
generic version
ParameterBase & operator[](const std::string &s)
” non-const version
T & addMod(const std::string &s, const std::string &mod, const std::string &d, const T &v)
Adds the parameter with a modifier suffix – useful when many parameters are distinguished only by su...
const ParameterBase & operator[](const std::string &) const
Subscription by parameter name.
Parameter(const std::string &s, const std::string &d, const T &v)
Defines class of the same name.
Common, template-parameter independent base class of Parameter, to be stored in a pointer-container i...
void setParsedCommandLine(const std::string &s)
Setter for the full command line used by the update() function.
std::stringstream & getStream()
The stream whereon parameter i/o occurs (an intermediary stringstream) is exposed in order that i/o m...
void printList() const
Print a full list of Parameters in help with name, typeID, description, and (default) value...
std::shared_ptr< std::string > ParsedCommandLine
Type for passing the parsed command line throughout the framework.
ParameterBase(const std::string &s, const std::string &d)
Defines tentative base classes for the exception classes of the framework.
Thrown if a given Parameter name is attempted to be used more than once when pushing to ParameterTabl...
Thrown if a certain Parameter name is not found in ParameterTable when subscripting.