85 default:
_value.asBinary = 0;
break;
96 else if (
int(
_value.asArray->size()) < size)
107 if (
int(
_value.asArray->size()) < size)
108 _value.asArray->resize(size);
139 default:
_value.asBinary = 0;
break;
147 static bool tmEq(
struct tm
const& t1,
struct tm
const& t2) {
148 return t1.tm_sec == t2.tm_sec && t1.tm_min == t2.tm_min &&
149 t1.tm_hour == t2.tm_hour && t1.tm_mday == t1.tm_mday &&
150 t1.tm_mon == t2.tm_mon && t1.tm_year == t2.tm_year;
174 ValueStruct::const_iterator it1=
_value.asStruct->begin();
176 while (it1 !=
_value.asStruct->end()) {
193 return !(*
this == other);
221 int savedOffset = *offset;
227 int afterValueOffset = *offset;
236 else if (typeTag.empty() || typeTag ==
STRING_TAG)
249 *offset = afterValueOffset;
256 *offset = savedOffset;
275 return std::string();
282 const char* valueStart = valueXml.c_str() + *offset;
284 long ivalue = strtol(valueStart, &valueEnd, 10);
285 if (valueEnd == valueStart || (ivalue != 0 && ivalue != 1))
289 _value.asBool = (ivalue == 1);
290 *offset += int(valueEnd - valueStart);
298 xml += (
_value.asBool ?
"1" :
"0");
307 const char* valueStart = valueXml.c_str() + *offset;
309 long ivalue = strtol(valueStart, &valueEnd, 10);
310 if (valueEnd == valueStart)
314 _value.asInt = int(ivalue);
315 *offset += int(valueEnd - valueStart);
322 snprintf(buf,
sizeof(buf)-1,
"%d",
_value.asInt);
323 buf[
sizeof(buf)-1] = 0;
335 const char* valueStart = valueXml.c_str() + *offset;
337 double dvalue = strtod(valueStart, &valueEnd);
338 if (valueEnd == valueStart)
343 *offset += int(valueEnd - valueStart);
351 buf[
sizeof(buf)-1] = 0;
364 size_t valueEnd = valueXml.find(
'<', *offset);
365 if (valueEnd == std::string::npos)
370 *offset += int(
_value.asString->length());
387 size_t valueEnd = valueXml.find(
'<', *offset);
388 if (valueEnd == std::string::npos)
391 std::string stime = valueXml.substr(*offset, valueEnd-*offset);
394 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)
400 _value.asTime =
new struct tm(t);
401 *offset += int(stime.length());
407 struct tm* t =
_value.asTime;
409 snprintf(buf,
sizeof(buf)-1,
"%04d%02d%02dT%02d:%02d:%02d",
410 1900+t->tm_year,t->tm_mon,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
411 buf[
sizeof(buf)-1] = 0;
425 size_t valueEnd = valueXml.find(
'<', *offset);
426 if (valueEnd == std::string::npos)
430 std::string
asString = valueXml.substr(*offset, valueEnd-*offset);
437 std::back_insert_iterator<BinaryData> ins = std::back_inserter(*(
_value.asBinary));
438 decoder.
get(asString.begin(), asString.end(), ins, iostatus);
440 *offset += int(asString.length());
448 std::vector<char> base64data;
451 std::back_insert_iterator<std::vector<char> > ins = std::back_inserter(base64data);
457 xml.append(base64data.begin(), base64data.end());
473 while (v.
fromXml(valueXml, offset))
474 _value.asArray->push_back(v);
490 int s = int(
_value.asArray->size());
491 for (
int i=0; i<s; ++i)
492 xml +=
_value.asArray->at(i).toXml();
516 const std::pair<const std::string, XmlRpcValue> p(name, val);
517 _value.asStruct->insert(p);
532 ValueStruct::const_iterator it;
533 for (it=
_value.asStruct->begin(); it!=
_value.asStruct->end(); ++it) {
538 xml += it->second.toXml();
559 struct tm* t =
_value.asTime;
561 snprintf(buf,
sizeof(buf)-1,
"%4d%02d%02dT%02d:%02d:%02d",
562 t->tm_year,t->tm_mon,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
563 buf[
sizeof(buf)-1] = 0;
570 std::ostreambuf_iterator<char> out(os);
577 int s = int(
_value.asArray->size());
579 for (
int i=0; i<s; ++i)
581 if (i > 0) os <<
',';
582 _value.asArray->at(i).write(os);
590 ValueStruct::const_iterator it;
591 for (it=
_value.asStruct->begin(); it!=
_value.asStruct->end(); ++it)
593 if (it!=
_value.asStruct->begin()) os <<
',';
594 os << it->first <<
':';
595 it->second.write(os);