casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
casa::QtDBusXML Class Reference

Subclass of QDomDocument that represents an XML scheme that is to be used with CASA's Qt dbus communication. More...

#include <QtDBusXML.h>

List of all members.

Public Member Functions

 QtDBusXML ()
 Non-Static Methods //.
 QtDBusXML (const QtDBusXML &copy)
 Copy constructor, see operator=().
virtual ~QtDBusXML ()
 Destructor.
String time () const
 Gets the value of the time tag, or an empty string if there is none.
QString qtime () const
void setTime ()
 Sets the time tag to the current time.
String from () const
 Gets/Sets the from tag.
QString qfrom () const
void setFrom (const String &value)
void setFrom (const QString &value)
String to () const
 Gets/Sets the to tag.
QString qto () const
void setTo (const String &value)
void setTo (const QString &value)
String methodName () const
 Gets/Sets the method name and whether the method call is asynchronous or not (default is false).
QString qmethodName () const
bool methodIsAsync () const
void setMethodName (const String &value, bool isAsync=false)
void setMethodName (const QString &value, bool isAsync=false)
void setMethodIsAsync (bool value)
String methodParamType (const String &paramName) const
 Returns the type of the method parameter with the given name, or an empty string if there is none.
QString qmethodParamType (const QString &paramName) const
bool methodParamIsBool (const String &paramName) const
 Returns whether the method parameter with the given name is the specified type or not.
bool methodParamIsInt (const String &paramName) const
bool methodParamIsUInt (const String &paramName) const
bool methodParamIsDouble (const String &paramName) const
bool methodParamIsString (const String &paramName) const
bool methodParamIsRecord (const String &paramName) const
bool methodParamBool (const String &paramName) const
 Returns the value of the method parameter with the given name as the specified type.
bool methodParamBool (const QString &paramName) const
int methodParamInt (const String &paramName) const
int methodParamInt (const QString &paramName) const
uInt methodParamUInt (const String &paramName) const
uInt methodParamUInt (const QString &paramName) const
double methodParamDouble (const String &paramName) const
double methodParamDouble (const QString &paramName) const
String methodParamString (const String &paramName) const
QString methodParamQString (const QString &paramName) const
Record methodParamRecord (const String &paramName) const
Record methodParamRecord (const QString &paramName) const
void setMethodParam (const String &paramName, bool value)
 Sets the parameter with the given name to the given value (and associated type).
void setMethodParam (const QString &paramName, bool value)
void setMethodParam (const String &paramName, int value)
void setMethodParam (const QString &paramName, int value)
void setMethodParam (const String &paramName, uInt value)
void setMethodParam (const QString &paramName, uInt value)
void setMethodParam (const String &paramName, double value)
void setMethodParam (const QString &paramName, double value)
void setMethodParam (const String &paramName, const String &value)
void setMethodParam (const QString &paramName, const QString &value)
void setMethodParam (const String &paramName, const Record &value)
void setMethodParam (const QString &paramName, const Record &value)
Record methodParams () const
 Gets/Sets all method parameter values as a Record.
void setMethodParams (const Record &parameters)
bool returnedSet () const
 Returns whether or not a returned value was set.
String returnedType () const
 Returns the type of the returned value, or empty string for none.
QString qreturnedType () const
bool returnedIsBool () const
 Returns whether the returned value is the specified type or not.
bool returnedIsInt () const
bool returnedIsUInt () const
bool returnedIsDouble () const
bool returnedIsString () const
bool returnedIsRecord () const
bool returnedBool () const
 Returns the returned value as the specified type.
int returnedInt () const
uInt returnedUInt () const
double returnedDouble () const
String returnedString () const
QString returnedQString () const
Record returnedRecord () const
void setReturnedValue (bool value)
 Sets the returned value to the given value (and associated type).
void setReturnedValue (int value)
void setReturnedValue (uInt value)
void setReturnedValue (double value)
void setReturnedValue (const String &value)
void setReturnedValue (const QString &value)
void setReturnedValue (const Record &value)
Record returnedValue () const
 Gets/Sets the returned value as a record.
void setReturnedValueRec (const Record &retValue)
String toXMLString () const
 Returns the whole XML as a string.
QString toXMLQString () const
bool fromXMLString (const String &value)
 Sets the whole XML as a string, and returns whether the operation.
bool fromXMLString (const QString &value)
QDomDocument & domDocument ()
 Returns the underlying QDomDocument.
const QDomDocument & domDocument () const
QtDBusXMLoperator= (const QtDBusXML &copy)
 Copy operator.

Static Public Member Functions

