gloox
0.9.9.12
|
#include <tag.h>
Public Types | |
typedef std::pair< std::string, std::string > | Attribute |
typedef std::list< Attribute > | AttributeList |
typedef std::list< Tag * > | TagList |
Public Member Functions | |
GLOOX_DEPRECATED_CTOR | Tag () |
Tag (const std::string &name, const std::string &cdata="", bool incoming=false) | |
Tag (Tag *parent, const std::string &name, const std::string &cdata="", bool incoming=false) | |
Tag (const std::string &name, const std::string &attrib, const std::string &value, bool incoming=false) | |
Tag (Tag *parent, const std::string &name, const std::string &attrib, const std::string &value, bool incoming=false) | |
virtual | ~Tag () |
virtual const std::string | xml () const |
virtual void | addAttribute (const std::string &name, const std::string &value) |
virtual void | addAttribute (const std::string &name, int value) |
virtual void | addAttribute (const std::string &name, long value) |
virtual void | setAttributes (const AttributeList &attributes) |
virtual void | addChild (Tag *child) |
virtual void | addChildCopy (const Tag *child) |
virtual void | setCData (const std::string &cdata) |
virtual void | addCData (const std::string &cdata) |
virtual const std::string & | name () const |
virtual const std::string & | cdata () const |
virtual AttributeList & | attributes () |
virtual const AttributeList & | attributes () const |
virtual TagList & | children () |
virtual const TagList & | children () const |
virtual const std::string | findAttribute (const std::string &name) const |
virtual bool | hasAttribute (const std::string &name, const std::string &value="") const |
virtual Tag * | findChild (const std::string &name) const |
virtual Tag * | findChild (const std::string &name, const std::string &attr, const std::string &value="") const |
virtual bool | hasChild (const std::string &name, const std::string &attr="", const std::string &value="") const |
virtual Tag * | findChildWithAttrib (const std::string &attr, const std::string &value="") const |
virtual bool | hasChildWithAttrib (const std::string &attr, const std::string &value="") const |
TagList | findChildren (const std::string &name) const |
void | removeChild (Tag *tag) |
virtual GLOOX_DEPRECATED bool | empty () const |
bool | hasChildWithCData (const std::string &name, const std::string &cdata) const |
Tag * | parent () const |
virtual StanzaType | type () const |
virtual Tag * | clone () const |
Tag * | findTag (const std::string &expression) |
Tag::TagList | findTagList (const std::string &expression) |
bool | operator== (const Tag &right) const |
bool | operator!= (const Tag &right) const |
operator bool () const |
Static Public Member Functions | |
static const std::string | escape (std::string what) |
static const std::string | relax (std::string what) |
Protected Types | |
enum | XPathError { XPNoError, XPExpectedLeftOperand } |
typedef std::pair<std::string, std::string> Attribute |
typedef std::list<Attribute> AttributeList |
|
protected |
Tag | ( | ) |
|
explicit |
Creates a new tag with a given name (and XML character data, if given).
name | The name of the element. |
cdata | The XML character data of the element. |
incoming | Indicates whether tag names, attributes, attribute values, and cdata shall be escaped (false, default) or not (true). |
|
explicit |
Creates a new tag as a child tag of the given parent, with a given name (and XML character data, if given).
parent | The parent tag. |
name | The name of the element. |
cdata | The XML character data of the element. |
incoming | Indicates whether tag names, attributes, attribute values, and cdata shall be escaped (false, default) or not (true). |
|
explicit |
Creates a new tag with a given name and an attribute.
name | The name of the element. |
attrib | The attribute name. |
value | The attribute value. |
incoming | Indicates whether tag names, attributes, attribute values, and cdata shall be escaped (false, default) or not (true). |
|
explicit |
Creates a new tag as a child tag of the given parent, with a given name and an attribute.
parent | The parent tag. |
name | The name of the element. |
attrib | The attribute name. |
value | The attribute value. |
incoming | Indicates whether tag names, attributes, attribute values, and cdata shall be escaped (false, default) or not (true). |
|
virtual |
|
virtual |
|
virtual |
|
inlinevirtual |
|
virtual |
|
virtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
|
inlinevirtual |
Returns whether the Tag is considered empty, i.e. invalid.
|
static |
Does some fancy escaping. (& –> &, etc).
what | A string to escape. |
|
virtual |
|
virtual |
|
virtual |
This function finds and returns the first element within the child elements of the current tag, that has a certain name, and a certain attribute with a certain value.
name | The name of the element to search for. |
attr | The name of the attribute of the child element. |
value | The value of the attribute of the child element. |
Tag::TagList findChildren | ( | const std::string & | name | ) | const |
Returns a list of child tags of the current tag with the given name.
name | The name of the tags to look for. |
|
virtual |
This function checks whether the Tag has a child element which posesses a given attribute with an optional value. The name of the child element does not matter.
attr | The name of the attribute of the child element. |
value | The value of the attribute of the child element. |
Tag * findTag | ( | const std::string & | expression | ) |
Evaluates the given XPath expression and returns the result Tag. If more than one Tag match, only the first one is returned.
expression | An XPath expression to evaluate. |
Tag::TagList findTagList | ( | const std::string & | expression | ) |
Evaluates the given XPath expression and returns the matched Tags.
expression | An XPath expression to evaluate. |
|
virtual |
|
inlinevirtual |
This function checks whether the Tag has a child element with a given name, and optionally this child element is checked for having a given attribute with an optional value.
name | The name of the child element. |
attr | The name of the attribute of the child element. |
value | The value of the attribute of the child element. |
|
inlinevirtual |
This function checks whether the Tag has a child element which posesses a given attribute with an optional value. The name of the child element does not matter.
attr | The name of the attribute of the child element. |
value | The value of the attribute of the child element. |
bool hasChildWithCData | ( | const std::string & | name, |
const std::string & | cdata | ||
) | const |
This function checks whether a child element with given name exists and has XML character data that equals the given cdata string.
name | The name of the child element. |
cdata | The character data that has to exist in the child element. |
|
inlinevirtual |
|
inline |
|
inline |
bool operator== | ( | const Tag & | right | ) | const |
|
inline |
|
static |
Reverses operation of escape(). (& –> &).
what | A string to de-escape. |
|
inline |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
virtual |