Public Types | Public Member Functions | Public Attributes | List of all members
cras::GetParamOptions< ResultType, ParamServerType > Struct Template Reference

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 >
GetParamOptionsoperator= (const ::cras::GetParamOptions< R1, P1 > &other)
 Assign from options of a different type. Only the non-function members are copied! More...
 
GetParamOptionsoperator= (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...
 

Detailed Description

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
struct cras::GetParamOptions< ResultType, ParamServerType >

Options specifying behavior of getParam() calls.

Note
For easy usage in getParam() calls, use the braced initializer syntax, e.g. {.printMessages = false}.
Template Parameters
ResultTypeType of getParam() result.
ParamServerTypeType of the intermediate value to which the XmlRpcValue should be converted.

Definition at line 115 of file get_param_options.hpp.

Member Typedef Documentation

◆ ToParamFn

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
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.

Parameters
[in]xmlValueThe XmlRpcValue read from parameter server.
[out]valueThe converted value. It is not valid if this function returns false.
[in]skipNonConvertibleIf 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]errorsIf non-null, any error messages coming from the conversion can be appended to this list.
Returns
Whether the conversion succeeded.
Note
This function should not throw.

Definition at line 141 of file get_param_options.hpp.

◆ ToResultFn

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
typedef ::std::function<ResultType(const ParamServerType& value)> cras::GetParamOptions< ResultType, ParamServerType >::ToResultFn

Function converting ParamServerType values to ResultType.

Parameters
[in]valueThe value to convert.
Returns
The converted value.
Exceptions
std::runtime_errorIf the conversion failed.

Definition at line 123 of file get_param_options.hpp.

Member Function Documentation

◆ asType()

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
template<typename NewParamServerType >
::cras::GetParamOptions<ResultType, NewParamServerType> cras::GetParamOptions< ResultType, ParamServerType >::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
inline

Convert this options object to a similar object with a different ParamServerType.

Template Parameters
NewParamServerTypeThe new ParamServerType.
Parameters
[in]newToResultNew toResult function.
[in]newParamToStrNew paramToStr function.
[in]newToParamNew toParam function.
Returns
The new options object.

Definition at line 222 of file get_param_options.hpp.

◆ operator=() [1/2]

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
template<typename R1 , typename P1 >
GetParamOptions& cras::GetParamOptions< ResultType, ParamServerType >::operator= ( const ::cras::GetParamOptions< R1, P1 > &  other)
inline

Assign from options of a different type. Only the non-function members are copied!

Template Parameters
R1Other ResultType.
P1Other ParamServerType.
Parameters
otherThe options to copy from.
Returns
This.

Definition at line 182 of file get_param_options.hpp.

◆ operator=() [2/2]

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
GetParamOptions& cras::GetParamOptions< ResultType, ParamServerType >::operator= ( const ::cras::GetParamOptions< ResultType, ParamServerType > &  other)
inline

Assign from options of the same type. Non-function members are also copied.

Parameters
otherThe options to copy from.
Returns
This.

Definition at line 198 of file get_param_options.hpp.

Member Data Documentation

◆ allowNestedParams

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
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.

◆ origNamespace

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
::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.

◆ origParamName

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
::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.

◆ paramToStr

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
::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.

◆ printDefaultAsWarn

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
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.

◆ printMessages

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
bool cras::GetParamOptions< ResultType, ParamServerType >::printMessages {true}

Whether to print error messages to log.

Definition at line 144 of file get_param_options.hpp.

◆ resultToStr

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
::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.

◆ throwIfConvertFails

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
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.

◆ toParam

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
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.

◆ toResult

template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
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.


The documentation for this struct was generated from the following file:


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sat Jun 17 2023 02:32:53