static QtDBusXML constructXML (const String &from="", const String &to="", const String &methodName="", bool methodIsAsync=false, const Record &methodParams=Record(), const Record &retValue=Record())
 Static Methods //.
static QtDBusXML constructXML (const QString &from="", const QString &to="", const QString &methodName="", bool methodIsAsync=false, const Record &methodParams=Record(), const Record &retValue=Record())
static QtDBusXML fromString (const String &xmlStr)
 Constructs and returns an XML message from the given XML string.
static QtDBusXML fromString (const QString &xmlStr)
static void extractXML (const QtDBusXML &xml, String *time=NULL, String *from=NULL, String *to=NULL, String *methodName=NULL, Record *methodParams=NULL, Record *retValue=NULL)
 Reads the values from the given XML message into the given parameters which are not NULL.
static void extractXML (const QtDBusXML &xml, QString *time=NULL, QString *from=NULL, QString *to=NULL, QString *methodName=NULL, Record *methodParams=NULL, Record *retValue=NULL)

Private Member Functions

void initialize ()
 Initialize object; meant to be called from constructor.
QString elemChildText (const QString &name) const
 Helper method for elemChildText().
void setElemChildText (const QString &name, const QString &value)
 Helper method for setElemChildText().
QDomElement methodParam (const QString &paramName, bool createIfAbsent=false) const
 Helper method that returns the element for the method parameter with the given name, or a null element if it is not.
void setMethodParam (const QString &name, const QString &type, const QString &value)
 Helper method for setting the method parameter values.
void setReturnedValue (const QString &type, const QString &value)
 Helper method for setting the returned value.

Static Private Member Functions

static bool qstringToBool (const QString &value)
 Static //.
static QString qstringFromBool (bool value)
static QDomElement elemChild (QDomDocument doc, const QString &name, bool createIfAbsent=false)
 Returns the child of the given element with the given tag name.
static QDomElement elemChild (QDomElement elem, const QString &name, bool createIfAbsent=false)
static QString elemChildText (QDomDocument doc, const QString &name, bool createIfAbsent=false)
 Returns the text value of the child of the given element with the given tag name.
static QString elemChildText (QDomElement elem, const QString &name, bool createIfAbsent=false)
static void setElemChildText (QDomDocument doc, const QString &name, const QString &value, bool createIfAbsent=false)
 Sets the text value of the child of the given element with the given tag name to the given value.
static void setElemChildText (QDomElement elem, const QString &name, const QString &value, bool createIfAbsent=false)
static void setElemText (QDomElement elem, const QString &text)
 Sets the text value of the given element (if it is not null) to the given text.
static Record elemToRecord (QDomElement value)
 Converts between a QDomElement and Record for values.
static void elemToRecord (Record &rec, QDomElement value)
static void elemFromRecord (QDomElement elem, const Record &value)

Private Attributes

QDomDocument itsXML_
 XML document.

Detailed Description

Subclass of QDomDocument that represents an XML scheme that is to be used with CASA's Qt dbus communication.

<casa-dbus> <time>[TIMESTAMP]</time> <from>[NAME]</from> <to>[NAME]</to> <method name="[METHOD]" async="[ISASYNC]">

Parameters:
[NAME][VALUE]

... </method> <returned type="[TYPE]">[VALUE]</returned> </casa-dbus> Currently supported types for parameters and returned values: bool, int, uInt, double, String, Records with these types. For a discussion of what these fields mean, see the documentation for QtDBusXmlApp.

Definition at line 56 of file QtDBusXML.h.


Constructor & Destructor Documentation

Non-Static Methods //.

Constructor.

Copy constructor, see operator=().

virtual casa::QtDBusXML::~QtDBusXML ( ) [virtual]

Destructor.


Member Function Documentation

static QtDBusXML casa::QtDBusXML::constructXML ( const String from = "",
const String to = "",
const String methodName = "",
bool  methodIsAsync = false,
const Record methodParams = Record(),
const Record retValue = Record() 
) [inline, static]

Static Methods //.

Constructs and returns an XML message using the given parameters. Only uses the non-empty values. Sets the time to the current.

Definition at line 63 of file QtDBusXML.h.

References casa::String::c_str(), from(), methodIsAsync(), methodName(), methodParams(), and to().

static QtDBusXML casa::QtDBusXML::constructXML ( const QString &  from = "",
const QString &  to = "",
const QString &  methodName = "",
bool  methodIsAsync = false,
const Record methodParams = Record(),
const Record retValue = Record() 
) [static]
QDomDocument& casa::QtDBusXML::domDocument ( )

Returns the underlying QDomDocument.

