Tag Class Reference

This is an abstraction of an XML element. More...

#include <tag.h>

Inherited by Stanza.

Inheritance diagram for Tag:

Inheritance graph
[legend]
Collaboration diagram for Tag:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::list< Tag * > TagList

Public Member Functions

 Tag ()
 Tag (const std::string &name, const std::string &cdata="")
 Tag (Tag *parent, const std::string &name, const std::string &cdata="")
virtual ~Tag ()
virtual const std::string xml () const
virtual void addAttrib (const std::string &name, const std::string &value)
virtual void addChild (Tag *child)
virtual void setCData (const std::string &cdata)
virtual void addCData (const std::string &cdata)
virtual std::string name () const
virtual std::string cdata () const
virtual StringMapattributes ()
virtual TagListchildren ()
virtual const std::string findAttribute (const std::string &name) const
virtual bool hasAttribute (const std::string &name, const std::string &value="") const
virtual TagfindChild (const std::string &name)
virtual bool hasChild (const std::string &name, const std::string &attr="", const std::string &value="") const
virtual TagfindChildWithAttrib (const std::string &attr, const std::string &value="")
virtual bool hasChildWithAttrib (const std::string &attr, const std::string &value="") const
virtual bool empty () const
bool hasChildWithCData (const std::string &name, const std::string &cdata) const
Tagparent ()
virtual StanzaType type () const
virtual Tagclone ()

Protected Attributes

std::string m_name
StringMap m_attribs
std::string m_cdata
TagList m_children
Tagm_parent
StanzaType m_type

Detailed Description

This is an abstraction of an XML element.

Author:
Jakob Schroeter <js@camaya.net>
Since:
0.4

Definition at line 32 of file tag.h.


Member Typedef Documentation

typedef std::list<Tag*> TagList
 

A list of Tags.

Definition at line 38 of file tag.h.


Constructor & Destructor Documentation

Tag  ) 
 

Creates an empty tag.

Definition at line 18 of file tag.cpp.

Referenced by Tag::clone(), Stanza::createIqStanza(), Stanza::createMessageStanza(), Stanza::createPresenceStanza(), and Stanza::createSubscriptionStanza().

Tag const std::string &  name,
const std::string &  cdata = ""
 

Creates a new tag with agiven name (and XML character data, if given).

Parameters:
name The name of the element.
cdata The XML character data of the element.

Definition at line 23 of file tag.cpp.

Tag Tag parent,
const std::string &  name,
const std::string &  cdata = ""
 

Creates a new tag as a child tag of the given parent, with a given name (and XML character data, if given).

Parameters:
parent The parent tag.
name The name of the element.
cdata The XML character data of the element.

Definition at line 28 of file tag.cpp.

References Tag::addChild(), and Tag::m_parent.

~Tag  )  [virtual]
 

Virtual destructor.

Definition at line 34 of file tag.cpp.

References Tag::m_children.


Member Function Documentation

void addAttrib const std::string &  name,
const std::string &  value
[virtual]
 

Use this function to add a new attribute to the tag.

Parameters:
name The name of the attribute.
value The value of the attribute.

Definition at line 86 of file tag.cpp.

References Tag::m_attribs.

Referenced by RosterManager::ackSubscriptionRequest(), RosterManager::add(), Client::bindResource(), Registration::changePassword(), Registration::createAccount(), Stanza::createIqStanza(), Stanza::createMessageStanza(), Stanza::createPresenceStanza(), Stanza::createSubscriptionStanza(), NonSaslAuth::doAuth(), FlexibleOffline::fetchMessages(), Registration::fetchRegistrationFields(), RosterManager::fill(), Disco::getDiscoInfo(), Disco::getDiscoItems(), PrivacyManager::handleIq(), LastActivity::handleIq(), Disco::handleIq(), LastActivity::query(), Registration::removeAccount(), PrivacyManager::removeList(), FlexibleOffline::removeMessages(), PrivacyManager::requestList(), PrivacyManager::requestListNames(), PrivateXML::requestXML(), PrivacyManager::setActive(), PrivacyManager::setDefault(), RosterManager::setDelimiter(), ClientBase::startSASL(), ClientBase::startTls(), PrivacyManager::store(), Annotations::storeAnnotations(), BookmarkStorage::storeBookmarks(), PrivateXML::storeXML(), RosterManager::subscribe(), RosterManager::synchronize(), DataFormField::tag(), DataForm::tag(), gloox::tagHook(), PrivacyManager::unsetActive(), PrivacyManager::unsetDefault(), and RosterManager::unsubscribe().

