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 addAttribute (const std::string &name, const std::string &value)
virtual void addAttribute (const std::string &name, int value)
virtual void addChild (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 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 TagfindChild (const std::string &name, const std::string &attr, const std::string &value="")
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 () const

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 20 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 25 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 30 of file tag.cpp.

~Tag (  )  [virtual]

Virtual destructor.

Definition at line 36 of file tag.cpp.


Member Function Documentation

void addAttribute ( const std::string &  name,
int  value 
) [virtual]

Use this function to add a new attribute to the tag. Tha value is an int here.

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

Definition at line 94 of file tag.cpp.

void addAttribute ( 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 88 of file tag.cpp.

Referenced by RosterManager::ackSubscriptionRequest(), RosterManager::add(), Client::bindResource(), Registration::changePassword(), Registration::createAccount(), Stanza::createIqStanza(), Stanza::createMessageStanza(), Stanza::createPresenceStanza(), Stanza::createSubscriptionStanza(), MessageEventFilter::decorate(), ChatStateFilter::decorate(), NonSaslAuth::doAuth(), FlexibleOffline::fetchMessages(), Registration::fetchRegistrationFields(), VCardManager::fetchVCard(), RosterManager::fill(), Disco::getDiscoInfo(), Disco::getDiscoItems(), RosterManager::handleIq(), PrivacyManager::handleIq(), LastActivity::handleIq(), InBandBytestreamManager::handleIq(), Disco::handleIq(), NonSaslAuth::handleIqID(), RosterManager::handleSubscription(), ClientBase::processSASLChallenge(), LastActivity::query(), MessageEventFilter::raiseMessageEvent(), Registration::removeAccount(), PrivacyManager::removeList(), FlexibleOffline::removeMessages(), InBandBytestreamManager::requestInBandBytestream(), PrivacyManager::requestList(), PrivacyManager::requestListNames(), PrivateXML::requestXML(), MessageSession::send(), InBandBytestream::sendBlock(), PrivacyManager::setActive(), ChatStateFilter::setChatState(), PrivacyManager::setDefault(), RosterManager::setDelimiter(), ClientBase::startSASL(), ClientBase::startTls(), PrivacyManager::store(), Annotations::storeAnnotations(), BookmarkStorage::storeBookmarks(), VCardManager::storeVCard(), PrivateXML::storeXML(), RosterManager::subscribe(), RosterManager::synchronize(), VCard::tag(), 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 52 of file tag.cpp.

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 104 of file tag.cpp.

Referenced by Tag::clone(), Stanza::Stanza(), VCardManager::storeVCard(), PrivateXML::storeXML(), Tag::Tag(), and gloox::tagHook().

StringMap & attributes (  )  [virtual]

Use this function to manipulate the list of attributes.

Returns:
A reference to the list of attributes.

Definition at line 118 of file tag.cpp.

Referenced by Stanza::Stanza().

const 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 113 of file tag.cpp.

Referenced by Tag::clone(), InBandBytestream::filter(), Registration::handleIqID(), RosterManager::handlePrivateXML(), and Stanza::init().

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 123 of file tag.cpp.

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

Tag * clone (  )  const [virtual]

This function creates a deep copy of this Tag.

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

Definition at line 270 of file tag.cpp.

Referenced by Registration::createAccount().

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 197 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 128 of file tag.cpp.

Referenced by DataFormField::DataFormField(), InBandBytestream::filter(), PrivacyManager::handleIq(), InBandBytestreamManager::handleIq(), Disco::handleIq(), Adhoc::handleIq(), PrivacyManager::handleIqID(), LastActivity::handleIqID(), and Stanza::init().

Tag * findChild ( const std::string &  name,
const std::string &  attr,
const std::string &  value = "" 
) [virtual]

This function finds and returns the first element within the child elements of the current tag, that has a certan name, and a certain attribute with a certain value.

Parameters:
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.
Returns:
The found Tag, or NUL.

Definition at line 161 of file tag.cpp.

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

This function finds and returns the first element within the child elements of the current tag that has a matching tag name.

Parameters:
name The name of the element to search for.
Returns:
The found Tag, or NUL.

Definition at line 149 of file tag.cpp.

Referenced by MessageEventFilter::filter(), InBandBytestream::filter(), FlexibleOffline::handleDiscoInfoResult(), FlexibleOffline::handleDiscoItemsResult(), Registration::handleIq(), PrivacyManager::handleIq(), InBandBytestreamManager::handleIq(), Disco::handleIq(), Adhoc::handleIq(), VCardManager::handleIqID(), Registration::handleIqID(), PrivateXML::handleIqID(), PrivacyManager::handleIqID(), NonSaslAuth::handleIqID(), LastActivity::handleIqID(), and Stanza::init().

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, NUL otherwise.

Definition at line 217 of file tag.cpp.

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 137 of file tag.cpp.

Referenced by DataForm::DataForm(), DataFormField::DataFormField(), FlexibleOffline::handleDiscoItemsResult(), PrivacyManager::handleIq(), InBandBytestreamManager::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 174 of file tag.cpp.

Referenced by MessageEventFilter::filter(), ChatStateFilter::filter(), FlexibleOffline::handleDiscoInfoResult(), Adhoc::handleIq(), Registration::handleIqID(), PrivacyManager::handleIqID(), NonSaslAuth::handleIqID(), Stanza::init(), 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 205 of file tag.cpp.

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 191 of file tag.cpp.

Referenced by Stanza::init().

virtual const 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 110 of file tag.h.

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

Tag* parent (  )  [inline]

Returns the tag's parent Tag.

Returns:
The Tag above the current Tag. May be 0.

Definition at line 212 of file tag.h.

Referenced by gloox::tagHook().

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

Sets the XML character data for this Tag.

Parameters:
cdata The new cdata.

Definition at line 47 of file tag.cpp.

Referenced by ClientBase::startSASL().

virtual StanzaType type (  )  const [inline, virtual]

Returns the stanza type.

Returns:
The type of the stanza.

Definition at line 218 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 57 of file tag.cpp.

Referenced by ClientBase::send().


The documentation for this class was generated from the following files:
Generated on Sun Sep 24 21:57:42 2006 for gloox by  doxygen 1.4.7