Namespaces | Macros | Functions | Variables
xmlrpc_value_utils.hpp File Reference

Utilities for working with XmlRpcValues. More...

#include <array>
#include <limits>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <dynamic_reconfigure/BoolParameter.h>
#include <dynamic_reconfigure/Config.h>
#include <dynamic_reconfigure/DoubleParameter.h>
#include <dynamic_reconfigure/IntParameter.h>
#include <dynamic_reconfigure/StrParameter.h>
#include <XmlRpcValue.h>
#include <XmlRpcException.h>
#include <cras_cpp_common/xmlrpc_value_traits.hpp>
Include dependency graph for xmlrpc_value_utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 cras
 
 XmlRpc
 

Macros

#define DEFINE_ARRAY_CONVERT(arrayType, insertFn)
 
#define DEFINE_DOUBLE_CONVERT(resultType, xmlType, minBound, maxBound)
 
#define DEFINE_INTEGRAL_CONVERT(resultType, xmlType, minBound, maxBound)
 
#define DEFINE_STRUCT_CONVERT(mapType)
 

Functions

bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::dynamic_reconfigure::Config &v, bool skipNonConvertible, ::std::list<::std::string > *errors)
 
template<typename T , size_t N>
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::array< T, N > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
template<typename T >
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::list< T > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
template<typename T >
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::map<::std::string, T > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
template<typename T >
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::set< T > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
template<typename T >
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::unordered_map<::std::string, T > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
template<typename T >
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::unordered_set< T > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
template<typename T >
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::vector< T > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::XmlRpc::XmlRpcValue &v, bool=false, ::std::list<::std::string > *errors=nullptr)
 Convert XmlRpcValue x to value v. More...
 
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, bool &v, bool=false, ::std::list<::std::string > *errors=nullptr)
 
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, double &v, bool=false, ::std::list<::std::string > *errors=nullptr)
 
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, int &v, bool=false, ::std::list<::std::string > *errors=nullptr)
 
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, std::string &v, bool=false, ::std::list<::std::string > *errors=nullptr)
 
