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; }
90 operator bool&() { assertTypeOrInvalid(TypeBoolean);
return _value.asBool; }
91 operator int&() { assertTypeOrInvalid(TypeInt);
return _value.asInt; }
92 operator double&() { assertTypeOrInvalid(TypeDouble);
return _value.asDouble; }
93 operator std::string&() { assertTypeOrInvalid(TypeString);
return *_value.asString; }
94 operator BinaryData&() { assertTypeOrInvalid(TypeBase64);
return *_value.asBinary; }
95 operator struct tm&() { assertTypeOrInvalid(TypeDateTime);
return *_value.asTime; }
103 iterator
begin() {assertStruct();
return (*_value.asStruct).begin(); }
104 iterator
end() {assertStruct();
return (*_value.asStruct).end(); }
108 bool valid()
const {
return _type != TypeInvalid; }
120 bool hasMember(
const std::string& name)
const;
123 bool fromXml(std::string
const& valueXml,
int* offset);
126 std::string toXml()
const;
129 std::ostream& write(std::ostream& os)
const;
144 void assertTypeOrInvalid(
Type t);
145 void assertArray(
int size)
const;
146 void assertArray(
int size);
150 bool boolFromXml(std::string
const& valueXml,
int* offset);
151 bool intFromXml(std::string
const& valueXml,
int* offset);
152 bool doubleFromXml(std::string
const& valueXml,
int* offset);
153 bool stringFromXml(std::string
const& valueXml,
int* offset);
154 bool timeFromXml(std::string
const& valueXml,
int* offset);
155 bool binaryFromXml(std::string
const& valueXml,
int* offset);
156 bool arrayFromXml(std::string
const& valueXml,
int* offset);
157 bool structFromXml(std::string
const& valueXml,
int* offset);
160 std::string boolToXml()
const;
161 std::string intToXml()
const;
162 std::string doubleToXml()
const;
163 std::string stringToXml()
const;
164 std::string timeToXml()
const;
165 std::string binaryToXml()
const;
166 std::string arrayToXml()
const;
167 std::string structToXml()
const;
195 #endif // _XMLRPCVALUE_H_
std::vector< XmlRpcValue > ValueArray
std::ostream & operator<<(std::ostream &os, const XmlRpc::XmlRpcValue &v)
ValueStruct::iterator iterator
RPC method arguments and results are represented by Values.
XmlRpcValue(XmlRpcValue const &rhs)
Copy.
XmlRpcValue const & operator[](int i) const
bool valid() const
Return true if the value has been set to something.
bool operator==(const in6_addr a, const in6_addr b)
Type const & getType() const
Return the type of the value stored.
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()
Constructors.
std::map< std::string, XmlRpcValue > ValueStruct
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.
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)