const QDomDocument& casa::QtDBusXML::domDocument ( ) const
static QDomElement casa::QtDBusXML::elemChild ( QDomDocument  doc,
const QString &  name,
bool  createIfAbsent = false 
) [inline, static, private]

Returns the child of the given element with the given tag name.

If createIfAbsent is true, then the element will be created and appended if it is not present; otherwise, the returned element will be null if not present. If the given element is null, a null element is returned.

Definition at line 346 of file QtDBusXML.h.

References casa::name().

Referenced by elemChildText(), and setElemChildText().

static QDomElement casa::QtDBusXML::elemChild ( QDomElement  elem,
const QString &  name,
bool  createIfAbsent = false 
) [static, private]
QString casa::QtDBusXML::elemChildText ( const QString &  name) const [inline, private]

Helper method for elemChildText().

Definition at line 313 of file QtDBusXML.h.

References itsXML_.

Referenced by elemChildText().

static QString casa::QtDBusXML::elemChildText ( QDomDocument  doc,
const QString &  name,
bool  createIfAbsent = false 
) [inline, static, private]

Returns the text value of the child of the given element with the given tag name.

See elemChild().

Definition at line 356 of file QtDBusXML.h.

References elemChildText(), and casa::name().

static QString casa::QtDBusXML::elemChildText ( QDomElement  elem,
const QString &  name,
bool  createIfAbsent = false 
) [inline, static, private]

Definition at line 359 of file QtDBusXML.h.

References elemChild().

static void casa::QtDBusXML::elemFromRecord ( QDomElement  elem,
const Record value 
) [static, private]
static Record casa::QtDBusXML::elemToRecord ( QDomElement  value) [static, private]

Converts between a QDomElement and Record for values.

static void casa::QtDBusXML::elemToRecord ( Record rec,
QDomElement  value 
) [static, private]
static void casa::QtDBusXML::extractXML ( const QtDBusXML xml,
String time = NULL,
String from = NULL,
String to = NULL,
String methodName = NULL,
Record methodParams = NULL,
Record retValue = NULL 
) [inline, static]

Reads the values from the given XML message into the given parameters which are not NULL.

Definition at line 86 of file QtDBusXML.h.

References from(), methodName(), methodParams(), qfrom(), qmethodName(), qtime(), qto(), time(), and to().

static void casa::QtDBusXML::extractXML ( const QtDBusXML xml,
QString *  time = NULL,
QString *  from = NULL,
QString *  to = NULL,
QString *  methodName = NULL,
Record methodParams = NULL,
Record retValue = NULL 
) [static]
String casa::QtDBusXML::from ( ) const [inline]

Gets/Sets the from tag.

Definition at line 130 of file QtDBusXML.h.

References qfrom().

Referenced by constructXML(), and extractXML().

static QtDBusXML casa::QtDBusXML::fromString ( const String xmlStr) [inline, static]

Constructs and returns an XML message from the given XML string.

Definition at line 78 of file QtDBusXML.h.

References casa::String::c_str().

static QtDBusXML casa::QtDBusXML::fromString ( const QString &  xmlStr) [static]
bool casa::QtDBusXML::fromXMLString ( const String value) [inline]

Sets the whole XML as a string, and returns whether the operation.

succeeded or not.

Definition at line 289 of file QtDBusXML.h.

References casa::String::c_str().

bool casa::QtDBusXML::fromXMLString ( const QString &  value)
void casa::QtDBusXML::initialize ( ) [private]

Initialize object; meant to be called from constructor.

Referenced by constructXML().

String casa::QtDBusXML::methodName ( ) const [inline]

Gets/Sets the method name and whether the method call is asynchronous or not (default is false).

Definition at line 147 of file QtDBusXML.h.

References qmethodName().

Referenced by constructXML(), and extractXML().

QDomElement casa::QtDBusXML::methodParam ( const QString &  paramName,
bool  createIfAbsent = false 
) const [private]

Helper method that returns the element for the method parameter with the given name, or a null element if it is not.

See elemChild().

bool casa::QtDBusXML::methodParamBool ( const String paramName) const [inline]

Returns the value of the method parameter with the given name as the specified type.

Is invalid if that parameter is not of the requested type. Note: the value can always be returned as a string representation.

Definition at line 180 of file QtDBusXML.h.

References casa::String::c_str().

bool casa::QtDBusXML::methodParamBool ( const QString &  paramName) const
double casa::QtDBusXML::methodParamDouble ( const String paramName) const [inline]

Definition at line 189 of file QtDBusXML.h.

References casa::String::c_str().

double casa::QtDBusXML::methodParamDouble ( const QString &  paramName) const
int casa::QtDBusXML::methodParamInt ( const String paramName) const [inline]