LONG_MAX cras::DEFINE_INTEGRAL_CONVERT (long long, int, LONG_LONG_MIN, LONG_LONG_MAX) DEFINE_INTEGRAL_CONVERT(unsigned short
 
 cras::DEFINE_INTEGRAL_CONVERT (short, int, SHRT_MIN, SHRT_MAX) DEFINE_INTEGRAL_CONVERT(long
 
LONG_MAX USHRT_MAX cras::DEFINE_INTEGRAL_CONVERT (unsigned long, int, 0, ULONG_MAX) DEFINE_INTEGRAL_CONVERT(unsigned long long
 
void XmlRpc::PrintTo (const XmlRpcValue &value, ::std::ostream *os)
 

Variables

 cras::int
 
 cras::LONG_MIN
 

Detailed Description

Utilities for working with XmlRpcValues.

Author
Martin Pecka SPDX-License-Identifier: BSD-3-Clause SPDX-FileCopyrightText: Czech Technical University in Prague

Definition in file xmlrpc_value_utils.hpp.

Macro Definition Documentation

◆ DEFINE_ARRAY_CONVERT

#define DEFINE_ARRAY_CONVERT (   arrayType,
  insertFn 
)
Value:
template<typename T> \
inline bool convert(const ::XmlRpc::XmlRpcValue& x, arrayType<T>& v, bool skipNonConvertible, \
::std::list<::std::string>* errors) \
{ \
if (x.getType() != ::XmlRpc::XmlRpcValue::TypeArray) { \
if (errors != nullptr) \
errors->push_back(::cras::format("Cannot convert type %s to array.", ::cras::to_cstring(x.getType())));\
return false; \
} \
v.clear(); \
for (size_t i = 0; i < x.size(); ++i) \
{ \
T t; \
if (convert(x[i], t, skipNonConvertible, errors)) \
v.insertFn(t); \
else if (!skipNonConvertible) \
return false; \
} \
return v.size() > 0 || x.size() == 0; \
}

Definition at line 232 of file xmlrpc_value_utils.hpp.

◆ DEFINE_DOUBLE_CONVERT

#define DEFINE_DOUBLE_CONVERT (   resultType,
  xmlType,
  minBound,
  maxBound 
)
Value:
\
inline bool convert(const ::XmlRpc::XmlRpcValue& x, resultType& v, bool skipNonConvertible = false, \
::std::list<::std::string>* errors = nullptr) \
{ \
xmlType i; \
if (!convert(x, i, skipNonConvertible, errors)) \
return false; \
if (::std::isnan(i)) { v = ::std::numeric_limits<resultType>::quiet_NaN(); return true; } \
if (::std::isinf(i) && i > 0) { v = ::std::numeric_limits<resultType>::infinity(); return true; } \
if (::std::isinf(i) && i < 0) { v = -::std::numeric_limits<resultType>::infinity(); return true; } \
if (i < (minBound) || i > (maxBound)) { \
if (errors != nullptr) \
errors->push_back(::cras::format("Value %s is out of bounds <%s, %s>.", \
::cras::to_string(i).c_str(), ::cras::to_string(minBound).c_str(), ::cras::to_string(maxBound).c_str())); \
return false; \
} \
v = static_cast<resultType>(i); \
return true; \
}

Definition at line 156 of file xmlrpc_value_utils.hpp.

◆ DEFINE_INTEGRAL_CONVERT

#define DEFINE_INTEGRAL_CONVERT (   resultType,
  xmlType,
  minBound,
  maxBound 
)
Value:
\
inline bool convert(const ::XmlRpc::XmlRpcValue& x, resultType& v, bool skipNonConvertible = false, \
::std::list<::std::string>* errors = nullptr) \
{ \
xmlType i; \
if (!convert(x, i, skipNonConvertible, errors)) \
return false; \
if (i < (minBound) || i > (maxBound)) { \
if (errors != nullptr) \
errors->push_back(::cras::format("Value %s is out of bounds <%s, %s>.", \
::cras::to_string(i).c_str(), ::cras::to_string(minBound).c_str(), ::cras::to_string(maxBound).c_str())); \
return false; \
} \
v = static_cast<resultType>(i); \
return true; \
}

Definition at line 104 of file xmlrpc_value_utils.hpp.

◆ DEFINE_STRUCT_CONVERT

#define DEFINE_STRUCT_CONVERT (   mapType)
Value:
template<typename T> \
inline bool convert(const ::XmlRpc::XmlRpcValue& x, mapType<::std::string, T>& v, bool skipNonConvertible, \
::std::list<::std::string>* errors) \
{ \
if (x.getType() != ::XmlRpc::XmlRpcValue::TypeStruct) { \
if (errors != nullptr) \
errors->push_back(::cras::format("Cannot convert type %s to struct.", ::cras::to_cstring(x.getType())));\
return false; \
} \
v.clear(); \
for (auto it = x.begin(); it != x.end(); ++it) \
{ \
T t; \
if (convert(it->second, t, skipNonConvertible, errors)) \
v[it->first] = t; \
else if (!skipNonConvertible) \
return false; \
} \
return v.size() > 0 || x.size() == 0; \
}

Definition at line 286 of file xmlrpc_value_utils.hpp.

cras::to_cstring
constexpr const char * to_cstring(const ::XmlRpc::XmlRpcValue::Type &value)
Return a string representation of the XmlRpcValue type.
Definition: xmlrpc_value_traits.hpp:33
cras::format
inline ::std::string format(::std::string format,...)
Definition: string_utils.hpp:280
XmlRpc::XmlRpcValue::TypeStruct
TypeStruct
XmlRpc::XmlRpcValue::TypeArray
TypeArray
cras::to_string
inline ::std::string to_string(const ::Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &value)
Definition: string_utils/eigen.hpp:21
cras::convert
bool convert(const ::XmlRpc::XmlRpcValue &x, ::dynamic_reconfigure::Config &v, bool skipNonConvertible, ::std::list<::std::string > *errors)
Definition: xmlrpc_value_utils.hpp:311
t
geometry_msgs::TransformStamped t


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:04