Options specifying behavior of getParam() calls. More...
#include <get_param_options.hpp>
Public Types | |
typedef ::std::function< bool(const ::XmlRpc::XmlRpcValue &xmlValue, ParamServerType &value, const bool skipNonConvertible, ::std::list<::std::string > *errors)> | ToParamFn |
Function converting XmlRpcValue to an intermediate value of type ParamServerType. More... | |
typedef ::std::function< ResultType(const ParamServerType &value)> | ToResultFn |
Function converting ParamServerType values to ResultType. More... | |
Public Member Functions | |
template<typename NewParamServerType > | |
::cras::GetParamOptions< ResultType, NewParamServerType > | asType (typename ::cras::GetParamOptions< ResultType, NewParamServerType >::ToResultFn newToResult=&::cras::DefaultToResultFn< ResultType, NewParamServerType >::toResult, ::cras::ToStringFn< NewParamServerType > newParamToStr=[](const NewParamServerType &s){ return ::cras::to_string(s);}, typename ::cras::GetParamOptions< ResultType, NewParamServerType >::ToParamFn newToParam=[](const ::XmlRpc::XmlRpcValue &x, NewParamServerType &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr) -> bool { return ::cras::convert(x, v, skipNonConvertible, errors);}) const |
Convert this options object to a similar object with a different ParamServerType. More... | |
template<typename R1 , typename P1 > | |
GetParamOptions & | operator= (const ::cras::GetParamOptions< R1, P1 > &other) |
Assign from options of a different type. Only the non-function members are copied! More... | |
GetParamOptions & | operator= (const ::cras::GetParamOptions< ResultType, ParamServerType > &other) |
Assign from options of the same type. Non-function members are also copied. More... | |
Public Attributes | |
bool | allowNestedParams {true} |
Allow parameters of form a/b/c (leads to recursive parsing of the sub-namespaces). More... | |
::std::string | origNamespace {} |
The human-friendly namespace to be reported in log messages. More... | |
::std::string | origParamName {} |
The human-friendly parameter name to be reported in log messages. More... | |
::cras::ToStringFn< ParamServerType > | paramToStr = &::cras::ParamToStringFn<ParamServerType>::to_string |
A function that converts ParamServerType values to string for use in log messages. More... | |
bool | printDefaultAsWarn {false} |
Whether defaulted parameters are reported as warning or info level messages. More... | |
bool | printMessages {true} |
Whether to print error messages to log. More... | |
::cras::ToStringFn< ResultType > | resultToStr = &::cras::ParamToStringFn<ResultType>::to_string |
A function that converts ResultType values to string for use in log messages. More... | |
bool | throwIfConvertFails {false} |
Throw GetParamException if any conversion fails. If false, the default value is used instead of a value that failed to convert. In such case, the log message is of error level. More... | |
ToParamFn | toParam = &::cras::DefaultToParamFn<ParamServerType>::toParam |
A function converting XmlRpcValue to an intermediate value of type ParamServerType. More... | |
ToResultFn | toResult = &::cras::DefaultToResultFn<ResultType, ParamServerType>::toResult |
A function converting ParamServerType values to ResultType. More... | |
Options specifying behavior of getParam() calls.
{.printMessages = false}
. ResultType | Type of getParam() result. |
ParamServerType | Type of the intermediate value to which the XmlRpcValue should be converted. |
Definition at line 115 of file get_param_options.hpp.
typedef ::std::function<bool( const ::XmlRpc::XmlRpcValue& xmlValue, ParamServerType& value, const bool skipNonConvertible, ::std::list<::std::string>* errors)> cras::GetParamOptions< ResultType, ParamServerType >::ToParamFn |
Function converting XmlRpcValue to an intermediate value of type ParamServerType.
[in] | xmlValue | The XmlRpcValue read from parameter server. |
[out] | value | The converted value. It is not valid if this function returns false. |
[in] | skipNonConvertible | If true and the target value is a container, all non-convertible items will be skipped. If false, non-convertible values mean failure of the whole conversion. If all items of a container are skipped (and there were some), the conversion also fails. |
[out] | errors | If non-null, any error messages coming from the conversion can be appended to this list. |
Definition at line 141 of file get_param_options.hpp.
typedef ::std::function<ResultType(const ParamServerType& value)> cras::GetParamOptions< ResultType, ParamServerType >::ToResultFn |
Function converting ParamServerType values to ResultType.
[in] | value | The value to convert. |
std::runtime_error | If the conversion failed. |
Definition at line 123 of file get_param_options.hpp.
|
inline |
Convert this options object to a similar object with a different ParamServerType.
NewParamServerType | The new ParamServerType. |
[in] | newToResult | New toResult function. |
[in] | newParamToStr | New paramToStr function. |
[in] | newToParam | New toParam function. |
Definition at line 222 of file get_param_options.hpp.
|
inline |
Assign from options of a different type. Only the non-function members are copied!
R1 | Other ResultType. |
P1 | Other ParamServerType. |
other | The options to copy from. |
Definition at line 182 of file get_param_options.hpp.
|
inline |
Assign from options of the same type. Non-function members are also copied.
other | The options to copy from. |
Definition at line 198 of file get_param_options.hpp.
bool cras::GetParamOptions< ResultType, ParamServerType >::allowNestedParams {true} |
Allow parameters of form a/b/c (leads to recursive parsing of the sub-namespaces).
Definition at line 154 of file get_param_options.hpp.
::std::string cras::GetParamOptions< ResultType, ParamServerType >::origNamespace {} |
The human-friendly namespace to be reported in log messages.
Definition at line 157 of file get_param_options.hpp.
::std::string cras::GetParamOptions< ResultType, ParamServerType >::origParamName {} |
The human-friendly parameter name to be reported in log messages.
Definition at line 160 of file get_param_options.hpp.
::cras::ToStringFn<ParamServerType> cras::GetParamOptions< ResultType, ParamServerType >::paramToStr = &::cras::ParamToStringFn<ParamServerType>::to_string |
A function that converts ParamServerType values to string for use in log messages.
Definition at line 163 of file get_param_options.hpp.
bool cras::GetParamOptions< ResultType, ParamServerType >::printDefaultAsWarn {false} |
Whether defaulted parameters are reported as warning or info level messages.
Definition at line 147 of file get_param_options.hpp.
bool cras::GetParamOptions< ResultType, ParamServerType >::printMessages {true} |
Whether to print error messages to log.
Definition at line 144 of file get_param_options.hpp.
::cras::ToStringFn<ResultType> cras::GetParamOptions< ResultType, ParamServerType >::resultToStr = &::cras::ParamToStringFn<ResultType>::to_string |
A function that converts ResultType values to string for use in log messages.
Definition at line 166 of file get_param_options.hpp.
bool cras::GetParamOptions< ResultType, ParamServerType >::throwIfConvertFails {false} |
Throw GetParamException if any conversion fails. If false, the default value is used instead of a value that failed to convert. In such case, the log message is of error level.
Definition at line 151 of file get_param_options.hpp.
ToParamFn cras::GetParamOptions< ResultType, ParamServerType >::toParam = &::cras::DefaultToParamFn<ParamServerType>::toParam |
A function converting XmlRpcValue to an intermediate value of type ParamServerType.
Definition at line 172 of file get_param_options.hpp.
ToResultFn cras::GetParamOptions< ResultType, ParamServerType >::toResult = &::cras::DefaultToResultFn<ResultType, ParamServerType>::toResult |
A function converting ParamServerType values to ResultType.
Definition at line 169 of file get_param_options.hpp.