void addCData const std::string &  cdata  )  [virtual]
 

Adds the string to the existing XML character data for this Tag.

Parameters:
cdata The additional cdata.

Definition at line 50 of file tag.cpp.

References Tag::m_cdata.

Referenced by gloox::cdataHook().

void addChild Tag child  )  [virtual]
 

Use this function to add a child node to the tag.

Parameters:
child The node to be inserted.

Definition at line 92 of file tag.cpp.

References Tag::m_children.

Referenced by RosterManager::add(), Client::bindResource(), Registration::changePassword(), Tag::clone(), Registration::createAccount(), Stanza::createPresenceStanza(), NonSaslAuth::doAuth(), FlexibleOffline::fetchMessages(), Registration::fetchRegistrationFields(), RosterManager::fill(), Registration::removeAccount(), PrivacyManager::removeList(), FlexibleOffline::removeMessages(), PrivacyManager::requestList(), PrivacyManager::requestListNames(), PrivateXML::requestXML(), PrivacyManager::setActive(), PrivacyManager::setDefault(), Stanza::Stanza(), PrivacyManager::store(), Annotations::storeAnnotations(), BookmarkStorage::storeBookmarks(), PrivateXML::storeXML(), RosterManager::synchronize(), Tag::Tag(), DataFormField::tag(), DataForm::tag(), gloox::tagHook(), PrivacyManager::unsetActive(), PrivacyManager::unsetDefault(), and RosterManager::unsubscribe().

StringMap & attributes  )  [virtual]
 

Use this function to manipulate the list of attributes.

Returns:
A reference to the list of attributes.

Definition at line 106 of file tag.cpp.

References Tag::m_attribs.

Referenced by Stanza::Stanza().

std::string cdata  )  const [virtual]
 

Use this function to retrieve the XML character data of an element.

Returns:
The cdata the element contains.

Definition at line 101 of file tag.cpp.

References Tag::m_cdata.

Referenced by Tag::clone(), and RosterManager::handlePrivateXML().

Tag::TagList & children  )  [virtual]
 

Use this function to manipulate the list of child elements.

Returns:
A reference to the list of child elements.

Definition at line 111 of file tag.cpp.

References Tag::m_children.

Referenced by DataForm::DataForm(), DataFormField::DataFormField(), FlexibleOffline::handleDiscoItemsResult(), PrivateXML::handleIqID(), PrivacyManager::handleIqID(), BookmarkStorage::handlePrivateXML(), Annotations::handlePrivateXML(), Stanza::init(), and Stanza::Stanza().

Tag * clone  )  [virtual]
 

This function creates a deep copy of this Tag.

Returns:
An independent copy of the Tag.
Since:
0.7

Definition at line 242 of file tag.cpp.

References Tag::addChild(), Tag::cdata(), Tag::m_attribs, Tag::m_children, Tag::name(), and Tag::Tag().

virtual bool empty  )  const [inline, virtual]
 

Returns whether a Tag is considered empty, i.e. invalid.

Returns:
True if the Tag is valid, false if not.

Definition at line 177 of file tag.h.

const std::string findAttribute const std::string &  name  )  const [virtual]
 

This function can be used to retrieve the value of a Tag's attribute.

Parameters:
name The name of the attribute to look for.
Returns:
The value of the attribute if found, an empty string otherwise.

Definition at line 116 of file tag.cpp.

References Tag::m_attribs.

Referenced by PrivacyManager::handleIq(), Adhoc::handleIq(), LastActivity::handleIqID(), and Stanza::init().

