2 #ifndef _XMLRPCVALUE_H_ 3 #define _XMLRPCVALUE_H_ 8 # pragma warning(disable:4786) // identifier was truncated in debug info 49 XmlRpcValue(
bool value) : _type(TypeBoolean) { _value.asBool = value; }
50 XmlRpcValue(
int value) : _type(TypeInt) { _value.asInt = value; }
51 XmlRpcValue(
double value) : _type(TypeDouble) { _value.asDouble = value; }
54 { _value.asString =
new std::string(value); }
57 { _value.asString =
new std::string(value); }
60 { _value.asTime =
new struct tm(*value); }
65 _value.asBinary =
new BinaryData((
char*)value, ((
char*)value)+nBytes);
69 XmlRpcValue(std::string
const& xml,
int* offset) : _type(TypeInvalid)
70 {
if ( !
fromXml(xml,offset)) _type = TypeInvalid; }
91 operator bool&() { assertTypeOrInvalid(TypeBoolean);
return _value.asBool; }
92 operator int&() { assertTypeOrInvalid(TypeInt);
return _value.asInt; }
93 operator double&() { assertTypeOrInvalid(TypeDouble);
return _value.asDouble; }
94 operator std::string&() { assertTypeOrInvalid(TypeString);
return *_value.asString; }
95 operator BinaryData&() { assertTypeOrInvalid(TypeBase64);
return *_value.asBinary; }
96 operator struct tm&() { assertTypeOrInvalid(TypeDateTime);
return *_value.asTime; }
98 operator const bool&()
const { assertTypeOrInvalid(TypeBoolean);
return _value.asBool; }
99 operator const int&()
const { assertTypeOrInvalid(TypeInt);
return _value.asInt; }
100 operator const double&()
const { assertTypeOrInvalid(TypeDouble);
return _value.asDouble; }
101 operator const std::string&()
const { assertTypeOrInvalid(TypeString);
return *_value.asString; }
102 operator const BinaryData&()
const { assertTypeOrInvalid(TypeBase64);
return *_value.asBinary; }
103 operator const struct tm&()
const { assertTypeOrInvalid(TypeDateTime);
return *_value.asTime; }
113 iterator
begin() {assertStruct();
return (*_value.asStruct).begin(); }
114 iterator
end() {assertStruct();
return (*_value.asStruct).end(); }
116 const_iterator
begin()
const {assertStruct();
return (*_value.asStruct).begin(); }
117 const_iterator
end()
const {assertStruct();
return (*_value.asStruct).end(); }
121 bool valid()
const {
return _type != TypeInvalid; }
133 bool hasMember(
const std::string& name)
const;
136 bool fromXml(std::string
const& valueXml,
int* offset);
139 std::string toXml()
const;
142 std::ostream& write(std::ostream& os)
const;
157 void assertTypeOrInvalid(
Type t)
const;
158 void assertTypeOrInvalid(
Type t);
159 void assertArray(
int size)
const;
160 void assertArray(
int size);
161 void assertStruct()
const;
165 bool boolFromXml(std::string
const& valueXml,
int* offset);
166 bool intFromXml(std::string
const& valueXml,
int* offset);
167 bool doubleFromXml(std::string
const& valueXml,
int* offset);
168 bool stringFromXml(std::string
const& valueXml,
int* offset);
169 bool timeFromXml(std::string
const& valueXml,
int* offset);
170 bool binaryFromXml(std::string
const& valueXml,
int* offset);
171 bool arrayFromXml(std::string
const& valueXml,
int* offset);
172 bool structFromXml(std::string
const& valueXml,
int* offset);
175 std::string boolToXml()
const;
176 std::string intToXml()
const;
177 std::string doubleToXml()
const;
178 std::string stringToXml()
const;
179 std::string timeToXml()
const;
180 std::string binaryToXml()
const;
181 std::string arrayToXml()
const;
182 std::string structToXml()
const;
210 #endif // _XMLRPCVALUE_H_
std::vector< XmlRpcValue > ValueArray
XmlRpcValue const & operator[](int i) const
ValueStruct::iterator iterator
RPC method arguments and results are represented by Values.
XmlRpcValue(XmlRpcValue const &rhs)
Copy.
bool valid() const
Return true if the value has been set to something.
bool operator==(const in6_addr a, const in6_addr b)
void clear()
Erase the current value.
XmlRpcValue & operator[](const char *k)
~XmlRpcValue()
Destructor (make virtual if you want to subclass)
XmlRpcValue & operator=(int const &rhs)
XmlRpcValue & operator[](const char *k) const
XmlRpcValue()
Constructors.
std::map< std::string, XmlRpcValue > ValueStruct
Type const & getType() const
Return the type of the value stored.
ValueStruct::const_iterator const_iterator
void setSize(int size)
Specify the size for array values. Array values will grow beyond this size if needed.
static void setDoubleFormat(const char *f)
Specify the format used to write double values.
const_iterator end() const
const_iterator begin() const
XmlRpcValue & operator=(const char *rhs)
XmlRpcValue & operator[](int i)
XmlRpcValue & operator[](std::string const &k)
XmlRpcValue(struct tm *value)
XmlRpcValue(std::string const &value)
XmlRpcValue(void *value, int nBytes)
XmlRpcValue(const char *value)
std::vector< char > BinaryData
XmlRpcValue & operator=(double const &rhs)
XmlRpcValue(std::string const &xml, int *offset)
Construct from xml, beginning at *offset chars into the string, updates offset.
static std::string const & getDoubleFormat()
Return the format used to write double values.
static std::string _doubleFormat
XmlRpcValue fromXml(std::string const &data)
XmlRpcValue(double value)
XmlRpcValue & operator=(bool const &rhs)
XMLRPCPP_DECL std::ostream & operator<<(std::ostream &os, const XmlRpc::XmlRpcValue &v)
XmlRpcValue & operator[](std::string const &k) const