3 #ifndef _XMLLOCALVALUE_H_
4 #define _XMLLOCALVALUE_H_
9 # pragma warning(disable:4786) // identifier was truncated in debug info
12 #include "xmlrpcpp/XmlRpcDecl.h"
50 XmlRpcValue(
bool value) : _type(TypeBoolean) { _value.asBool = value; }
51 XmlRpcValue(
int value) : _type(TypeInt) { _value.asInt = value; }
52 XmlRpcValue(
double value) : _type(TypeDouble) { _value.asDouble = value; }
56 _value.asString =
new std::string(value);
61 _value.asString =
new std::string(value);
66 _value.asTime =
new struct tm(*value);
72 _value.asBinary =
new BinaryData((
char*)value, ((
char*)value) + nBytes);
76 XmlRpcValue(std::string
const& xml,
int* offset) : _type(TypeInvalid)
78 if (!
fromXml(xml, offset)) _type = TypeInvalid;
99 operator bool&() { assertTypeOrInvalid(TypeBoolean);
return _value.asBool; }
100 operator int&() { assertTypeOrInvalid(TypeInt);
return _value.asInt; }
101 operator double&() { assertTypeOrInvalid(TypeDouble);
return _value.asDouble; }
102 operator std::string&() { assertTypeOrInvalid(TypeString);
return *_value.asString; }
103 operator BinaryData&() { assertTypeOrInvalid(TypeBase64);
return *_value.asBinary; }
104 operator struct tm&() { assertTypeOrInvalid(TypeDateTime);
return *_value.asTime; }
113 iterator end() { assertStruct();
return (*_value.asStruct).end(); }
117 bool valid()
const {
return _type != TypeInvalid; }
129 bool hasMember(
const std::string&
name)
const;
132 bool fromXml(std::string
const& valueXml,
int* offset);
135 std::string toXml()
const;
138 std::ostream& write(std::ostream& os)
const;
153 void assertTypeOrInvalid(Type t);
154 void assertArray(
int size)
const;
155 void assertArray(
int size);
159 bool boolFromXml(std::string
const& valueXml,
int* offset);
160 bool intFromXml(std::string
const& valueXml,
int* offset);
161 bool doubleFromXml(std::string
const& valueXml,
int* offset);
162 bool stringFromXml(std::string
const& valueXml,
int* offset);
163 bool timeFromXml(std::string
const& valueXml,
int* offset);
164 bool binaryFromXml(std::string
const& valueXml,
int* offset);
165 bool arrayFromXml(std::string
const& valueXml,
int* offset);
166 bool structFromXml(std::string
const& valueXml,
int* offset);
169 std::string boolToXml()
const;
170 std::string intToXml()
const;
171 std::string doubleToXml()
const;
172 std::string stringToXml()
const;
173 std::string timeToXml()
const;
174 std::string binaryToXml()
const;
175 std::string arrayToXml()
const;
176 std::string structToXml()
const;
204 #endif // _XMLRPCVALUE_H_