Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Element Class Reference

an XML element. More...

#include <Element.h>

Inheritance diagram for Element:

Inheritance graph
[legend]
Collaboration diagram for Element:

Collaboration graph
[legend]
List of all members.

Public Methods

 Element (const string &name="Element", const StringMap &atts=StringMap(), const ChildList &children=ChildList())
 constructor. More...

Inspectors
return various values from Element

virtual string Get (const string &att) const
virtual StartTagGetStartTag () const
virtual EndTagGetEndTag () const
virtual ChildList GetChildren () const
virtual StringVector GetAttributes () const
virtual StringVector GetValues () const
virtual StringMap GetAttributeMap () const
virtual string GetName () const
Modifiers
change the Element's values

virtual Element Set (const string &att, const string &val)
virtual Element SetAttributeMap (const StringMap &newAttributeMap)
virtual Element SetChildren (const ChildList &newChildren)
virtual Element SetValues (const StringVector &newVals, const StringVector &newAtts=StringVector())
virtual string& operator[] (const string &newAtt)
virtual Element SetName (const string &newName)
Containable
methods inherited from the Containable interface

virtual void Add (XMLChild *const &)
virtual void Delete (XMLChild *const &)
virtual size_t Size () const
virtual bool IsEmpty () const
Writeable
method inherited from the Writeable interface

virtual string ToString () const

Protected Methods

virtual void Init (const string &newNname, const StringMap &newAtts, const ChildList &newChildren)
 Initialize a new name, attribute map, and children.

Object
methods inherited from the Object base class

Element& Copy (const Element &rhs)
 Copy Constructor.

virtual bool Equals (const Element &rhs) const
 operator==.

virtual void NullifyPointers ()
 makes all member pointers initially point to NULL.

virtual void Clear ()
 delete's all member pointers.


Protected Attributes

StartTagstart
 for base classes like EmptyElement.

EndTagend

Detailed Description

an XML element.

An abstraction for an XML element <element foo="bar">foobar</element>


Constructor & Destructor Documentation

Element::Element ( const string & name = "Element",
const StringMap & atts = StringMap(),
const ChildList & children = ChildList() )
 

constructor.

Parameters:
name:   the Element's name
atts:   a Map<string, string> of attributes and values
children:   a list<XMLChild*> of child nodes this element has


Member Function Documentation

void Element::Add ( XMLChild *const & ) [virtual]
 

add a new child node to this element

See also:
Delete()

void Element::Delete ( XMLChild *const & ) [virtual]
 

delete a oldChild from the list of this element's nodes

string Element::Get ( const string & att ) const [virtual]
 

Get a value from the atts Map<string, string>

Parameters:
att:   an attribute
Returns:
a value corresponding to the given att

StringMap Element::GetAttributeMap ( ) const [virtual]
 

Returns:
a Map<string, string> of the element's attributes && values
See also:
GetValues(), GetAttributes()

StringVector Element::GetAttributes ( ) const [virtual]
 

Returns:
a vector<string> of the element's attributes
See also:
GetValues()

ChildList Element::GetChildren ( ) const [virtual]
 

Returns:
the list of children

EndTag * Element::GetEndTag ( ) const [virtual]
 

Returns:
the end tag

string Element::GetName ( ) const [virtual]
 

Returns:
element's name

StartTag * Element::GetStartTag ( ) const [virtual]
 

Returns:
the start tag

StringVector Element::GetValues ( ) const [virtual]
 

Returns:
a vector<string> of the element's values
See also:
GetAttributes()

bool Element::IsEmpty ( ) const [virtual]
 

Returns:
true || false if this element has no children

Element Element::Set ( const string & att,
const string & val ) [virtual]
 

this does the same as element[att] = val

Parameters:
att:   attribute to set
val:   value to set att
Returns:
this Element with the attribute newly set this does the same as element[att] = val;
See also:
operator[]

Element Element::SetAttributeMap ( const StringMap & newAttributeMap ) [virtual]
 

replace the current attributeMap with the given

Parameters:
newAttributeMap:   a new attribute map
Returns:
this element with the new map

Element Element::SetChildren ( const ChildList & newChildren ) [virtual]
 

replace the child nodes with the given list of nodes

Parameters:
newChildren:   new list of child nodes
Returns:
this element with new children

Element Element::SetName ( const string & newName ) [virtual]
 

assign a new name to this element

Parameters:
newName:   the new name
Returns:
this element with the new name

Element Element::SetValues ( const StringVector & newVals,
const StringVector & newAtts = StringVector() ) [virtual]
 

basically the same as SetAttributeMap, just with more params

Parameters:
newVals:   the Map's "words"
newAtts:   the Map's "defs"
Returns:
this element with the new attributes && values
See also:
SetAttributeMap()

size_t Element::Size ( ) const [virtual]
 

Returns:
the number of children of this element

string Element::ToString ( ) const [virtual]
 

Returns:
this element converted into a string

Reimplemented in EmptyElement.

string & Element::operator[] ( const string & newAtt ) [virtual]
 

same as Set() -- sets an attributes with a given value: element[newAtt] = val;

Returns:
reference to the attribute
See also:
Set()


The documentation for this class was generated from the following file:
Generated at Wed May 2 00:21:04 2001 for libXMLement by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001