Go to the documentation of this file.
92 default:
_value.asBinary = 0;
break;
132 throw XmlRpcException(
"type error: expected a struct");
152 default:
_value.asBinary = 0;
break;
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;
187 ValueStruct::const_iterator it1=
_value.asStruct->begin();
189 while (it1 !=
_value.asStruct->end()) {
206 return !(*
this == other);
234 int savedOffset = *offset;
240 int afterValueOffset = *offset;
249 else if (typeTag.empty() || typeTag ==
STRING_TAG)
262 *offset = afterValueOffset;
269 *offset = savedOffset;
288 return std::string();
295 const char* valueStart = valueXml.c_str() + *offset;
297 long ivalue = strtol(valueStart, &valueEnd, 10);
298 if (valueEnd == valueStart || (ivalue != 0 && ivalue != 1))
302 _value.asBool = (ivalue == 1);
303 *offset += int(valueEnd - valueStart);
311 xml += (
_value.asBool ?
"1" :
"0");
320 const char* valueStart = valueXml.c_str() + *offset;
322 long ivalue = strtol(valueStart, &valueEnd, 10);
323 if (valueEnd == valueStart)
327 _value.asInt = int(ivalue);
328 *offset += int(valueEnd - valueStart);
335 std::snprintf(buf,
sizeof(buf)-1,
"%d",
_value.asInt);
336 buf[
sizeof(buf)-1] = 0;
348 const char* valueStart = valueXml.c_str() + *offset;
355 std::string tmplocale;
356 char* locale_cstr = setlocale(LC_NUMERIC, 0);
359 tmplocale = locale_cstr;
360 setlocale(LC_NUMERIC,
"POSIX");
363 double dvalue = strtod(valueStart, &valueEnd);
365 if (tmplocale.size() > 0) {
366 setlocale(LC_NUMERIC, tmplocale.c_str());
369 if (valueEnd == valueStart)
374 *offset += int(valueEnd - valueStart);
381 std::stringstream ss;
382 ss.imbue(std::locale::classic());
397 size_t valueEnd = valueXml.find(
'<', *offset);
398 if (valueEnd == std::string::npos)
403 *offset += int(
_value.asString->length());
420 size_t valueEnd = valueXml.find(
'<', *offset);
421 if (valueEnd == std::string::npos)
424 std::string stime = valueXml.substr(*offset, valueEnd-*offset);
428 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)
430 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)
436 _value.asTime =
new struct tm(t);
437 *offset += int(stime.length());
443 struct tm* t =
_value.asTime;
445 std::snprintf(buf,
sizeof(buf)-1,
"%4d%02d%02dT%02d:%02d:%02d",
446 t->tm_year,t->tm_mon,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
447 buf[
sizeof(buf)-1] = 0;
458 std::size_t base64EncodedSize(std::size_t raw_size)
461 if (raw_size == 0)
return 1;
465 std::size_t encoded = (raw_size + 2) / 3 * 4;
466 encoded += (encoded + 71) / 72;
470 std::size_t base64DecodedSize(std::size_t encoded_size)
473 if (encoded_size == 0)
return 1;
476 return (encoded_size + 3) / 4 * 3;
484 size_t valueEnd = valueXml.find(
'<', *offset);
485 if (valueEnd == std::string::npos)
488 std::size_t encoded_size = valueEnd - *offset;
496 std::size_t
size = decoder.
decode(&valueXml[*offset], encoded_size, &(*
_value.asBinary)[0]);
499 *offset += encoded_size;
509 std::size_t offset = xml.size();
511 xml.resize(xml.size() + base64EncodedSize(
_value.asBinary->size()));
514 offset += encoder.
encode(
_value.asBinary->data(),
_value.asBinary->size(), &xml[offset]);
533 while (v.
fromXml(valueXml, offset))
534 _value.asArray->push_back(v);
550 int s = int(
_value.asArray->size());
551 for (
int i=0; i<
s; ++i)
552 xml +=
_value.asArray->at(i).toXml();
572 if ( ! val.
valid()) {
576 const std::pair<const std::string, XmlRpcValue> p(name, val);
577 _value.asStruct->insert(p);
592 ValueStruct::const_iterator it;
593 for (it=
_value.asStruct->begin(); it!=
_value.asStruct->end(); ++it) {
598 xml += it->second.toXml();
617 static std::once_flag once;
619 int required_size = std::snprintf(buf,
sizeof(buf)-1,
621 if (required_size < 0) {
625 }
else if (required_size <
static_cast<int>(
sizeof(buf))) {
626 buf[
sizeof(buf)-1] = 0;
629 std::vector<char> required_buf(required_size+1);
630 std::snprintf(required_buf.data(), required_size,
632 required_buf[required_size] = 0;
633 os << required_buf.data();
640 struct tm* t =
_value.asTime;
642 std::snprintf(buf,
sizeof(buf)-1,
"%4d%02d%02dT%02d:%02d:%02d",
643 t->tm_year,t->tm_mon,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
644 buf[
sizeof(buf)-1] = 0;
650 std::stringstream buffer;
651 buffer.write(
_value.asBinary->data(),
_value.asBinary->size());
653 encoder.
encode(buffer, os);
658 int s = int(
_value.asArray->size());
660 for (
int i=0; i<
s; ++i)
662 if (i > 0) os <<
',';
663 _value.asArray->at(i).write(os);
671 ValueStruct::const_iterator it;
672 for (it=
_value.asStruct->begin(); it!=
_value.asStruct->end(); ++it)
674 if (it!=
_value.asStruct->begin()) os <<
',';
675 os << it->first <<
':';
676 it->second.write(os);
static const char DATA_TAG[]
int size() const
Return the size for string, base64, array, and struct values.
void assertArray(int size) const
std::string toXml() const
Encode the Value in xml.
std::ostream & operator<<(std::ostream &os, const XmlRpc::XmlRpcValue &v)
static const char DOUBLE_TAG[]
static const char NAME_ETAG[]
std::vector< char > BinaryData
static const char VALUE_ETAG[]
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
std::string intToXml() const
std::string structToXml() const
std::map< std::string, XmlRpcValue > ValueStruct
bool fromXml(std::string const &valueXml, int *offset)
Decode xml. Destroys any existing value.
static const char STRUCT_ETAG[]
static std::string _doubleFormat
static bool tmEq(struct tm const &t1, struct tm const &t2)
static const char DATETIME_TAG[]
void assertStruct() const
static const char DATETIME_ETAG[]
static const char DATA_ETAG[]
static const char INT_TAG[]
bool doubleFromXml(std::string const &valueXml, int *offset)
static const char DOUBLE_ETAG[]
static const char MEMBER_ETAG[]
static std::string parseTag(const char *tag, std::string const &xml, int *offset)
Returns contents between <tag> and </tag>, updates offset to char after </tag>
static const char ARRAY_ETAG[]
void assertTypeOrInvalid(Type t) const
static std::string const & getDoubleFormat()
Return the format used to write double values.
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.
std::string arrayToXml() const
bool boolFromXml(std::string const &valueXml, int *offset)
static const char ARRAY_TAG[]
static const char MEMBER_TAG[]
bool timeFromXml(std::string const &valueXml, int *offset)
int encode_end(char *plaintext_out)
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
static const char STRING_TAG[]
bool stringFromXml(std::string const &valueXml, int *offset)
bool operator==(XmlRpcValue const &other) const
std::vector< XmlRpcValue > ValueArray
static const char BASE64_TAG[]
static const char VALUE_TAG[]
static void error(const char *fmt,...)
Dump error messages somewhere.
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
static const char I4_TAG[]
std::string doubleToXml() const
std::string boolToXml() const
bool arrayFromXml(std::string const &valueXml, int *offset)
bool binaryFromXml(std::string const &valueXml, int *offset)
bool structFromXml(std::string const &valueXml, int *offset)
bool hasMember(const std::string &name) const
Check for the existence of a struct member by name.
bool intFromXml(std::string const &valueXml, int *offset)
XmlRpcValue & operator=(XmlRpcValue const &rhs)
int decode(char value_in)
bool valid() const
Return true if the value has been set to something.
std::string stringToXml() const
union XmlRpc::XmlRpcValue::@0 _value
int encode(char value_in)
bool operator!=(XmlRpcValue const &other) const
static const char I4_ETAG[]
static const char BOOLEAN_TAG[]
static const char BOOLEAN_ETAG[]
std::string timeToXml() const
static const char NAME_TAG[]
std::string binaryToXml() const
static const char BASE64_ETAG[]
std::ostream & write(std::ostream &os) const
Write the value (no xml encoding)
static const char STRUCT_TAG[]
RPC method arguments and results are represented by Values.
static std::string getNextTag(std::string const &xml, int *offset)
xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas
autogenerated on Thu Apr 8 2021 03:00:12