32 #include <boost/foreach.hpp> 33 #define forEach BOOST_FOREACH 37 : _data(data), _parent(parent), _path(path), _nh(nh)
66 for(
unsigned int i = 0; i <
_children.size(); i++) {
89 return QVariant( (
bool)val );
92 return QVariant( (
int)val );
95 return QVariant( (
double)val );
98 return QVariant( ((std::string)val).c_str() );
103 struct tm time = (
struct tm)val;
108 return QVariant( QDateTime(
114 QDate(time.tm_year + 1900, time.tm_mon + 1, time.tm_mday),
120 QTime(time.tm_hour, time.tm_min, time.tm_sec, ms)));
128 for(std::vector<char>::iterator it = bd.begin(); it != bd.end(); it++)
153 return it->first.c_str();
164 return QString(
"[%1]").arg(row);
215 bool setXmlOK =
false;
218 if(!val.canConvert(QVariant::Bool)) {
219 ROS_WARN(
"XmlRpcValue TypeBoolean -- setData cannot convert from QVariant type %d.", val.type());
223 (
bool&)(*
_data) = val.toBool();
228 if(!val.canConvert(QVariant::Int)) {
229 ROS_WARN(
"XmlRpcValue TypeInt -- setData cannot convert from QVariant type %d.", val.type());
233 int iVal = val.toInt(&ok);
236 (
int&)(*
_data) = iVal;
243 if(!val.canConvert(QVariant::Double)) {
244 ROS_WARN(
"XmlRpcValue TypeDouble -- setData cannot convert from QVariant type %d.", val.type());
250 double dVal = val.toDouble(&ok);
253 (
double&)(*
_data) = dVal;
259 if(!val.canConvert(QVariant::String)) {
260 ROS_WARN(
"XmlRpcValue TypeString -- setData cannot convert from QVariant type %d.", val.type());
264 (std::string&)(*
_data) = qPrintable(val.toString());
270 if(!val.canConvert(QVariant::DateTime)) {
271 ROS_WARN(
"XmlRpcValue TypeDateTime -- setData cannot convert from QVariant type %d.", val.type());
274 QDateTime dt = val.toDateTime();
278 time.tm_year = dt.date().year() - 1900;
279 time.tm_mon = dt.date().month() - 1;
280 time.tm_mday = dt.date().day();
281 time.tm_hour = dt.time().hour();
282 time.tm_min = dt.time().minute();
283 time.tm_sec = dt.time().second();
284 time.tm_wday = dt.date().dayOfWeek() - 1;
285 time.tm_yday = dt.date().dayOfYear() - 1;
290 (
struct tm &)(*
_data) = time;
298 if(!val.canConvert(QVariant::ByteArray)) {
299 ROS_WARN(
"XmlRpcValue TypeBase64 -- setData cannot convert from QVariant type %d.", val.type());
302 QByteArray ba = val.toByteArray();
304 for(
int i = 0; i < ba.size(); i++) {
305 bd.push_back(ba.at(i));
QVariant xmlToVariant(XmlRpc::XmlRpcValue &val) const
Convert a XmlRpcValue to QVariant - only leaf values are supported.
A wrapper around the XmlRpcValue including a parent pointer and convenience functions for the qt mode...
ValueStruct::iterator iterator
bool setData(QVariant val)
set data for this item
void setParam()
write this XmlRpcValue to parameter server (for array childs).
deque< XmlRpcTreeItem * > _children
Type const & getType() const
bool isBool(int row, int column) const
is the stored data a bool
void addChild(const std::string &name, XmlRpc::XmlRpcValue *childData)
Create a child from its data.
#define ROS_WARN_THROTTLE(period,...)
QVariant data(int row, int column) const
return the data in the map
int childIndexOf(const XmlRpcTreeItem *child) const
void createChildren()
Create all children based on data.
XmlRpc::XmlRpcValue * _data
XmlRpcTreeItem * child(unsigned int i)
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
int row() const
Figure out which row/nth child we are for the parent.
unsigned int childCount() const
std::vector< char > BinaryData
XmlRpcTreeItem(XmlRpc::XmlRpcValue *data, XmlRpcTreeItem *parent, const std::string &path, ros::NodeHandle *nh)