7 #include "XmlRpcValue.h"
14 using YarpXmlRpc::XmlRpcValue;
20 case XmlRpcValue::TypeInt:
23 case XmlRpcValue::TypeDouble:
24 return Value((
double)v);
26 case XmlRpcValue::TypeString:
28 std::string s = (std::string)v;
29 if (s.length()==0 || s[0]!=
'[') {
38 case XmlRpcValue::TypeArray:
42 for (
int i=0; i<v.size(); i++) {
43 XmlRpcValue& v2 = v[i];
44 if (v2.getType()!=XmlRpcValue::TypeInvalid) {
48 if (tag==
"list"||tag==
"dict") {
60 case XmlRpcValue::TypeStruct:
64 XmlRpcValue::ValueStruct& vals = v;
66 for (
auto& val : vals) {
67 XmlRpcValue& v2 = val.second;
70 if (v2.getType()!=XmlRpcValue::TypeInvalid) {
77 case XmlRpcValue::TypeInvalid:
82 return Value(
"(type not supported yet out of laziness)");
104 client.read(
"POST /RP");
106 server.read(
"POST /RP");
111 Bytes bytes(buf,
sizeof(buf));
113 int result2 = delegate->getInputStream().partialRead(bytes);
117 std::string s(buf,result2);
130 client.parseResponse(xresult);
132 cprefix = server.parseRequest(xresult);
133 bool isAdmin =
false;
135 if (cprefix==
"publisherUpdate") {
138 if (cprefix==
"requestTopic") {
141 if (cprefix==
"getPid") {
144 if (cprefix==
"getBusInfo") {
148 prefix = isAdmin?
"a\n":
"d\n";
155 sis.reset(prefix + v.
toString() +
"\n");
157 sis.reset(prefix +
"\n");
160 result = sis.read(b);
166 return (result>0)?result:-1;
172 delegate->getOutputStream().write(b);
const yarp::os::LogComponent & XMLRPCCARRIER()
Value toValue(XmlRpcValue &v, bool outer)
void write(const yarp::os::Bytes &b) override
Write a block of bytes to the stream.
A simple collection of objects that can be described and transmitted in a portable way.
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A simple abstraction for a block of bytes.
A single value (typically within a Bottle).
static Value & getNullValue()
Return an invalid, "null" Value.
virtual Bottle * asList() const
Get list value.
std::string toString() const override
Return a standard text representation of the content of the object.
bool isNull() const override
Checks if the object is invalid.
void fromString(const char *str)
Set value to correspond to a textual representation.
virtual std::string asString() const
Get string value.
#define yCTrace(component,...)
An interface to the operating system, including Port based communication.