29 template<
typename ResultType,
typename ParamServerType>
38 static ResultType
toResult(
const ParamServerType& value)
40 return static_cast<ResultType
>(value);
51 template<
typename ParamServerType>
66 static bool toParam(const ::XmlRpc::XmlRpcValue& x, ParamServerType& v,
bool skipNonConvertible =
false,
67 ::std::list<::std::string>* errors =
nullptr)
101 template<
typename ResultType>
114 template<typename ResultType, typename ParamServerType = typename ::cras::DefaultParamServerType<ResultType>::type>
123 typedef ::std::function<ResultType(const ParamServerType& value)>
ToResultFn;
137 typedef ::std::function<bool(
138 const ::XmlRpc::XmlRpcValue& xmlValue,
139 ParamServerType& value,
140 const bool skipNonConvertible,
144 bool printMessages {
true};
147 bool printDefaultAsWarn {
false};
151 bool throwIfConvertFails {
false};
154 bool allowNestedParams {
true};
157 ::std::string origNamespace {};
160 ::std::string origParamName {};
181 template<
typename R1,
typename P1>
185 this->printDefaultAsWarn = other.printDefaultAsWarn;
186 this->throwIfConvertFails = other.throwIfConvertFails;
187 this->allowNestedParams = other.allowNestedParams;
188 this->origNamespace = other.origNamespace;
189 this->origParamName = other.origParamName;
201 this->printDefaultAsWarn = other.printDefaultAsWarn;
202 this->throwIfConvertFails = other.throwIfConvertFails;
203 this->allowNestedParams = other.allowNestedParams;
204 this->origNamespace = other.origNamespace;
205 this->origParamName = other.origParamName;
206 this->paramToStr = other.paramToStr;
207 this->resultToStr = other.resultToStr;
208 this->toResult = other.toResult;
209 this->toParam = other.toParam;
221 template<
typename NewParamServerType>
223 typename ::cras::GetParamOptions<ResultType, NewParamServerType>::ToResultFn newToResult =
227 typename ::cras::GetParamOptions<ResultType, NewParamServerType>::ToParamFn newToParam =
228 [](const ::XmlRpc::XmlRpcValue& x, NewParamServerType& v,
bool skipNonConvertible =
false,
229 ::std::list<::std::string>* errors =
nullptr) ->
bool {
235 {{}, {}, {}, {}, {}, {}, {}, {}, newToResult, newToParam};
inline ::std::string to_string(const ::Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &value)
Default function for converting values to string in getParam(Verbose) functions. Uses cras::to_string...
::cras::ToStringFn< ParamServerType > paramToStr
A function that converts ParamServerType values to string for use in log messages.
GetParamOptions & operator=(const ::cras::GetParamOptions< R1, P1 > &other)
Assign from options of a different type. Only the non-function members are copied! ...
::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. ...
Default function for converting param server types to result types.
::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. ...
bool printMessages
Whether to print error messages to log.
Utilities for working with XmlRpcValues.
::std::string to_string(const T &value)
Convert the given value to a string representation.
::cras::ToStringFn< ResultType > resultToStr
A function that converts ResultType values to string for use in log messages.
GetParamOptions & operator=(const ::cras::GetParamOptions< ResultType, ParamServerType > &other)
Assign from options of the same type. Non-function members are also copied.
Default ParamServerType for the given ResultType.
::std::function< ResultType(const ParamServerType &value)> ToResultFn
Function converting ParamServerType values to ResultType.
static bool toParam(const ::XmlRpc::XmlRpcValue &x, ParamServerType &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
Function converting XmlRpcValue to an intermediate value of type ParamServerType. ...
bool convert(const ::XmlRpc::XmlRpcValue &x, ::XmlRpc::XmlRpcValue &v, bool=false, ::std::list<::std::string > *errors=nullptr)
Convert XmlRpcValue x to value v.
static ResultType toResult(const ParamServerType &value)
Function converting ParamServerType values to ResultType.
Default function for converting XmlRpcValue to an intermediate value of type ParamServerType.
ResultType type
The ParamServerType to be used as intermediate type when reading values of type ResultType.
Options specifying behavior of getParam() calls.
Utils for working with strings.
::std::function<::std::string(const T &)> ToStringFn
Type of function that converts anything to a string.