11 #include <mrpt/config.h> 56 using BASE = std::map<std::string, T>;
65 TParameters(std::initializer_list<typename BASE::value_type> init)
80 auto it =
base.find(
s);
82 throw std::logic_error(
83 (
"Parameter '"s +
s +
"' is not present."s).c_str());
89 template <
typename RET>
93 auto it =
base.find(
s);
97 return static_cast<RET
>(it->second);
120 size_t maxStrLen = 10;
121 for (
const auto& e : *
this)
122 maxStrLen = std::max(maxStrLen, e.first.size());
124 std::stringstream str;
125 for (
const auto& e : *
this)
126 str << e.first <<
std::string(maxStrLen - e.first.size(),
' ')
127 <<
" = " << e.second << std::endl;
iterator begin() noexcept
TParameters()
Default constructor (initializes empty)
const_iterator begin() const noexcept
bool has(const std::string &s) const
const_iterator end() const noexcept
std::map< std::string, double > BASE
std::string getAsString() const
Returns a multi-line string representation of the parameters like : 'nam = val = val2...'.
GLsizei const GLchar ** string
T & operator[](const std::string &s)
The write (non-const) version of the [] operator.
iterator find(const std::string &key)
T operator[](const std::string &s) const
A const version of the [] operator, for usage as read-only.
RET getWithDefaultVal(const std::string &s, const RET &defaultVal) const
A const version of the [] operator and with a default value in case the parameter is not set (for usa...
const_iterator find(const std::string &key) const
TParameters(std::initializer_list< typename BASE::value_type > init)
Constructor with a list of initial values (see the description and use example in mrpt::system::TPara...
void dumpToConsole() const
Dumps to console the output from getAsString()
typename BASE::const_iterator const_iterator
typename BASE::iterator iterator
For usage when passing a dynamic number of (numeric) arguments to a function, by name.
void getAsString(std::string &s) const
Returns a multi-line string representation of the parameters like : 'nam = val = val2...'.