Definition at line 183 of file QtDBusXML.h.

References casa::String::c_str().

int casa::QtDBusXML::methodParamInt ( const QString &  paramName) const
bool casa::QtDBusXML::methodParamIsBool ( const String paramName) const

Returns whether the method parameter with the given name is the specified type or not.

bool casa::QtDBusXML::methodParamIsDouble ( const String paramName) const
bool casa::QtDBusXML::methodParamIsInt ( const String paramName) const
bool casa::QtDBusXML::methodParamIsRecord ( const String paramName) const
bool casa::QtDBusXML::methodParamIsString ( const String paramName) const
bool casa::QtDBusXML::methodParamIsUInt ( const String paramName) const
QString casa::QtDBusXML::methodParamQString ( const QString &  paramName) const

Referenced by methodParamString().

Record casa::QtDBusXML::methodParamRecord ( const String paramName) const [inline]

Definition at line 195 of file QtDBusXML.h.

References casa::String::c_str().

Record casa::QtDBusXML::methodParamRecord ( const QString &  paramName) const

Gets/Sets all method parameter values as a Record.

Referenced by constructXML(), and extractXML().

String casa::QtDBusXML::methodParamString ( const String paramName) const [inline]

Definition at line 192 of file QtDBusXML.h.

References casa::String::c_str(), and methodParamQString().

String casa::QtDBusXML::methodParamType ( const String paramName) const [inline]

Returns the type of the method parameter with the given name, or an empty string if there is none.

Definition at line 159 of file QtDBusXML.h.

References casa::String::c_str(), and qmethodParamType().

uInt casa::QtDBusXML::methodParamUInt ( const String paramName) const [inline]

Definition at line 186 of file QtDBusXML.h.

References casa::String::c_str().

uInt casa::QtDBusXML::methodParamUInt ( const QString &  paramName) const
QtDBusXML& casa::QtDBusXML::operator= ( const QtDBusXML copy)

Copy operator.

QString casa::QtDBusXML::qfrom ( ) const

Referenced by extractXML(), and from().

QString casa::QtDBusXML::qmethodName ( ) const

Referenced by extractXML(), and methodName().

QString casa::QtDBusXML::qmethodParamType ( const QString &  paramName) const

Referenced by methodParamType().

QString casa::QtDBusXML::qreturnedType ( ) const

Referenced by returnedSet(), and returnedType().

static QString casa::QtDBusXML::qstringFromBool ( bool  value) [static, private]
static bool casa::QtDBusXML::qstringToBool ( const QString &  value) [static, private]

Static //.

Converts between QStrings and bools.

QString casa::QtDBusXML::qtime ( ) const

Referenced by extractXML(), and time().

QString casa::QtDBusXML::qto ( ) const

Referenced by extractXML(), and to().

Returns the returned value as the specified type.

Is invalid if that parameter is not of the requested type. Note: the value can always be returned as a string representation.

Returns whether the returned value is the specified type or not.

Referenced by returnedString().

bool casa::QtDBusXML::returnedSet ( ) const [inline]

Returns whether or not a returned value was set.

Definition at line 230 of file QtDBusXML.h.

References qreturnedType().

Definition at line 256 of file QtDBusXML.h.

References returnedQString().

Returns the type of the returned value, or empty string for none.

Definition at line 234 of file QtDBusXML.h.

References qreturnedType().

Gets/Sets the returned value as a record.

ONLY the first field is used.

void casa::QtDBusXML::setElemChildText ( const QString &  name,
const QString &  value 
) [inline, private]

Helper method for setElemChildText().

Definition at line 317 of file QtDBusXML.h.

References itsXML_.

Referenced by setElemChildText().

static void casa::QtDBusXML::setElemChildText ( QDomDocument  doc,
const QString &  name,
const QString &  value,
bool  createIfAbsent = false 
) [inline, static, private]

Sets the text value of the child of the given element with the given tag name to the given value.

See elemChild().

Definition at line 368 of file QtDBusXML.h.

References casa::name(), setElemChildText(), and casa::value().

static void casa::QtDBusXML::setElemChildText ( QDomElement  elem,
const QString &  name,
const QString &  value,
bool  createIfAbsent = false 
) [inline, static, private]

Definition at line 371 of file QtDBusXML.h.

References elemChild(), and setElemText().

static void casa::QtDBusXML::setElemText ( QDomElement  elem,
const QString &  text 
) [static, private]

Sets the text value of the given element (if it is not null) to the given text.

Referenced by setElemChildText().

void casa::QtDBusXML::setFrom ( const String value) [inline]

