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="", bool incoming=false)
 Tag (Tag *parent, const std::string &name, const std::string &cdata="", 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 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 const StringMapattributes () const
virtual TagListchildren ()
virtual const TagListchildren () const
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
bool m_incoming

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 = "",
bool  incoming = false 
)

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

Parameters:
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).

Definition at line 25 of file tag.cpp.

Tag ( Tag parent,
const std::string &  name,
const std::string &  cdata = "",
bool  incoming = false 
)

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.
incoming Indicates whether tag names, attributes, attribute values, and cdata shall be escaped (false, default) or not (true).

Definition at line 32 of file tag.cpp.

~Tag (  )  [virtual]

Virtual destructor.

Definition at line 40 of file tag.cpp.


Member Function Documentation

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

Referenced by ClientBase::send().

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 93 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(), Search::fetchSearchFields(), 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(), Search::search(), 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 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 99 of file tag.cpp.

void addChild ( Tag child  )  [virtual]

Use this function to add a child node to the tag. The Tag will be owned by Tag.

Parameters:
child The node to be inserted.

Definition at line 109 of file tag.cpp.

Referenced by Tag::clone(), Registration::createAccount(), Search::search(), Stanza::Stanza(), VCardManager::storeVCard(), PrivateXML::storeXML(), Tag::Tag(), DataFormReported::tag(), DataFormItem::tag(), and 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 52 of file tag.cpp.

Referenced by ClientBase::startSASL().

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

Referenced by gloox::cdataHook().

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 114 of file tag.h.

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

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

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

StringMap & attributes (  )  [virtual]

Use this function to manipulate the list of attributes.

Returns:
A reference to the list of attributes.

Definition at line 123 of file tag.cpp.

Referenced by Stanza::Stanza().

virtual const StringMap& attributes (  )  const [inline, virtual]

Use this function to fetch a const list of attributes.

Returns:
A constant reference to the list of attributes.

Definition at line 132 of file tag.h.

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

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

virtual const TagList& children (  )  const [inline, virtual]

Use this function to fetch a const list of child elements.

Returns:
A constant reference to the list of child elements.

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

Referenced by DataFormField::DataFormField(), MessageEventFilter::filter(), InBandBytestream::filter(), PrivacyManager::handleIq(), InBandBytestreamManager::handleIq(), Disco::handleIq(), Adhoc::handleIq(), PrivacyManager::handleIqID(), LastActivity::handleIqID(), and 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 142 of file tag.cpp.

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

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 154 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(), Search::handleIqID(), Registration::handleIqID(), PrivateXML::handleIqID(), PrivacyManager::handleIqID(), NonSaslAuth::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 certain 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 166 of file tag.cpp.

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

Referenced by MessageEventFilter::filter(), ChatStateFilter::filter(), FlexibleOffline::handleDiscoInfoResult(), Adhoc::handleIq(), Search::handleIqID(), Registration::handleIqID(), PrivacyManager::handleIqID(), NonSaslAuth::handleIqID(), Stanza::init(), and ClientBase::processSASLError().

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

Referenced by Stanza::init().

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

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 213 of file tag.h.

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

Referenced by Stanza::init().

Tag* parent (  )  [inline]

Returns the tag's parent Tag.

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

Definition at line 228 of file tag.h.

Referenced by gloox::tagHook().

virtual StanzaType type (  )  const [inline, virtual]

Returns the stanza type.

Returns:
The type of the stanza.

Definition at line 234 of file tag.h.

Referenced by ClientBase::send().

Tag * clone (  )  const [virtual]

This function creates a deep copy of this Tag.

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

Reimplemented in Stanza.

Definition at line 291 of file tag.cpp.


The documentation for this class was generated from the following files:
Generated on Tue May 1 14:20:27 2007 for gloox by  doxygen 1.5.1