Public Member Functions

TiXmlAttributeSet Class Reference

#include <tinyxml.h>

Collaboration diagram for TiXmlAttributeSet:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TiXmlAttributeSet ()
 ~TiXmlAttributeSet ()
void Add (TiXmlAttribute *attribute)
void Remove (TiXmlAttribute *attribute)
const TiXmlAttributeFirst () const
TiXmlAttributeFirst ()
const TiXmlAttributeLast () const
TiXmlAttributeLast ()
TiXmlAttributeFind (const char *_name) const
TiXmlAttributeFindOrCreate (const char *_name)
TiXmlAttributeFind (const std::string &_name) const
TiXmlAttributeFindOrCreate (const std::string &_name)

Detailed Description

Definition at line 908 of file tinyxml.h.


Constructor & Destructor Documentation

TiXmlAttributeSet::TiXmlAttributeSet (  )

Definition at line 1453 of file tinyxml.cpp.

{
        sentinel.next = &sentinel;
        sentinel.prev = &sentinel;
}
TiXmlAttributeSet::~TiXmlAttributeSet (  )

Definition at line 1460 of file tinyxml.cpp.

{
        assert( sentinel.next == &sentinel );
        assert( sentinel.prev == &sentinel );
}

Member Function Documentation

void TiXmlAttributeSet::Add ( TiXmlAttribute attribute )

Definition at line 1467 of file tinyxml.cpp.

References Find(), TiXmlAttribute::Name(), and TIXML_STRING.

Referenced by FindOrCreate(), and TiXmlElement::Parse().

{
    #ifdef TIXML_USE_STL
        assert( !Find( TIXML_STRING( addMe->Name() ) ) );       // Shouldn't be multiply adding to the set.
        #else
        assert( !Find( addMe->Name() ) );       // Shouldn't be multiply adding to the set.
        #endif

        addMe->next = &sentinel;
        addMe->prev = sentinel.prev;

        sentinel.prev->next = addMe;
        sentinel.prev      = addMe;
}
TiXmlAttribute * TiXmlAttributeSet::Find ( const std::string &  _name ) const

Definition at line 1502 of file tinyxml.cpp.

References TiXmlNode::next.

{
        for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
        {
                if ( node->name == name )
                        return node;
        }
        return 0;
}
TiXmlAttribute * TiXmlAttributeSet::Find ( const char *  _name ) const

Definition at line 1525 of file tinyxml.cpp.

References TiXmlNode::next.

Referenced by Add(), TiXmlElement::Attribute(), FindOrCreate(), TiXmlElement::Parse(), TiXmlElement::QueryDoubleAttribute(), TiXmlElement::QueryIntAttribute(), TiXmlElement::QueryValueAttribute(), and TiXmlElement::RemoveAttribute().

{
        for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
        {
                if ( strcmp( node->name.c_str(), name ) == 0 )
                        return node;
        }
        return 0;
}
TiXmlAttribute * TiXmlAttributeSet::FindOrCreate ( const char *  _name )

Definition at line 1536 of file tinyxml.cpp.

References Add(), Find(), and TiXmlAttribute::SetName().

Referenced by TiXmlElement::SetAttribute(), and TiXmlElement::SetDoubleAttribute().

{
        TiXmlAttribute* attrib = Find( _name );
        if ( !attrib ) {
                attrib = new TiXmlAttribute();
                Add( attrib );
                attrib->SetName( _name );
        }
        return attrib;
}
TiXmlAttribute * TiXmlAttributeSet::FindOrCreate ( const std::string &  _name )

Definition at line 1512 of file tinyxml.cpp.

References Add(), Find(), and TiXmlAttribute::SetName().

{
        TiXmlAttribute* attrib = Find( _name );
        if ( !attrib ) {
                attrib = new TiXmlAttribute();
                Add( attrib );
                attrib->SetName( _name );
        }
        return attrib;
}
TiXmlAttribute* TiXmlAttributeSet::First (  ) [inline]

Definition at line 918 of file tinyxml.h.

{ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
const TiXmlAttribute* TiXmlAttributeSet::First (  ) const [inline]

Definition at line 917 of file tinyxml.h.

Referenced by TiXmlElement::Accept(), TiXmlElement::ClearThis(), TiXmlElement::CopyTo(), TiXmlElement::FirstAttribute(), and TiXmlElement::Print().

{ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
const TiXmlAttribute* TiXmlAttributeSet::Last (  ) const [inline]

Definition at line 919 of file tinyxml.h.

Referenced by TiXmlElement::LastAttribute().

{ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
TiXmlAttribute* TiXmlAttributeSet::Last (  ) [inline]

Definition at line 920 of file tinyxml.h.

{ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
void TiXmlAttributeSet::Remove ( TiXmlAttribute attribute )

Definition at line 1482 of file tinyxml.cpp.

Referenced by TiXmlElement::ClearThis(), and TiXmlElement::RemoveAttribute().

{
        TiXmlAttribute* node;

        for( node = sentinel.next; node != &sentinel; node = node->next )
        {
                if ( node == removeMe )
                {
                        node->prev->next = node->next;
                        node->next->prev = node->prev;
                        node->next = 0;
                        node->prev = 0;
                        return;
                }
        }
        assert( 0 );            // we tried to remove a non-linked attribute.
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines