class XMLElement

An XML element. More...

Full nameTelEngine::XMLElement
Definition#include <libs/yjingle/xmlparser.h>
InheritsTelEngine::GenObject [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods

Public Members

Protected Methods


Detailed Description

This class holds an XML element

enum Type { StreamStart, StreamEnd, StreamError, StreamFeatures, Register, Starttls, Handshake, Auth, Challenge, Abort, Aborted, Response, Proceed, Success, Failure, Mechanisms, Mechanism, Session, Iq, Message, Presence, Error, Query, VCard, Jingle, Description, PayloadType, Transport, Candidate, Body, Subject, Feature, Bind, Resource, Transfer, Hold, Active, Ringing, Mute, Registered, Remove, Jid, Username, Password, Digest, Required, Dtmf, DtmfMethod, Command, Text, Item, Group, Reason, Content, Parameter, Crypto, CryptoRequired, Trying, Received, File, Offer, Request, StreamHost, StreamHostUsed, Unknown, Invalid, }

Type

Element type as enumeration

 XMLElement ()

XMLElement

Constructor. Constructs a StreamEnd element

 XMLElement (const XMLElement& src)

XMLElement

Copy constructor

Parameters:
srcSource element

 XMLElement (const XMLElement& src, bool response, bool result)

XMLElement

Constructor. Partially build this element from another one. Copy name and 'to', 'from', 'type', 'id' attributes

Parameters:
srcSource element
responseTrue to reverse 'to' and 'from' attributes
resultTrue to set type to "result", false to set it to "error". Ignored if response is false

 XMLElement (const char* name, NamedList* attributes = 0, const char* text = 0)

XMLElement

Constructor. Constructs an XML element with a TiXmlElement element with the given name. Used for outgoing elements

Parameters:
nameThe element's name
attributesOptional list of attributes
textOptional text for the XML element

 XMLElement (Type type, NamedList* attributes = 0, const char* text = 0)

XMLElement

Constructor. Constructs an XML element with a TiXmlElement element with the given type's name. Used for outgoing elements

Parameters:
typeThe element's type
attributesOptional list of attributes
textOptional text for the XML element

 XMLElement (NamedList& src, const char* prefix)

XMLElement

Constructor. Build this XML element from a list containing name, attributes and text. Element's name must be a parameter whose name must be equal to prefix. Element's text must be a parameter whose name is prefix followed by a dot. The list of attributes will be built from parameters starting with prefix.attributename

Parameters:
srcThe list containing data used to build this XML element
prefixThe prefix used to search the list of parameters

 ~XMLElement ()

~XMLElement

[virtual]

Destructor. Deletes the underlying TiXmlElement if owned

inline Type  type ()

type

[const]

Get the type of this object

Returns: The type of this object as enumeration

inline const char*  name ()

name

[const]

Get the TiXmlElement's name

Returns: The name of the TiXmlElement object or 0

inline bool  nameIs (const char* text)

nameIs

[const]

Check if the TiXmlElement's name is the given text

Parameters:
textText to compare with

Returns: False if text is 0 or not equal to name

inline bool  valid ()

valid

[const]

Get the validity of this object

Returns: True if m_element is non null

inline void  changeType (Type t)

changeType

Change the type of this object

Parameters:
tThe new type of this object

void  toString (String& dest, bool unclose = false)

toString

[const]

Put the element in a buffer

Parameters:
destDestination string
uncloseTrue to leave the tag unclosed

Reimplemented from GenObject.

void  toList (NamedList& dest, const char* prefix)

toList

Put this element's name, text and attributes to a list of parameters

Parameters:
destDestination list
prefixPrefix to add to parameters

void  setAttribute (const char* name, const char* value)

setAttribute

Set the value of an existing attribute or adds a new one

Parameters:
nameAttribute's name
valueAttribute's value

inline void  setAttributeValid (const char* name, const String& value)

setAttributeValid

Set the value of an existing attribute or adds a new one if the value's length is not 0

Parameters:
nameAttribute's name
valueAttribute's value

inline void  setAttribute (const char* name, int value)

setAttribute

Set the value of an existing attribute or adds a new one from an integer

Parameters:
nameAttribute's name
valueAttribute's value

const char*  getAttribute (const char* name)

getAttribute

[const]

Get the value of an attribute

Parameters:
nameAttribute's name

Returns: Attribute's value. May be 0 if doesn't exists or empty

inline bool  getAttribute (const char* name, String& value)

getAttribute

[const]

Get the value of an attribute

Parameters:
nameAttribute's name
valueDestination string

Returns: True if attribute with the given name exists and is not empty

void  getAttributes (NamedList& dest)

getAttributes

[const]

Fill a list with element's attributes

Parameters:
destThe destination list

bool  hasAttribute (const char* name, const char* value)

hasAttribute

[const]

Check if an attribute with the given name and value exists

Parameters:
nameAttribute's name
valueAttribute's value

Returns: True/False

const char*  getText ()

getText

[const]

Get the text of this XML element

Returns: Pointer to the text of this XML element or 0

void  addChild (XMLElement* element)

addChild

Add a child to this object. Release the received element

Parameters:
elementXMLElement to add

XMLElement*  removeChild (const char* name = 0)

removeChild

Find the first child element of this one. Remove it from the children list. If an element is returned, it owns the TiXmlElement pointer. This element must own its TiXmlElement pointer.

Parameters:
nameOptional name of the child

Returns: Pointer to an XMLElement or 0 if not found

inline XMLElement*  removeChild (Type type)

removeChild

Find the first child element of this one. Remove it from the children list. If an element is returned, it owns the TiXmlElement pointer. This element must own its TiXmlElement pointer.

Parameters:
typeChild's type to find

Returns: Pointer to an XMLElement or 0 if not found

XMLElement*  findFirstChild (const char* name = 0)

findFirstChild

Find the first child element of this one. If an element is returned, it is a newly allocated one, not owning its TiXmlElement pointer

Parameters:
nameOptional name of the child

Returns: Pointer to an XMLElement or 0 if not found

inline XMLElement*  findFirstChild (Type type)

findFirstChild

Find the first child element of the given type. If an element is returned, it is a newly allocated one, not owning its TiXmlElement pointer

Parameters:
typeChild's type to find

Returns: Pointer to an XMLElement or 0 if not found

inline bool  hasChild (const char* name)

hasChild

Check if this element has a given child

Parameters:
nameOptional name of the child (check for the first one if 0)

Returns: True if this element has the desired child

inline bool  hasChild (Type type)

hasChild

Check if this element has a given child

Parameters:
typeChild's type to find

Returns: True if this element has the desired child

XMLElement*  findNextChild (XMLElement* element, const char* name = 0)

findNextChild

Find the next child element. Delete the starting element if not 0. If an element is returned, it is a newly allocated one, not owning its TiXmlElement pointer

Parameters:
elementStarting XMLElement. O to find from the beginning
nameOptional name of the child

Returns: Pointer to an XMLElement or 0 if not found

inline XMLElement*  findNextChild (XMLElement* element, Type type)

findNextChild

Find the next child element of the given type. Delete the starting element if not 0. If an element is returned, it is a newly allocated one, not owning its TiXmlElement pointer

Parameters:
elementStarting XMLElement. O to find from the beginning
typeChild's type to find

Returns: Pointer to an XMLElement or 0 if not found

inline const TiXmlAttribute*  firstAttribute ()

firstAttribute

[const]

Find the first attribute

Returns: Pointer to the first attribute or 0

inline const char*  typeName (Type type)

typeName

[static]

Get the name associated with the given type

Parameters:
typeElement type as enumeration

Returns: Pointer to the name or 0

inline bool  isType (const char* txt, Type type)

isType

[static]

Check if the given text is equal to the one associated with the given type

Parameters:
txtText to compare
typeElement type as enumeration

Returns: True if txt equals the text associated with the given type

void*  getObject (const String& name)

getObject

[const virtual]

Get a pointer to this object

Reimplemented from GenObject.

const String&  toString ()

toString

[const virtual]

Release memory

Reimplemented from GenObject.

void  destruct ()

destruct

[virtual]

Release memory

Reimplemented from GenObject.

XMLElement*  getXml (NamedList& list, bool stole = false, const char* name = "xml", const char* value = 0)

getXml

[static]

Get an xml element from a list's parameter

Parameters:
listThe list to be searched for the given parameter
stoleTrue to release parameter ownership (defaults to false)
nameParameter name (defaults to 'xml')
valueOptional parameter value to check

Returns: XMLElement pointer or 0. If a valid pointer is returned and stole is true the caller will own the pointer

static TokenDict s_names[]

s_names[]

 XMLElement (TiXmlElement* element, bool owner)

XMLElement

[protected]

Constructor. Constructs an XML element from a TiXmlElement. Used to extract elements from parser and access the children. When extracting elements from parser the object will own the TiXmlElement. When accessing the children, the object will not own the TiXmlElement

Parameters:
elementPointer to a valid TiXmlElement
ownerOwner flag

inline TiXmlElement*  get ()

get

[protected const]

Get the underlying TiXmlElement

Returns: The underlying TiXmlElement object or 0

TiXmlElement*  releaseOwnership ()

releaseOwnership

[protected]

Release the ownership of the underlying TiXmlElement and returns it if the object owns it

Returns: The underlying TiXmlElement object or 0 if not owned or 0


Generated by: paulc on bussard on Wed Oct 21 01:57:30 2009, using kdoc 2.0a54.