Tag * findChild const std::string &  name  )  [virtual]
 

This function finds and returns an element within the child elements of the current tag.

Parameters:
name The name of the element to search for.
Returns:
The found Tag, or an empty (invalid) Tag.

Definition at line 137 of file tag.cpp.

References Tag::m_children.

Referenced by FlexibleOffline::handleDiscoInfoResult(), FlexibleOffline::handleDiscoItemsResult(), Registration::handleIq(), PrivacyManager::handleIq(), Adhoc::handleIq(), Registration::handleIqID(), PrivateXML::handleIqID(), PrivacyManager::handleIqID(), NonSaslAuth::handleIqID(), and LastActivity::handleIqID().

Tag * findChildWithAttrib const std::string &  attr,
const std::string &  value = ""
[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.

Parameters:
attr The name of the attribute of the child element.
value The value of the attribute of the child element.
Returns:
The child if found, an empty Tag otherwise.

Definition at line 189 of file tag.cpp.

References Tag::m_children.

Referenced by Stanza::init().

bool hasAttribute const std::string &  name,
const std::string &  value = ""
const [virtual]
 

Checks whether the tag has a attribute with given name and optional value.

Parameters:
name The name of the attribute to check for.
value The value of the attribute to check for.
Returns:
Whether the attribute exists (optionally with the given value).

Definition at line 125 of file tag.cpp.

References Tag::m_attribs.

Referenced by DataForm::DataForm(), DataFormField::DataFormField(), FlexibleOffline::handleDiscoItemsResult(), PrivacyManager::handleIq(), NonSaslAuth::handleIqID(), and Stanza::init().

bool hasChild const std::string &  name,
const std::string &  attr = "",
const std::string &  value = ""
const [virtual]
 

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.

Parameters:
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.
Returns:
True if the given child element exists, @ false otherwise.

Definition at line 149 of file tag.cpp.

References Tag::m_children.

Referenced by FlexibleOffline::handleDiscoInfoResult(), Adhoc::handleIq(), Registration::handleIqID(), NonSaslAuth::handleIqID(), and ClientBase::processSASLError().

bool hasChildWithAttrib const std::string &  attr,
const std::string &  value = ""
const [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.

Parameters:
attr The name of the attribute of the child element.
value The value of the attribute of the child element.
Returns:
True if any such child element exists, @ false otherwise.

Definition at line 177 of file tag.cpp.

References Tag::m_children.

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.

Parameters:
name The name of the child element.
cdata The character data that has to exist in the child element.
Returns:
True if a child element with given cdata exists, false otherwise.

Definition at line 163 of file tag.cpp.

References Tag::m_children.

virtual std::string name  )  const [inline, virtual]
 

Use this function to retrieve the name of an element.

Returns:
The name of the tag.

Definition at line 102 of file tag.h.

Referenced by Tag::clone(), DataForm::DataForm(), and Component::handleNormalNode().

Tag* parent  )  [inline]
 

Returns the tag's parent Tag.

Returns:
The Tag above the current Tag.

Definition at line 192 of file tag.h.

void setCData const std::string &  cdata  )  [virtual]
 

Sets the XML character data for this Tag.

Parameters:
cdata The new cdata.

Definition at line 45 of file tag.cpp.

References Tag::m_cdata.

Referenced by ClientBase::startSASL().

virtual StanzaType type  )  const [inline, virtual]
 

Returns the stanza type.

Returns:
The type of the stanza.

Definition at line 198 of file tag.h.

Referenced by ClientBase::send().

const std::string xml  )  const [virtual]
 

This function can be used to retrieve the complete XML of a tag as a string. It includes all the attributes, child nodes and character data.

Returns:
The complete XML.

Definition at line 55 of file tag.cpp.

References Tag::m_attribs, and Tag::m_name.

Referenced by ClientBase::send().


The documentation for this class was generated from the following files:
Generated on Mon Jan 16 16:20:01 2006 for gloox by  doxygen 1.4.6