Definition at line 132 of file QtDBusXML.h.

References casa::String::c_str(), and setFrom().

Referenced by setFrom().

void casa::QtDBusXML::setFrom ( const QString &  value)
void casa::QtDBusXML::setMethodIsAsync ( bool  value)
void casa::QtDBusXML::setMethodName ( const String value,
bool  isAsync = false 
) [inline]

Definition at line 150 of file QtDBusXML.h.

References casa::String::c_str().

void casa::QtDBusXML::setMethodName ( const QString &  value,
bool  isAsync = false 
)
void casa::QtDBusXML::setMethodParam ( const String paramName,
bool  value 
) [inline]

Sets the parameter with the given name to the given value (and associated type).

Definition at line 203 of file QtDBusXML.h.

References casa::String::c_str().

Referenced by setMethodParam().

void casa::QtDBusXML::setMethodParam ( const QString &  paramName,
bool  value 
)
void casa::QtDBusXML::setMethodParam ( const String paramName,
int  value 
) [inline]

Definition at line 206 of file QtDBusXML.h.

References casa::String::c_str(), and setMethodParam().

void casa::QtDBusXML::setMethodParam ( const QString &  paramName,
int  value 
)
void casa::QtDBusXML::setMethodParam ( const String paramName,
uInt  value 
) [inline]

Definition at line 209 of file QtDBusXML.h.

References casa::String::c_str(), and setMethodParam().

void casa::QtDBusXML::setMethodParam ( const QString &  paramName,
uInt  value 
)
void casa::QtDBusXML::setMethodParam ( const String paramName,
double  value 
) [inline]

Definition at line 212 of file QtDBusXML.h.

References casa::String::c_str(), and setMethodParam().

void casa::QtDBusXML::setMethodParam ( const QString &  paramName,
double  value 
)
void casa::QtDBusXML::setMethodParam ( const String paramName,
const String value 
) [inline]

Definition at line 215 of file QtDBusXML.h.

References casa::String::c_str(), and setMethodParam().

void casa::QtDBusXML::setMethodParam ( const QString &  paramName,
const QString &  value 
)
void casa::QtDBusXML::setMethodParam ( const String paramName,
const Record value 
) [inline]

Definition at line 218 of file QtDBusXML.h.

References casa::String::c_str(), and setMethodParam().

void casa::QtDBusXML::setMethodParam ( const QString &  paramName,
const Record value 
)
void casa::QtDBusXML::setMethodParam ( const QString &  name,
const QString &  type,
const QString &  value 
) [private]

Helper method for setting the method parameter values.

void casa::QtDBusXML::setMethodParams ( const Record parameters)
void casa::QtDBusXML::setReturnedValue ( bool  value)

Sets the returned value to the given value (and associated type).

Referenced by setReturnedValue().

void casa::QtDBusXML::setReturnedValue ( int  value)
void casa::QtDBusXML::setReturnedValue ( double  value)
void casa::QtDBusXML::setReturnedValue ( const String value) [inline]

Definition at line 267 of file QtDBusXML.h.

References casa::String::c_str(), and setReturnedValue().

void casa::QtDBusXML::setReturnedValue ( const QString &  value)
void casa::QtDBusXML::setReturnedValue ( const Record value)
void casa::QtDBusXML::setReturnedValue ( const QString &  type,
const QString &  value 
) [private]

Helper method for setting the returned value.

void casa::QtDBusXML::setReturnedValueRec ( const Record retValue)

Sets the time tag to the current time.

void casa::QtDBusXML::setTo ( const String value) [inline]

Definition at line 140 of file QtDBusXML.h.

References casa::String::c_str(), and setTo().

Referenced by setTo().

void casa::QtDBusXML::setTo ( const QString &  value)
String casa::QtDBusXML::time ( ) const [inline]

Gets the value of the time tag, or an empty string if there is none.

Definition at line 121 of file QtDBusXML.h.

References qtime().

Referenced by extractXML().

String casa::QtDBusXML::to ( ) const [inline]

Gets/Sets the to tag.

Definition at line 138 of file QtDBusXML.h.

References qto().

Referenced by constructXML(), and extractXML().

QString casa::QtDBusXML::toXMLQString ( ) const

Referenced by toXMLString().

Returns the whole XML as a string.

Definition at line 282 of file QtDBusXML.h.

References toXMLQString().


Member Data Documentation

QDomDocument casa::QtDBusXML::itsXML_ [private]

XML document.

Definition at line 306 of file QtDBusXML.h.

Referenced by elemChildText(), and setElemChildText().


The documentation for this class was generated from the following file: