OverSim
|
A class to represent RPC arguments and results. More...
#include <XmlRpcValue.h>
Public Types | |
enum | Type { TypeInvalid, TypeBoolean, TypeInt, TypeDouble, TypeString, TypeDateTime, TypeBase64, TypeArray, TypeStruct } |
XmlRpcValue types. More... | |
typedef std::vector< char > | BinaryData |
typedef std::vector< XmlRpcValue > | ValueArray |
typedef std::map< std::string, XmlRpcValue > | ValueStruct |
Public Member Functions | |
XmlRpcValue () | |
Construct an empty XmlRpcValue. | |
XmlRpcValue (bool value) | |
Construct an XmlRpcValue with a bool value. | |
XmlRpcValue (int value) | |
Construct an XmlRpcValue with an int value. | |
XmlRpcValue (double value) | |
Construct an XmlRpcValue with a double value. | |
XmlRpcValue (std::string const &value) | |
Construct an XmlRpcValue with a string value. | |
XmlRpcValue (const char *value) | |
Construct an XmlRpcValue with a string value. | |
XmlRpcValue (struct tm *value) | |
Construct an XmlRpcValue with a date/time value. | |
XmlRpcValue (void *value, int nBytes) | |
Construct an XmlRpcValue with a binary data value. | |
XmlRpcValue (std::string const &xml, int *offset) | |
Construct from xml, beginning at *offset chars into the string, updates offset. | |
XmlRpcValue (XmlRpcValue const &rhs) | |
Copy constructor. | |
~XmlRpcValue () | |
Destructor (make virtual if you want to subclass) | |
void | clear () |
Erase the current value. | |
XmlRpcValue & | operator= (XmlRpcValue const &rhs) |
Assignment from one XmlRpcValue to this one. | |
XmlRpcValue & | operator= (int const &rhs) |
Assign an int to this XmlRpcValue. | |
XmlRpcValue & | operator= (double const &rhs) |
Assign a double to this XmlRpcValue. | |
XmlRpcValue & | operator= (const char *rhs) |
Assign a string to this XmlRpcValue. | |
bool | operator== (XmlRpcValue const &other) const |
Tests two XmlRpcValues for equality. | |
bool | operator!= (XmlRpcValue const &other) const |
Tests two XmlRpcValues for inequality. | |
operator bool & () | |
Treat an XmlRpcValue as a bool. | |
operator int & () | |
Treat an XmlRpcValue as an int. | |
operator double & () | |
Treat an XmlRpcValue as a double. | |
operator std::string & () | |
Treat an XmlRpcValue as a string. | |
operator BinaryData & () | |
Access the BinaryData value. | |
operator struct tm & () | |
Access the DateTime value. | |
XmlRpcValue const & | operator[] (int i) const |
Const array value accessor. | |
XmlRpcValue & | operator[] (int i) |
Array value accessor. | |
XmlRpcValue & | operator[] (std::string const &k) |
Struct entry accessor. | |
XmlRpcValue & | operator[] (const char *k) |
Struct entry accessor. | |
operator ValueStruct const & () | |
Access the struct value map. | |
bool | isValid () const |
Return true if the value has been set to something. | |
Type const & | getType () const |
Return the type of the value stored. | |
int | size () const |
Return the size for string, base64, array, and struct values. | |
void | setSize (int size) |
Specify the size for array values. Array values will grow beyond this size if needed. | |
bool | hasMember (const std::string &name) const |
Check for the existence of a struct member by name. | |
bool | fromXml (std::string const &valueXml, int *offset) |
Decode xml. Destroys any existing value. | |
std::string | toXml () const |
Encode the Value in xml. | |
std::ostream & | write (std::ostream &os) const |
Write the value (no xml encoding) |
Static Public Member Functions | |
static std::string const & | getDoubleFormat () |
Return the format used to write double values. | |
static void | setDoubleFormat (const char *f) |
Specify the format used to write double values. |
Protected Member Functions | |
void | invalidate () |
void | assertTypeOrInvalid (Type t) |
void | assertArray (int size) const |
void | assertArray (int size) |
void | assertStruct () |
bool | boolFromXml (std::string const &valueXml, int *offset) |
bool | intFromXml (std::string const &valueXml, int *offset) |
bool | doubleFromXml (std::string const &valueXml, int *offset) |
bool | stringFromXml (std::string const &valueXml, int *offset) |
bool | timeFromXml (std::string const &valueXml, int *offset) |
bool | binaryFromXml (std::string const &valueXml, int *offset) |
bool | arrayFromXml (std::string const &valueXml, int *offset) |
bool | structFromXml (std::string const &valueXml, int *offset) |
std::string | boolToXml () const |
std::string | intToXml () const |
std::string | doubleToXml () const |
std::string | stringToXml () const |
std::string | timeToXml () const |
std::string | binaryToXml () const |
std::string | arrayToXml () const |
std::string | structToXml () const |
Protected Attributes | |
Type | _type |
union { | |
bool asBool | |
int asInt | |
double asDouble | |
struct tm * asTime | |
std::string * asString | |
BinaryData * asBinary | |
ValueArray * asArray | |
ValueStruct * asStruct | |
} | _value |
Static Protected Attributes | |
static std::string | _doubleFormat |
A class to represent RPC arguments and results.
Each XmlRpcValue object contains a typed value, where the type is determined by the initial value assigned to the object.
Definition at line 31 of file XmlRpcValue.h.
typedef std::vector<char> XmlRpc::XmlRpcValue::BinaryData |
Definition at line 48 of file XmlRpcValue.h.
typedef std::vector<XmlRpcValue> XmlRpc::XmlRpcValue::ValueArray |
Definition at line 49 of file XmlRpcValue.h.
typedef std::map<std::string, XmlRpcValue> XmlRpc::XmlRpcValue::ValueStruct |
Definition at line 50 of file XmlRpcValue.h.
XmlRpcValue types.
TypeInvalid | |
TypeBoolean | |
TypeInt | |
TypeDouble | |
TypeString | |
TypeDateTime | |
TypeBase64 | |
TypeArray | |
TypeStruct |
Definition at line 35 of file XmlRpcValue.h.
|
inline |
Construct an empty XmlRpcValue.
Definition at line 55 of file XmlRpcValue.h.
Referenced by operator=().
|
inline |
|
inline |
Construct an XmlRpcValue with an int value.
Definition at line 61 of file XmlRpcValue.h.
|
inline |
|
inline |
Construct an XmlRpcValue with a string value.
Definition at line 67 of file XmlRpcValue.h.
|
inline |
Construct an XmlRpcValue with a string value.
value | A null-terminated (C) string. |
Definition at line 72 of file XmlRpcValue.h.
|
inline |
Construct an XmlRpcValue with a date/time value.
value | A pointer to a struct tm (see localtime) |
Definition at line 77 of file XmlRpcValue.h.
|
inline |
Construct an XmlRpcValue with a binary data value.
value | A pointer to data |
nBytes | The length of the data pointed to, in bytes |
Definition at line 83 of file XmlRpcValue.h.
|
inline |
Construct from xml, beginning at *offset chars into the string, updates offset.
Definition at line 89 of file XmlRpcValue.h.
|
inline |
|
inline |
Destructor (make virtual if you want to subclass)
Definition at line 96 of file XmlRpcValue.h.
|
protected |
Definition at line 465 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 484 of file XmlRpcValue.cc.
Referenced by toXml().
|
protected |
Definition at line 92 of file XmlRpcValue.cc.
Referenced by operator[](), and setSize().
|
protected |
Definition at line 101 of file XmlRpcValue.cc.
|
protected |
Definition at line 113 of file XmlRpcValue.cc.
Referenced by operator ValueStruct const &(), and operator[]().
|
protected |
Definition at line 74 of file XmlRpcValue.cc.
Referenced by operator BinaryData &(), operator bool &(), operator double &(), operator int &(), operator std::string &(), and operator struct tm &().
|
protected |
Definition at line 423 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 445 of file XmlRpcValue.cc.
Referenced by toXml().
|
protected |
Definition at line 280 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 294 of file XmlRpcValue.cc.
Referenced by toXml().
|
inline |
Erase the current value.
Definition at line 99 of file XmlRpcValue.h.
Referenced by XmlRpc::XmlRpcClient::execute().
|
protected |
Definition at line 333 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 347 of file XmlRpcValue.cc.
Referenced by toXml().
bool XmlRpc::XmlRpcValue::fromXml | ( | std::string const & | valueXml, |
int * | offset | ||
) |
Decode xml. Destroys any existing value.
Definition at line 219 of file XmlRpcValue.cc.
Referenced by arrayFromXml(), XmlRpc::XmlRpcClient::parseResponse(), and XmlRpcValue().
|
inlinestatic |
Return the format used to write double values.
Definition at line 202 of file XmlRpcValue.h.
Referenced by doubleToXml().
|
inline |
Return the type of the value stored.
Definition at line 180 of file XmlRpcValue.h.
Referenced by XmlRpc::XmlRpcServer::executeMulticall(), and XmlRpc::XmlRpcClient::generateRequest().
bool XmlRpc::XmlRpcValue::hasMember | ( | const std::string & | name | ) | const |
Check for the existence of a struct member by name.
Definition at line 212 of file XmlRpcValue.cc.
|
protected |
Definition at line 305 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 319 of file XmlRpcValue.cc.
Referenced by toXml().
|
protected |
Definition at line 58 of file XmlRpcValue.cc.
Referenced by clear(), fromXml(), operator=(), structFromXml(), and ~XmlRpcValue().
|
inline |
Return true if the value has been set to something.
Definition at line 177 of file XmlRpcValue.h.
Referenced by XmlRpc::XmlRpcServer::executeMethod(), XmlRpc::XmlRpcClient::generateRequest(), XmlRpc::XmlRpcClient::parseResponse(), and structFromXml().
|
inline |
Access the BinaryData value.
Throws XmlRpcException if the value is initialized to a type that is not TypeBase64.
Definition at line 144 of file XmlRpcValue.h.
|
inline |
Treat an XmlRpcValue as a bool.
Throws XmlRpcException if the value is initialized to a type that is not TypeBoolean.
Definition at line 124 of file XmlRpcValue.h.
|
inline |
Treat an XmlRpcValue as a double.
Throws XmlRpcException if the value is initialized to a type that is not TypeDouble.
Definition at line 134 of file XmlRpcValue.h.
|
inline |
Treat an XmlRpcValue as an int.
Throws XmlRpcException if the value is initialized to a type that is not TypeInt.
Definition at line 129 of file XmlRpcValue.h.
|
inline |
Treat an XmlRpcValue as a string.
Throws XmlRpcException if the value is initialized to a type that is not TypeString.
Definition at line 139 of file XmlRpcValue.h.
|
inline |
Access the DateTime value.
Throws XmlRpcException if the value is initialized to a type that is not TypeDateTime.
Definition at line 149 of file XmlRpcValue.h.
|
inline |
Access the struct value map.
Can be used to iterate over the entries in the map to find all defined entries.
Definition at line 173 of file XmlRpcValue.h.
bool XmlRpc::XmlRpcValue::operator!= | ( | XmlRpcValue const & | other | ) | const |
Tests two XmlRpcValues for inequality.
Definition at line 191 of file XmlRpcValue.cc.
XmlRpcValue & XmlRpc::XmlRpcValue::operator= | ( | XmlRpcValue const & | rhs | ) |
Assignment from one XmlRpcValue to this one.
rhs | The value in rhs is copied to this value. |
Definition at line 124 of file XmlRpcValue.cc.
|
inline |
Assign an int to this XmlRpcValue.
Definition at line 107 of file XmlRpcValue.h.
Referenced by operator=().
|
inline |
Assign a double to this XmlRpcValue.
Definition at line 110 of file XmlRpcValue.h.
Referenced by operator=().
|
inline |
Assign a string to this XmlRpcValue.
Definition at line 113 of file XmlRpcValue.h.
Referenced by operator=().
bool XmlRpc::XmlRpcValue::operator== | ( | XmlRpcValue const & | other | ) | const |
Tests two XmlRpcValues for equality.
Definition at line 153 of file XmlRpcValue.cc.
|
inline |
Const array value accessor.
Access the ith value of the array. Throws XmlRpcException if the value is not an array or if the index i is not a valid index for the array.
Definition at line 156 of file XmlRpcValue.h.
|
inline |
Array value accessor.
Access the ith value of the array, growing the array if necessary. Throws XmlRpcException if the value is not an array.
Definition at line 161 of file XmlRpcValue.h.
|
inline |
Struct entry accessor.
Returns the value associated with the given entry, creating one if necessary.
Definition at line 165 of file XmlRpcValue.h.
|
inline |
Struct entry accessor.
Returns the value associated with the given entry, creating one if necessary.
Definition at line 169 of file XmlRpcValue.h.
|
inlinestatic |
Specify the format used to write double values.
Definition at line 205 of file XmlRpcValue.h.
|
inline |
Specify the size for array values. Array values will grow beyond this size if needed.
Definition at line 186 of file XmlRpcValue.h.
Referenced by XmlRpc::XmlRpcServer::executeMulticall(), XmlRpcInterface::handleRpcResponse(), and XmlRpc::XmlRpcServer::listMethods().
int XmlRpc::XmlRpcValue::size | ( | ) | const |
Return the size for string, base64, array, and struct values.
Definition at line 198 of file XmlRpcValue.cc.
Referenced by XmlRpcInterface::dumpDht(), XmlRpc::XmlRpcServer::executeMulticall(), XmlRpc::XmlRpcClient::generateRequest(), XmlRpcInterface::get(), XmlRpcInterface::joinOverlay(), XmlRpcInterface::localLookup(), XmlRpcInterface::lookup(), XmlRpcInterface::p2pnsRegister(), XmlRpcInterface::p2pnsResolve(), and XmlRpcInterface::put().
|
protected |
Definition at line 362 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 374 of file XmlRpcValue.cc.
Referenced by toXml().
|
protected |
Definition at line 502 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 527 of file XmlRpcValue.cc.
Referenced by toXml().
|
protected |
Definition at line 385 of file XmlRpcValue.cc.
Referenced by fromXml().
|
protected |
Definition at line 405 of file XmlRpcValue.cc.
Referenced by toXml().
std::string XmlRpc::XmlRpcValue::toXml | ( | ) | const |
Encode the Value in xml.
Definition at line 262 of file XmlRpcValue.cc.
Referenced by XmlRpc::XmlRpcServer::executeRequest(), XmlRpc::XmlRpcServer::generateFaultResponse(), XmlRpc::XmlRpcClient::generateRequest(), and XmlRpcInterface::handleRpcResponse().
std::ostream & XmlRpc::XmlRpcValue::write | ( | std::ostream & | os | ) | const |
Write the value (no xml encoding)
Definition at line 550 of file XmlRpcValue.cc.
Referenced by operator<<().
|
staticprotected |
Definition at line 239 of file XmlRpcValue.h.
Referenced by getDoubleFormat(), and setDoubleFormat().
|
protected |
Definition at line 242 of file XmlRpcValue.h.
Referenced by arrayFromXml(), assertArray(), assertStruct(), assertTypeOrInvalid(), binaryFromXml(), boolFromXml(), doubleFromXml(), getType(), hasMember(), intFromXml(), invalidate(), isValid(), operator=(), operator==(), size(), stringFromXml(), structFromXml(), timeFromXml(), toXml(), write(), and XmlRpcValue().
union { ... } XmlRpc::XmlRpcValue::_value |
Referenced by arrayFromXml(), arrayToXml(), assertArray(), assertStruct(), assertTypeOrInvalid(), binaryFromXml(), binaryToXml(), boolFromXml(), boolToXml(), doubleFromXml(), doubleToXml(), hasMember(), intFromXml(), intToXml(), invalidate(), operator BinaryData &(), operator bool &(), operator double &(), operator int &(), operator std::string &(), operator struct tm &(), operator ValueStruct const &(), operator=(), operator==(), operator[](), size(), stringFromXml(), stringToXml(), structFromXml(), structToXml(), timeFromXml(), timeToXml(), write(), and XmlRpcValue().
ValueArray* XmlRpc::XmlRpcValue::asArray |
Definition at line 253 of file XmlRpcValue.h.
Referenced by operator=(), and operator==().
BinaryData* XmlRpc::XmlRpcValue::asBinary |
Definition at line 252 of file XmlRpcValue.h.
Referenced by operator=(), and operator==().
bool XmlRpc::XmlRpcValue::asBool |
Definition at line 247 of file XmlRpcValue.h.
Referenced by operator=(), and operator==().
double XmlRpc::XmlRpcValue::asDouble |
Definition at line 249 of file XmlRpcValue.h.
Referenced by operator=(), and operator==().
int XmlRpc::XmlRpcValue::asInt |
Definition at line 248 of file XmlRpcValue.h.
Referenced by operator=(), and operator==().
std::string* XmlRpc::XmlRpcValue::asString |
Definition at line 251 of file XmlRpcValue.h.
Referenced by binaryFromXml(), operator=(), and operator==().
ValueStruct* XmlRpc::XmlRpcValue::asStruct |
Definition at line 254 of file XmlRpcValue.h.
Referenced by operator=(), and operator==().
struct tm* XmlRpc::XmlRpcValue::asTime |
Definition at line 250 of file XmlRpcValue.h.
Referenced by operator=(), and operator==().