Go to the documentation of this file.
11 #include <mrpt/config.h>
56 using BASE = std::map<std::string, T>;
65 TParameters(std::initializer_list<typename BASE::value_type> init)
69 inline bool has(
const std::string& s)
const
79 using namespace std::string_literals;
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>
91 const std::string& s,
const RET& defaultVal)
const
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;
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...
iterator find(const std::string &key)
bool has(const std::string &s) const
T operator[](const std::string &s) const
A const version of the [] operator, for usage as read-only.
typename BASE::const_iterator const_iterator
TParameters()
Default constructor (initializes empty)
void dumpToConsole() const
Dumps to console the output from getAsString()
void getAsString(std::string &s) const
Returns a multi-line string representation of the parameters like : 'nam = val\nnam2 = val2....
iterator begin() noexcept
std::map< std::string, double > BASE
For usage when passing a dynamic number of (numeric) arguments to a function, by name.
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...
const_iterator end() const noexcept
std::string getAsString() const
Returns a multi-line string representation of the parameters like : 'nam = val\nnam2 = val2....
const_iterator find(const std::string &key) const
typename BASE::iterator iterator
T & operator[](const std::string &s)
The write (non-const) version of the [] operator.
const_iterator begin() const noexcept
Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020 | |