#include <xmlparser.h>
Public Types | |
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, Jingle, Description, PayloadType, Transport, Candidate, Body, Feature, Bind, Resource, Jid, Username, Password, Digest, Required, Dtmf, DtmfMethod, Command, Text, Item, Group, Unknown, Invalid } |
Public Member Functions | |
XMLElement () | |
XMLElement (const XMLElement &src) | |
XMLElement (const XMLElement &src, bool response, bool result) | |
XMLElement (const char *name, NamedList *attributes=0, const char *text=0) | |
XMLElement (Type type, NamedList *attributes=0, const char *text=0) | |
XMLElement (NamedList &src, const char *prefix) | |
virtual | ~XMLElement () |
Type | type () const |
const char * | name () const |
bool | nameIs (const char *text) const |
bool | valid () const |
void | changeType (Type t) |
void | toString (String &dest, bool unclose=false) const |
void | toList (NamedList &dest, const char *prefix) |
void | setAttribute (const char *name, const char *value) |
void | setAttributeValid (const char *name, const String &value) |
void | setAttribute (const char *name, int value) |
const char * | getAttribute (const char *name) const |
bool | getAttribute (const char *name, String &value) const |
bool | hasAttribute (const char *name, const char *value) const |
const char * | getText () const |
void | addChild (XMLElement *element) |
XMLElement * | findFirstChild (const char *name=0) |
XMLElement * | findFirstChild (Type type) |
bool | hasChild (const char *name) |
bool | hasChild (Type type) |
XMLElement * | findNextChild (XMLElement *element, const char *name=0) |
XMLElement * | findNextChild (XMLElement *element, Type type) |
const TiXmlAttribute * | firstAttribute () const |
virtual void * | getObject (const String &name) const |
virtual const String & | toString () const |
virtual void | destruct () |
Static Public Member Functions | |
static const char * | typeName (Type type) |
static bool | isType (const char *txt, Type type) |
static XMLElement * | getXml (NamedList &list, bool stole=false, const char *name="xml", const char *value=0) |
Protected Member Functions | |
XMLElement (TiXmlElement *element, bool owner) | |
TiXmlElement * | get () const |
TiXmlElement * | releaseOwnership () |
Static Protected Attributes | |
static TokenDict | s_names [] |
Friends | |
class | XMLParser |
This class holds an XML element
enum Type |
Element type as enumeration
XMLElement | ( | ) |
Constructor. Constructs a StreamEnd element
XMLElement | ( | const XMLElement & | src | ) |
Copy constructor
src | Source element |
XMLElement | ( | const XMLElement & | src, | |
bool | response, | |||
bool | result | |||
) |
Constructor. Partially build this element from another one. Copy name and 'to', 'from', 'type', 'id' attributes
src | Source element | |
response | True to reverse 'to' and 'from' attributes | |
result | True 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 | |||
) |
Constructor. Constructs an XML element with a TiXmlElement element with the given name. Used for outgoing elements
name | The element's name | |
attributes | Optional list of attributes | |
text | Optional text for the XML element |
XMLElement | ( | Type | type, | |
NamedList * | attributes = 0 , |
|||
const char * | text = 0 | |||
) |
Constructor. Constructs an XML element with a TiXmlElement element with the given type's name. Used for outgoing elements
type | The element's type | |
attributes | Optional list of attributes | |
text | Optional text for the XML element |
XMLElement | ( | NamedList & | src, | |
const char * | prefix | |||
) |
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
src | The list containing data used to build this XML element | |
prefix | The prefix used to search the list of parameters |
virtual ~XMLElement | ( | ) | [virtual] |
Destructor. Deletes the underlying TiXmlElement if owned
XMLElement | ( | TiXmlElement * | element, | |
bool | owner | |||
) | [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
element | Pointer to a valid TiXmlElement | |
owner | Owner flag |
void addChild | ( | XMLElement * | element | ) |
Add a child to this object. Release the received element
element | XMLElement to add |
Referenced by JGTransport::addTo().
void changeType | ( | Type | t | ) | [inline] |
Change the type of this object
t | The new type of this object |
virtual void destruct | ( | ) | [inline, virtual] |
XMLElement* findFirstChild | ( | Type | type | ) | [inline] |
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
type | Child's type to find |
References XMLElement::findFirstChild().
Referenced by XMLElement::findFirstChild().
XMLElement* findFirstChild | ( | const char * | name = 0 |
) |
Find the first child element of this one. If an element is returned, it is a newly allocated one, not owning its TiXmlElement pointer
name | Optional name of the child |
XMLElement* findNextChild | ( | XMLElement * | element, | |
Type | type | |||
) | [inline] |
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
element | Starting XMLElement. O to find from the beginning | |
type | Child's type to find |
References XMLElement::findNextChild().
Referenced by XMLElement::findNextChild().
XMLElement* findNextChild | ( | XMLElement * | element, | |
const char * | name = 0 | |||
) |
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
element | Starting XMLElement. O to find from the beginning | |
name | Optional name of the child |
const TiXmlAttribute* firstAttribute | ( | ) | const [inline] |
Find the first attribute
TiXmlElement* get | ( | ) | const [inline, protected] |
Get the underlying TiXmlElement
bool getAttribute | ( | const char * | name, | |
String & | value | |||
) | const [inline] |
Get the value of an attribute
name | Attribute's name | |
value | Destination string |
References String::length().
const char* getAttribute | ( | const char * | name | ) | const |
Get the value of an attribute
name | Attribute's name |
virtual void* getObject | ( | const String & | name | ) | const [inline, virtual] |
const char* getText | ( | ) | const |
Get the text of this XML element
static XMLElement* getXml | ( | NamedList & | list, | |
bool | stole = false , |
|||
const char * | name = "xml" , |
|||
const char * | value = 0 | |||
) | [static] |
Get an xml element from a list's parameter
list | The list to be searched for the given parameter | |
stole | True to release parameter ownership (defaults to false) | |
name | Parameter name (defaults to 'xml') | |
value | Optional parameter value to check |
bool hasAttribute | ( | const char * | name, | |
const char * | value | |||
) | const |
Check if an attribute with the given name and value exists
name | Attribute's name | |
value | Attribute's value |
bool hasChild | ( | Type | type | ) | [inline] |
Check if this element has a given child
type | Child's type to find |
References XMLElement::hasChild().
Referenced by XMLElement::hasChild().
bool hasChild | ( | const char * | name | ) | [inline] |
Check if this element has a given child
name | Optional name of the child (check for the first one if 0) |
References TelEngine::destruct().
static bool isType | ( | const char * | txt, | |
Type | type | |||
) | [inline, static] |
Check if the given text is equal to the one associated with the given type
txt | Text to compare | |
type | Element type as enumeration |
const char* name | ( | ) | const [inline] |
Get the TiXmlElement's name
bool nameIs | ( | const char * | text | ) | const [inline] |
Check if the TiXmlElement's name is the given text
text | Text to compare with |
TiXmlElement* releaseOwnership | ( | ) | [protected] |
Release the ownership of the underlying TiXmlElement and returns it if the object owns it
void setAttribute | ( | const char * | name, | |
int | value | |||
) | [inline] |
Set the value of an existing attribute or adds a new one from an integer
name | Attribute's name | |
value | Attribute's value |
void setAttribute | ( | const char * | name, | |
const char * | value | |||
) |
Set the value of an existing attribute or adds a new one
name | Attribute's name | |
value | Attribute's value |
void setAttributeValid | ( | const char * | name, | |
const String & | value | |||
) | [inline] |
Set the value of an existing attribute or adds a new one if the value's length is not 0
name | Attribute's name | |
value | Attribute's value |
void toList | ( | NamedList & | dest, | |
const char * | prefix | |||
) |
Put this element's name, text and attributes to a list of parameters
dest | Destination list | |
prefix | Prefix to add to parameters |
virtual const String& toString | ( | ) | const [inline, virtual] |
Release memory
Reimplemented from GenObject.
void toString | ( | String & | dest, | |
bool | unclose = false | |||
) | const |
Put the element in a buffer
dest | Destination string | |
unclose | True to leave the tag unclosed |
Referenced by XMLElementOut::toBuffer().
Type type | ( | ) | const [inline] |
Get the type of this object
static const char* typeName | ( | Type | type | ) | [inline, static] |
Get the name associated with the given type
type | Element type as enumeration |
References TelEngine::lookup().
bool valid | ( | ) | const [inline] |
Get the validity of this object