XmlRpcValue.cpp
Go to the documentation of this file.
1 
2 #include "xmlrpcpp/XmlRpcValue.h"
4 #include "xmlrpcpp/XmlRpcUtil.h"
5 
6 #include <b64/encode.h>
7 #include <b64/decode.h>
8 
9 #ifndef MAKEDEPEND
10 # include <iostream>
11 # include <ostream>
12 # include <stdlib.h>
13 # include <stdio.h>
14 #endif
15 
16 #include <sstream>
17 #include <mutex>
18 #include <vector>
19 
20 namespace XmlRpc {
21 
22 
23  static const char VALUE_TAG[] = "<value>";
24  static const char VALUE_ETAG[] = "</value>";
25 
26  static const char BOOLEAN_TAG[] = "<boolean>";
27  static const char BOOLEAN_ETAG[] = "</boolean>";
28  static const char DOUBLE_TAG[] = "<double>";
29  static const char DOUBLE_ETAG[] = "</double>";
30  static const char INT_TAG[] = "<int>";
31  static const char I4_TAG[] = "<i4>";
32  static const char I4_ETAG[] = "</i4>";
33  static const char STRING_TAG[] = "<string>";
34  static const char DATETIME_TAG[] = "<dateTime.iso8601>";
35  static const char DATETIME_ETAG[] = "</dateTime.iso8601>";
36  static const char BASE64_TAG[] = "<base64>";
37  static const char BASE64_ETAG[] = "</base64>";
38 
39  static const char ARRAY_TAG[] = "<array>";
40  static const char DATA_TAG[] = "<data>";
41  static const char DATA_ETAG[] = "</data>";
42  static const char ARRAY_ETAG[] = "</array>";
43 
44  static const char STRUCT_TAG[] = "<struct>";
45  static const char MEMBER_TAG[] = "<member>";
46  static const char NAME_TAG[] = "<name>";
47  static const char NAME_ETAG[] = "</name>";
48  static const char MEMBER_ETAG[] = "</member>";
49  static const char STRUCT_ETAG[] = "</struct>";
50 
51 
52 
53  // Format strings
54  std::string XmlRpcValue::_doubleFormat("%.16g");
55 
56 
57 
58  // Clean up
60  {
61  switch (_type) {
62  case TypeString: delete _value.asString; break;
63  case TypeDateTime: delete _value.asTime; break;
64  case TypeBase64: delete _value.asBinary; break;
65  case TypeArray: delete _value.asArray; break;
66  case TypeStruct: delete _value.asStruct; break;
67  default: break;
68  }
70  _value.asBinary = 0;
71  }
72 
73 
74  // Type checking
76  {
77  if (_type != t)
78  throw XmlRpcException("type error");
79  }
80 
82  {
83  if (_type == TypeInvalid)
84  {
85  _type = t;
86  switch (_type) { // Ensure there is a valid value for the type
87  case TypeString: _value.asString = new std::string(); break;
88  case TypeDateTime: _value.asTime = new struct tm(); break;
89  case TypeBase64: _value.asBinary = new BinaryData(); break;
90  case TypeArray: _value.asArray = new ValueArray(); break;
91  case TypeStruct: _value.asStruct = new ValueStruct(); break;
92  default: _value.asBinary = 0; break;
93  }
94  }
95  else if (_type != t)
96  throw XmlRpcException("type error");
97  }
98 
99  void XmlRpcValue::assertArray(int size) const
100  {
101  if (_type != TypeArray)
102  throw XmlRpcException("type error: expected an array");
103  else if (int(_value.asArray->size()) < size)
104  throw XmlRpcException("range error: array index too large");
105  }
106 
107 
109  {
110  if (_type == TypeInvalid) {
111  _type = TypeArray;
112  _value.asArray = new ValueArray(size);
113  } else if (_type == TypeArray) {
114  if (int(_value.asArray->size()) < size)
115  _value.asArray->resize(size);
116  } else
117  throw XmlRpcException("type error: expected an array");
118  }
119 
121  {
122  if (_type != TypeStruct)
123  throw XmlRpcException("type error: expected a struct");
124  }
125 
127  {
128  if (_type == TypeInvalid) {
129  _type = TypeStruct;
130  _value.asStruct = new ValueStruct();
131  } else if (_type != TypeStruct)
132  throw XmlRpcException("type error: expected a struct");
133  }
134 
135 
136  // Operators
138  {
139  if (this != &rhs)
140  {
141  invalidate();
142  _type = rhs._type;
143  switch (_type) {
144  case TypeBoolean: _value.asBool = rhs._value.asBool; break;
145  case TypeInt: _value.asInt = rhs._value.asInt; break;
146  case TypeDouble: _value.asDouble = rhs._value.asDouble; break;
147  case TypeDateTime: _value.asTime = new struct tm(*rhs._value.asTime); break;
148  case TypeString: _value.asString = new std::string(*rhs._value.asString); break;
149  case TypeBase64: _value.asBinary = new BinaryData(*rhs._value.asBinary); break;
150  case TypeArray: _value.asArray = new ValueArray(*rhs._value.asArray); break;
151  case TypeStruct: _value.asStruct = new ValueStruct(*rhs._value.asStruct); break;
152  default: _value.asBinary = 0; break;
153  }
154  }
155  return *this;
156  }
157 
158 
159  // Predicate for tm equality
160  static bool tmEq(struct tm const& t1, struct tm const& t2) {
161  return t1.tm_sec == t2.tm_sec && t1.tm_min == t2.tm_min &&
162  t1.tm_hour == t2.tm_hour && t1.tm_mday == t2.tm_mday &&
163  t1.tm_mon == t2.tm_mon && t1.tm_year == t2.tm_year;
164  }
165 
166  bool XmlRpcValue::operator==(XmlRpcValue const& other) const
167  {
168  if (_type != other._type)
169  return false;
170 
171  switch (_type) {
172  case TypeBoolean: return ( !_value.asBool && !other._value.asBool) ||
173  ( _value.asBool && other._value.asBool);
174  case TypeInt: return _value.asInt == other._value.asInt;
175  case TypeDouble: return _value.asDouble == other._value.asDouble;
176  case TypeDateTime: return tmEq(*_value.asTime, *other._value.asTime);
177  case TypeString: return *_value.asString == *other._value.asString;
178  case TypeBase64: return *_value.asBinary == *other._value.asBinary;
179  case TypeArray: return *_value.asArray == *other._value.asArray;
180 
181  // The map<>::operator== requires the definition of value< for kcc
182  case TypeStruct: //return *_value.asStruct == *other._value.asStruct;
183  {
184  if (_value.asStruct->size() != other._value.asStruct->size())
185  return false;
186 
187  ValueStruct::const_iterator it1=_value.asStruct->begin();
188  ValueStruct::const_iterator it2=other._value.asStruct->begin();
189  while (it1 != _value.asStruct->end()) {
190  const XmlRpcValue& v1 = it1->second;
191  const XmlRpcValue& v2 = it2->second;
192  if ( ! (v1 == v2))
193  return false;
194  it1++;
195  it2++;
196  }
197  return true;
198  }
199  default: break;
200  }
201  return true; // Both invalid values ...
202  }
203 
204  bool XmlRpcValue::operator!=(XmlRpcValue const& other) const
205  {
206  return !(*this == other);
207  }
208 
209 
210  // Works for strings, binary data, arrays, and structs.
211  int XmlRpcValue::size() const
212  {
213  switch (_type) {
214  case TypeString: return int(_value.asString->size());
215  case TypeBase64: return int(_value.asBinary->size());
216  case TypeArray: return int(_value.asArray->size());
217  case TypeStruct: return int(_value.asStruct->size());
218  default: break;
219  }
220 
221  throw XmlRpcException("type error");
222  }
223 
224  // Checks for existence of struct member
225  bool XmlRpcValue::hasMember(const std::string& name) const
226  {
227  return _type == TypeStruct && _value.asStruct->find(name) != _value.asStruct->end();
228  }
229 
230  // Set the value from xml. The chars at *offset into valueXml
231  // should be the start of a <value> tag. Destroys any existing value.
232  bool XmlRpcValue::fromXml(std::string const& valueXml, int* offset)
233  {
234  if (offset == NULL) return false;
235 
236  int savedOffset = *offset;
237 
238  invalidate();
239  if ( ! XmlRpcUtil::nextTagIs(VALUE_TAG, valueXml, offset))
240  return false; // Not a value, offset not updated
241 
242  int afterValueOffset = *offset;
243  std::string typeTag = XmlRpcUtil::getNextTag(valueXml, offset);
244  bool result = false;
245  if (typeTag == BOOLEAN_TAG)
246  result = boolFromXml(valueXml, offset);
247  else if (typeTag == I4_TAG || typeTag == INT_TAG)
248  result = intFromXml(valueXml, offset);
249  else if (typeTag == DOUBLE_TAG)
250  result = doubleFromXml(valueXml, offset);
251  else if (typeTag.empty() || typeTag == STRING_TAG)
252  result = stringFromXml(valueXml, offset);
253  else if (typeTag == DATETIME_TAG)
254  result = timeFromXml(valueXml, offset);
255  else if (typeTag == BASE64_TAG)
256  result = binaryFromXml(valueXml, offset);
257  else if (typeTag == ARRAY_TAG)
258  result = arrayFromXml(valueXml, offset);
259  else if (typeTag == STRUCT_TAG)
260  result = structFromXml(valueXml, offset);
261  // Watch for empty/blank strings with no <string>tag
262  else if (typeTag == VALUE_ETAG)
263  {
264  *offset = afterValueOffset; // back up & try again
265  result = stringFromXml(valueXml, offset);
266  }
267 
268  if (result) // Skip over the </value> tag
269  XmlRpcUtil::findTag(VALUE_ETAG, valueXml, offset);
270  else // Unrecognized tag after <value>
271  *offset = savedOffset;
272 
273  return result;
274  }
275 
276  // Encode the Value in xml
277  std::string XmlRpcValue::toXml() const
278  {
279  switch (_type) {
280  case TypeBoolean: return boolToXml();
281  case TypeInt: return intToXml();
282  case TypeDouble: return doubleToXml();
283  case TypeString: return stringToXml();
284  case TypeDateTime: return timeToXml();
285  case TypeBase64: return binaryToXml();
286  case TypeArray: return arrayToXml();
287  case TypeStruct: return structToXml();
288  default: break;
289  }
290  return std::string(); // Invalid value
291  }
292 
293 
294  // Boolean
295  bool XmlRpcValue::boolFromXml(std::string const& valueXml, int* offset)
296  {
297  const char* valueStart = valueXml.c_str() + *offset;
298  char* valueEnd;
299  long ivalue = strtol(valueStart, &valueEnd, 10);
300  if (valueEnd == valueStart || (ivalue != 0 && ivalue != 1))
301  return false;
302 
303  _type = TypeBoolean;
304  _value.asBool = (ivalue == 1);
305  *offset += int(valueEnd - valueStart);
306  return true;
307  }
308 
309  std::string XmlRpcValue::boolToXml() const
310  {
311  std::string xml = VALUE_TAG;
312  xml += BOOLEAN_TAG;
313  xml += (_value.asBool ? "1" : "0");
314  xml += BOOLEAN_ETAG;
315  xml += VALUE_ETAG;
316  return xml;
317  }
318 
319  // Int
320  bool XmlRpcValue::intFromXml(std::string const& valueXml, int* offset)
321  {
322  const char* valueStart = valueXml.c_str() + *offset;
323  char* valueEnd;
324  long ivalue = strtol(valueStart, &valueEnd, 10);
325  if (valueEnd == valueStart)
326  return false;
327 
328  _type = TypeInt;
329  _value.asInt = int(ivalue);
330  *offset += int(valueEnd - valueStart);
331  return true;
332  }
333 
334  std::string XmlRpcValue::intToXml() const
335  {
336  char buf[256];
337  std::snprintf(buf, sizeof(buf)-1, "%d", _value.asInt);
338  buf[sizeof(buf)-1] = 0;
339  std::string xml = VALUE_TAG;
340  xml += I4_TAG;
341  xml += buf;
342  xml += I4_ETAG;
343  xml += VALUE_ETAG;
344  return xml;
345  }
346 
347  // Double
348  bool XmlRpcValue::doubleFromXml(std::string const& valueXml, int* offset)
349  {
350  const char* valueStart = valueXml.c_str() + *offset;
351  char* valueEnd;
352 
353  // ticket #2438
354  // push/pop the locale here. Value 123.45 can get read by strtod
355  // as '123', if the locale expects a comma instead of dot.
356  // if there are locale problems, silently continue.
357  std::string tmplocale;
358  char* locale_cstr = setlocale(LC_NUMERIC, 0);
359  if (locale_cstr)
360  {
361  tmplocale = locale_cstr;
362  setlocale(LC_NUMERIC, "POSIX");
363  }
364 
365  double dvalue = strtod(valueStart, &valueEnd);
366 
367  if (tmplocale.size() > 0) {
368  setlocale(LC_NUMERIC, tmplocale.c_str());
369  }
370 
371  if (valueEnd == valueStart)
372  return false;
373 
374  _type = TypeDouble;
375  _value.asDouble = dvalue;
376  *offset += int(valueEnd - valueStart);
377  return true;
378  }
379 
380  std::string XmlRpcValue::doubleToXml() const
381  {
382  // ticket #2438
383  std::stringstream ss;
384  ss.imbue(std::locale::classic()); // ensure we're using "C" locale for formatting floating-point (1.4 vs. 1,4, etc.)
385  ss.precision(17);
386  ss << _value.asDouble;
387 
388  std::string xml = VALUE_TAG;
389  xml += DOUBLE_TAG;
390  xml += ss.str();
391  xml += DOUBLE_ETAG;
392  xml += VALUE_ETAG;
393  return xml;
394  }
395 
396  // String
397  bool XmlRpcValue::stringFromXml(std::string const& valueXml, int* offset)
398  {
399  size_t valueEnd = valueXml.find('<', *offset);
400  if (valueEnd == std::string::npos)
401  return false; // No end tag;
402 
403  _type = TypeString;
404  _value.asString = new std::string(XmlRpcUtil::xmlDecode(valueXml.substr(*offset, valueEnd-*offset)));
405  *offset += int(_value.asString->length());
406  return true;
407  }
408 
409  std::string XmlRpcValue::stringToXml() const
410  {
411  std::string xml = VALUE_TAG;
412  //xml += STRING_TAG; optional
413  xml += XmlRpcUtil::xmlEncode(*_value.asString);
414  //xml += STRING_ETAG;
415  xml += VALUE_ETAG;
416  return xml;
417  }
418 
419  // DateTime (stored as a struct tm)
420  bool XmlRpcValue::timeFromXml(std::string const& valueXml, int* offset)
421  {
422  size_t valueEnd = valueXml.find('<', *offset);
423  if (valueEnd == std::string::npos)
424  return false; // No end tag;
425 
426  std::string stime = valueXml.substr(*offset, valueEnd-*offset);
427 
428  struct tm t;
429 #ifdef _MSC_VER
430  if (sscanf_s(stime.c_str(),"%4d%2d%2dT%2d:%2d:%2d",&t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec) != 6)
431 #else
432  if (sscanf(stime.c_str(),"%4d%2d%2dT%2d:%2d:%2d",&t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec) != 6)
433 #endif
434  return false;
435 
436  t.tm_isdst = -1;
438  _value.asTime = new struct tm(t);
439  *offset += int(stime.length());
440  return true;
441  }
442 
443  std::string XmlRpcValue::timeToXml() const
444  {
445  struct tm* t = _value.asTime;
446  char buf[20];
447  std::snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
448  t->tm_year,t->tm_mon,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
449  buf[sizeof(buf)-1] = 0;
450 
451  std::string xml = VALUE_TAG;
452  xml += DATETIME_TAG;
453  xml += buf;
454  xml += DATETIME_ETAG;
455  xml += VALUE_ETAG;
456  return xml;
457  }
458 
459  namespace {
460  std::size_t base64EncodedSize(std::size_t raw_size)
461  {
462  // encoder will still write to output buffer for empty input.
463  if (raw_size == 0) return 1;
464 
465  // 4 encoded character per 3 input bytes, rounded up,
466  // plus a newline character per 72 output characters, rounded up.
467  std::size_t encoded = (raw_size + 2) / 3 * 4;
468  encoded += (encoded + 71) / 72;
469  return encoded;
470  }
471 
472  std::size_t base64DecodedSize(std::size_t encoded_size)
473  {
474  // decoded will still write to output buffer for empty input.
475  if (encoded_size == 0) return 1;
476 
477  // 3 decoded bytes per 4 encoded characters, rounded up just to be sure.
478  return (encoded_size + 3) / 4 * 3;
479  }
480 
481  }
482 
483  // Base64
484  bool XmlRpcValue::binaryFromXml(std::string const& valueXml, int* offset)
485  {
486  size_t valueEnd = valueXml.find('<', *offset);
487  if (valueEnd == std::string::npos)
488  return false; // No end tag;
489 
490  std::size_t encoded_size = valueEnd - *offset;
491 
492 
493  _type = TypeBase64;
494  // might reserve too much, we'll shrink later
495  _value.asBinary = new BinaryData(base64DecodedSize(encoded_size), '\0');
496 
497  base64::decoder decoder;
498  std::size_t size = decoder.decode(&valueXml[*offset], encoded_size, &(*_value.asBinary)[0]);
499  _value.asBinary->resize(size);
500 
501  *offset += encoded_size;
502  return true;
503  }
504 
505  std::string XmlRpcValue::binaryToXml() const
506  {
507  // Wrap with xml
508  std::string xml = VALUE_TAG;
509  xml += BASE64_TAG;
510 
511  std::size_t offset = xml.size();
512  // might reserve too much, we'll shrink later
513  xml.resize(xml.size() + base64EncodedSize(_value.asBinary->size()));
514 
515  base64::encoder encoder;
516  offset += encoder.encode(_value.asBinary->data(), _value.asBinary->size(), &xml[offset]);
517  offset += encoder.encode_end(&xml[offset]);
518  xml.resize(offset);
519 
520  xml += BASE64_ETAG;
521  xml += VALUE_ETAG;
522  return xml;
523  }
524 
525 
526  // Array
527  bool XmlRpcValue::arrayFromXml(std::string const& valueXml, int* offset)
528  {
529  if ( ! XmlRpcUtil::nextTagIs(DATA_TAG, valueXml, offset))
530  return false;
531 
532  _type = TypeArray;
533  _value.asArray = new ValueArray;
534  XmlRpcValue v;
535  while (v.fromXml(valueXml, offset))
536  _value.asArray->push_back(v); // copy...
537 
538  // Skip the trailing </data>
539  (void) XmlRpcUtil::nextTagIs(DATA_ETAG, valueXml, offset);
540  return true;
541  }
542 
543 
544  // In general, its preferable to generate the xml of each element of the
545  // array as it is needed rather than glomming up one big string.
546  std::string XmlRpcValue::arrayToXml() const
547  {
548  std::string xml = VALUE_TAG;
549  xml += ARRAY_TAG;
550  xml += DATA_TAG;
551 
552  int s = int(_value.asArray->size());
553  for (int i=0; i<s; ++i)
554  xml += _value.asArray->at(i).toXml();
555 
556  xml += DATA_ETAG;
557  xml += ARRAY_ETAG;
558  xml += VALUE_ETAG;
559  return xml;
560  }
561 
562 
563  // Struct
564  bool XmlRpcValue::structFromXml(std::string const& valueXml, int* offset)
565  {
566  _type = TypeStruct;
567  _value.asStruct = new ValueStruct;
568 
569  while (XmlRpcUtil::nextTagIs(MEMBER_TAG, valueXml, offset)) {
570  // name
571  const std::string name = XmlRpcUtil::nextTagData(NAME_TAG, valueXml, offset);
572  // value
573  XmlRpcValue val(valueXml, offset);
574  if ( ! val.valid()) {
575  invalidate();
576  return false;
577  }
578  const std::pair<const std::string, XmlRpcValue> p(name, val);
579  _value.asStruct->insert(p);
580 
581  (void) XmlRpcUtil::nextTagIs(MEMBER_ETAG, valueXml, offset);
582  }
583  return true;
584  }
585 
586 
587  // In general, its preferable to generate the xml of each element
588  // as it is needed rather than glomming up one big string.
589  std::string XmlRpcValue::structToXml() const
590  {
591  std::string xml = VALUE_TAG;
592  xml += STRUCT_TAG;
593 
594  ValueStruct::const_iterator it;
595  for (it=_value.asStruct->begin(); it!=_value.asStruct->end(); ++it) {
596  xml += MEMBER_TAG;
597  xml += NAME_TAG;
598  xml += XmlRpcUtil::xmlEncode(it->first);
599  xml += NAME_ETAG;
600  xml += it->second.toXml();
601  xml += MEMBER_ETAG;
602  }
603 
604  xml += STRUCT_ETAG;
605  xml += VALUE_ETAG;
606  return xml;
607  }
608 
609 
610 
611  // Write the value without xml encoding it
612  std::ostream& XmlRpcValue::write(std::ostream& os) const {
613  switch (_type) {
614  default: break;
615  case TypeBoolean: os << _value.asBool; break;
616  case TypeInt: os << _value.asInt; break;
617  case TypeDouble:
618  {
619  static std::once_flag once;
620  char buf[128]; // Should be long enough
621  int required_size = std::snprintf(buf, sizeof(buf)-1,
622  getDoubleFormat().c_str(), _value.asDouble);
623  if (required_size < 0) {
624  std::call_once(once,
625  [](){XmlRpcUtil::error("Failed to format with %s", getDoubleFormat().c_str());});
626  os << _value.asDouble;
627  } else if (required_size < static_cast<int>(sizeof(buf))) {
628  buf[sizeof(buf)-1] = 0;
629  os << buf;
630  } else { // required_size >= static_cast<int>(sizeof(buf)
631  std::vector<char> required_buf(required_size+1);
632  std::snprintf(required_buf.data(), required_size,
633  getDoubleFormat().c_str(), _value.asDouble);
634  required_buf[required_size] = 0;
635  os << required_buf.data();
636  }
637  break;
638  }
639  case TypeString: os << *_value.asString; break;
640  case TypeDateTime:
641  {
642  struct tm* t = _value.asTime;
643  char buf[20];
644  std::snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
645  t->tm_year,t->tm_mon,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
646  buf[sizeof(buf)-1] = 0;
647  os << buf;
648  break;
649  }
650  case TypeBase64:
651  {
652  std::stringstream buffer;
653  buffer.write(_value.asBinary->data(), _value.asBinary->size());
654  base64::encoder encoder;
655  encoder.encode(buffer, os);
656  break;
657  }
658  case TypeArray:
659  {
660  int s = int(_value.asArray->size());
661  os << '{';
662  for (int i=0; i<s; ++i)
663  {
664  if (i > 0) os << ',';
665  _value.asArray->at(i).write(os);
666  }
667  os << '}';
668  break;
669  }
670  case TypeStruct:
671  {
672  os << '[';
673  ValueStruct::const_iterator it;
674  for (it=_value.asStruct->begin(); it!=_value.asStruct->end(); ++it)
675  {
676  if (it!=_value.asStruct->begin()) os << ',';
677  os << it->first << ':';
678  it->second.write(os);
679  }
680  os << ']';
681  break;
682  }
683 
684  }
685 
686  return os;
687  }
688 
689 } // namespace XmlRpc
690 
691 
692 // ostream
693 std::ostream& operator<<(std::ostream& os, const XmlRpc::XmlRpcValue& v)
694 {
695  // If you want to output in xml format:
696  //return os << v.toXml();
697  return v.write(os);
698 }
699 
XmlRpc::DATA_TAG
static const char DATA_TAG[]
Definition: XmlRpcValue.cpp:40
XmlRpc::XmlRpcValue::size
int size() const
Return the size for string, base64, array, and struct values.
Definition: XmlRpcValue.cpp:211
XmlRpc::XmlRpcValue::assertArray
void assertArray(int size) const
Definition: XmlRpcValue.cpp:99
XmlRpc::XmlRpcValue::toXml
std::string toXml() const
Encode the Value in xml.
Definition: XmlRpcValue.cpp:277
XmlRpc::XmlRpcValue::asInt
int asInt
Definition: XmlRpcValue.h:194
operator<<
std::ostream & operator<<(std::ostream &os, const XmlRpc::XmlRpcValue &v)
Definition: XmlRpcValue.cpp:693
XmlRpc::DOUBLE_TAG
static const char DOUBLE_TAG[]
Definition: XmlRpcValue.cpp:28
XmlRpc::NAME_ETAG
static const char NAME_ETAG[]
Definition: XmlRpcValue.cpp:47
XmlRpc::XmlRpcValue::asStruct
ValueStruct * asStruct
Definition: XmlRpcValue.h:200
XmlRpc::XmlRpcValue::BinaryData
std::vector< char > BinaryData
Definition: XmlRpcValue.h:41
XmlRpc::VALUE_ETAG
static const char VALUE_ETAG[]
Definition: XmlRpcValue.cpp:24
XmlRpc::XmlRpcValue::TypeBase64
@ TypeBase64
Definition: XmlRpcValue.h:35
XmlRpc::XmlRpcUtil::xmlEncode
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
Definition: XmlRpcUtil.cpp:299
XmlRpc::XmlRpcValue::intToXml
std::string intToXml() const
Definition: XmlRpcValue.cpp:334
XmlRpc::XmlRpcValue::structToXml
std::string structToXml() const
Definition: XmlRpcValue.cpp:589
encode.h
XmlRpc::XmlRpcValue::ValueStruct
std::map< std::string, XmlRpcValue > ValueStruct
Definition: XmlRpcValue.h:43
s
XmlRpcServer s
Definition: HelloServer.cpp:11
XmlRpc::XmlRpcValue::fromXml
bool fromXml(std::string const &valueXml, int *offset)
Decode xml. Destroys any existing value.
Definition: XmlRpcValue.cpp:232
XmlRpc::STRUCT_ETAG
static const char STRUCT_ETAG[]
Definition: XmlRpcValue.cpp:49
XmlRpc::XmlRpcValue::_doubleFormat
static std::string _doubleFormat
Definition: XmlRpcValue.h:185
XmlRpc::tmEq
static bool tmEq(struct tm const &t1, struct tm const &t2)
Definition: XmlRpcValue.cpp:160
XmlRpc::DATETIME_TAG
static const char DATETIME_TAG[]
Definition: XmlRpcValue.cpp:34
XmlRpc::XmlRpcValue::assertStruct
void assertStruct() const
Definition: XmlRpcValue.cpp:120
XmlRpcValue.h
XmlRpc::DATETIME_ETAG
static const char DATETIME_ETAG[]
Definition: XmlRpcValue.cpp:35
XmlRpc::XmlRpcValue::TypeInt
@ TypeInt
Definition: XmlRpcValue.h:31
XmlRpc::DATA_ETAG
static const char DATA_ETAG[]
Definition: XmlRpcValue.cpp:41
XmlRpc::XmlRpcValue::TypeInvalid
@ TypeInvalid
Definition: XmlRpcValue.h:29
XmlRpc::INT_TAG
static const char INT_TAG[]
Definition: XmlRpcValue.cpp:30
XmlRpc::XmlRpcValue::doubleFromXml
bool doubleFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:348
XmlRpc
Definition: XmlRpcClient.h:20
XmlRpc::DOUBLE_ETAG
static const char DOUBLE_ETAG[]
Definition: XmlRpcValue.cpp:29
XmlRpc::MEMBER_ETAG
static const char MEMBER_ETAG[]
Definition: XmlRpcValue.cpp:48
XmlRpc::XmlRpcValue::TypeStruct
@ TypeStruct
Definition: XmlRpcValue.h:37
XmlRpc::ARRAY_ETAG
static const char ARRAY_ETAG[]
Definition: XmlRpcValue.cpp:42
XmlRpc::XmlRpcValue::assertTypeOrInvalid
void assertTypeOrInvalid(Type t) const
Definition: XmlRpcValue.cpp:75
decode.h
XmlRpc::XmlRpcValue::getDoubleFormat
static std::string const & getDoubleFormat()
Return the format used to write double values.
Definition: XmlRpcValue.h:146
XmlRpc::XmlRpcValue::TypeDouble
@ TypeDouble
Definition: XmlRpcValue.h:32
XmlRpc::XmlRpcUtil::findTag
static bool findTag(const char *tag, std::string const &xml, int *offset)
Returns true if the tag is found and updates offset to the char after the tag.
Definition: XmlRpcUtil.cpp:133
XmlRpc::XmlRpcValue::arrayToXml
std::string arrayToXml() const
Definition: XmlRpcValue.cpp:546
XmlRpc::XmlRpcValue::boolFromXml
bool boolFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:295
XmlRpc::ARRAY_TAG
static const char ARRAY_TAG[]
Definition: XmlRpcValue.cpp:39
XmlRpc::MEMBER_TAG
static const char MEMBER_TAG[]
Definition: XmlRpcValue.cpp:45
XmlRpc::XmlRpcValue::asArray
ValueArray * asArray
Definition: XmlRpcValue.h:199
XmlRpc::XmlRpcValue::timeFromXml
bool timeFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:420
XmlRpc::XmlRpcUtil::nextTagData
static std::string nextTagData(const char *tag, std::string const &xml, int *offset)
Definition: XmlRpcUtil.cpp:173
base64::encoder::encode_end
int encode_end(char *plaintext_out)
Definition: encode.h:43
XmlRpc::XmlRpcValue::TypeString
@ TypeString
Definition: XmlRpcValue.h:33
XmlRpc::XmlRpcValue::_type
Type _type
Definition: XmlRpcValue.h:188
XmlRpc::XmlRpcUtil::nextTagIs
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
Definition: XmlRpcUtil.cpp:150
XmlRpc::STRING_TAG
static const char STRING_TAG[]
Definition: XmlRpcValue.cpp:33
XmlRpc::XmlRpcValue::stringFromXml
bool stringFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:397
XmlRpc::XmlRpcValue::operator==
bool operator==(XmlRpcValue const &other) const
Definition: XmlRpcValue.cpp:166
XmlRpc::XmlRpcValue::Type
Type
Definition: XmlRpcValue.h:28
XmlRpc::XmlRpcValue::ValueArray
std::vector< XmlRpcValue > ValueArray
Definition: XmlRpcValue.h:42
XmlRpc::BASE64_TAG
static const char BASE64_TAG[]
Definition: XmlRpcValue.cpp:36
XmlRpc::VALUE_TAG
static const char VALUE_TAG[]
Definition: XmlRpcValue.cpp:23
XmlRpc::XmlRpcUtil::error
static void error(const char *fmt,...)
Dump error messages somewhere.
Definition: XmlRpcUtil.cpp:96
XmlRpc::XmlRpcUtil::xmlDecode
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
Definition: XmlRpcUtil.cpp:262
XmlRpc::I4_TAG
static const char I4_TAG[]
Definition: XmlRpcValue.cpp:31
XmlRpc::XmlRpcValue::asBinary
BinaryData * asBinary
Definition: XmlRpcValue.h:198
XmlRpc::XmlRpcValue::asTime
struct tm * asTime
Definition: XmlRpcValue.h:196
XmlRpc::XmlRpcValue::doubleToXml
std::string doubleToXml() const
Definition: XmlRpcValue.cpp:380
XmlRpc::XmlRpcValue::boolToXml
std::string boolToXml() const
Definition: XmlRpcValue.cpp:309
XmlRpc::XmlRpcValue::arrayFromXml
bool arrayFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:527
XmlRpc::XmlRpcValue::binaryFromXml
bool binaryFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:484
XmlRpc::XmlRpcValue::TypeArray
@ TypeArray
Definition: XmlRpcValue.h:36
XmlRpc::XmlRpcValue::invalidate
void invalidate()
Definition: XmlRpcValue.cpp:59
XmlRpc::XmlRpcValue::structFromXml
bool structFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:564
XmlRpc::XmlRpcException
Definition: XmlRpcException.h:23
XmlRpc::XmlRpcValue::hasMember
bool hasMember(const std::string &name) const
Check for the existence of a struct member by name.
Definition: XmlRpcValue.cpp:225
XmlRpc::XmlRpcValue::intFromXml
bool intFromXml(std::string const &valueXml, int *offset)
Definition: XmlRpcValue.cpp:320
XmlRpc::XmlRpcValue::operator=
XmlRpcValue & operator=(XmlRpcValue const &rhs)
Definition: XmlRpcValue.cpp:137
base64::decoder::decode
int decode(char value_in)
Definition: decode.h:33
XmlRpc::XmlRpcValue::valid
bool valid() const
Return true if the value has been set to something.
Definition: XmlRpcValue.h:121
XmlRpc::XmlRpcValue::asString
std::string * asString
Definition: XmlRpcValue.h:197
XmlRpc::XmlRpcValue::stringToXml
std::string stringToXml() const
Definition: XmlRpcValue.cpp:409
XmlRpc::XmlRpcValue::_value
union XmlRpc::XmlRpcValue::@0 _value
base64::encoder::encode
int encode(char value_in)
Definition: encode.h:33
XmlRpc::XmlRpcValue::asDouble
double asDouble
Definition: XmlRpcValue.h:195
XmlRpc::XmlRpcValue::operator!=
bool operator!=(XmlRpcValue const &other) const
Definition: XmlRpcValue.cpp:204
XmlRpc::I4_ETAG
static const char I4_ETAG[]
Definition: XmlRpcValue.cpp:32
XmlRpcException.h
XmlRpc::BOOLEAN_TAG
static const char BOOLEAN_TAG[]
Definition: XmlRpcValue.cpp:26
XmlRpc::BOOLEAN_ETAG
static const char BOOLEAN_ETAG[]
Definition: XmlRpcValue.cpp:27
base64::decoder
Definition: decode.h:22
XmlRpc::XmlRpcValue::timeToXml
std::string timeToXml() const
Definition: XmlRpcValue.cpp:443
XmlRpc::XmlRpcValue::TypeBoolean
@ TypeBoolean
Definition: XmlRpcValue.h:30
XmlRpc::XmlRpcValue::TypeDateTime
@ TypeDateTime
Definition: XmlRpcValue.h:34
XmlRpc::XmlRpcValue::asBool
bool asBool
Definition: XmlRpcValue.h:193
XmlRpc::NAME_TAG
static const char NAME_TAG[]
Definition: XmlRpcValue.cpp:46
base64::encoder
Definition: encode.h:22
XmlRpcUtil.h
XmlRpc::XmlRpcValue::binaryToXml
std::string binaryToXml() const
Definition: XmlRpcValue.cpp:505
XmlRpc::BASE64_ETAG
static const char BASE64_ETAG[]
Definition: XmlRpcValue.cpp:37
XmlRpc::XmlRpcValue::write
std::ostream & write(std::ostream &os) const
Write the value (no xml encoding)
Definition: XmlRpcValue.cpp:612
XmlRpc::STRUCT_TAG
static const char STRUCT_TAG[]
Definition: XmlRpcValue.cpp:44
XmlRpc::XmlRpcValue
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
XmlRpc::XmlRpcUtil::getNextTag
static std::string getNextTag(std::string const &xml, int *offset)
Definition: XmlRpcUtil.cpp:225


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas , Jacob Perron
autogenerated on Thu Nov 23 2023 04:01:41