Skip to content
Snippets Groups Projects
Commit 6c227297 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[BL] Add getConfigAttribute with default value.

Update documentation mismatches in other getConfigAttribute*().
parent 587cd92a
No related branches found
No related tags found
No related merge requests found
......@@ -187,6 +187,16 @@ getConfigAttribute(std::string const& attr) const
error("Did not find XML attribute with name \"" + attr + "\".");
}
template <typename T>
T ConfigTree::getConfigAttribute(std::string const& attr,
T const& default_value) const
{
if (auto a = getConfigAttributeOptional<T>(attr))
return *a;
return default_value;
}
template<typename T>
boost::optional<T>
ConfigTree::
......
......@@ -364,18 +364,32 @@ public:
/*! Get XML attribute \c attr of type \c T for the current parameter.
*
* \return the requested attribute
* \return the requested attribute's value.
*
* \pre \c param must not have been read before from this ConfigTree.
* \pre \c attr must not have been read before from the current parameter.
*/
template<typename T> T
getConfigAttribute(std::string const& attr) const;
/*! Get XML attribute \c attr of type \c T for the current parameter if present.
/*! Get XML attribute \c attr of type \c T for the current parameter or the
* \c default_value.
*
* \return the requested attribute
* This method has a similar behaviour as getConfigAttribute(std::string
* const&) except in case of errors the \c default_value is returned.
*
* \pre \c param must not have been read before from this ConfigTree.
* \return the requested attribute's value.
*
* \pre \c attr must not have been read before from the current parameter.
*/
template <typename T>
T getConfigAttribute(std::string const& attr, T const& default_value) const;
/*! Get XML attribute \c attr of type \c T for the current parameter if
* present.
*
* \return the requested attribute's value.
*
* \pre \c attr must not have been read before from the current parameter.
*/
template<typename T> boost::optional<T>
getConfigAttributeOptional(std::string const& attr) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment