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, ::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, int &v, bool=false, ::std::list<::std::string > *errors=nullptr)
 
LONG_MAX USHRT_MAX ULONG_LONG_MAX bool cras::convert (const ::XmlRpc::XmlRpcValue &x, double &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)
 
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::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::vector< T > &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::set< 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 , size_t N>
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::std::array< T, N > &v, bool skipNonConvertible=false, ::std::list<::std::string > *errors=nullptr)
 
bool cras::convert (const ::XmlRpc::XmlRpcValue &x, ::dynamic_reconfigure::Config &v, bool skipNonConvertible, ::std::list<::std::string > *errors)
 
 cras::DEFINE_INTEGRAL_CONVERT (short, int, SHRT_MIN, SHRT_MAX) DEFINE_INTEGRAL_CONVERT(long
 
LONG_MAX cras::DEFINE_INTEGRAL_CONVERT (long long, int, LONG_LONG_MIN, LONG_LONG_MAX) DEFINE_INTEGRAL_CONVERT(unsigned short
 
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; \
}
geometry_msgs::TransformStamped t
inline ::std::string format(const char *format, ::va_list args)
bool convert(const ::XmlRpc::XmlRpcValue &x, ::dynamic_reconfigure::Config &v, bool skipNonConvertible, ::std::list<::std::string > *errors)
constexpr const char * to_cstring(const ::XmlRpc::XmlRpcValue::Type &value)
Return a string representation of the XmlRpcValue type.

Definition at line 230 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; \
}
inline ::std::string to_string(const ::Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &value)
inline ::std::string format(const char *format, ::va_list args)
bool convert(const ::XmlRpc::XmlRpcValue &x, ::dynamic_reconfigure::Config &v, bool skipNonConvertible, ::std::list<::std::string > *errors)

Definition at line 154 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; \
}
inline ::std::string to_string(const ::Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > &value)
inline ::std::string format(const char *format, ::va_list args)
bool convert(const ::XmlRpc::XmlRpcValue &x, ::dynamic_reconfigure::Config &v, bool skipNonConvertible, ::std::list<::std::string > *errors)

Definition at line 102 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; \
}
geometry_msgs::TransformStamped t
inline ::std::string format(const char *format, ::va_list args)
bool convert(const ::XmlRpc::XmlRpcValue &x, ::dynamic_reconfigure::Config &v, bool skipNonConvertible, ::std::list<::std::string > *errors)
constexpr const char * to_cstring(const ::XmlRpc::XmlRpcValue::Type &value)
Return a string representation of the XmlRpcValue type.

Definition at line 284 of file xmlrpc_value_utils.hpp.



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