CXMLElement Class

# CXMLElement Class Reference

[CADIHash.h Index] [CADIHash.h Hierarchy]

This class captures the structure of an XML element More...

`#include <../libInvertedFile/include/CXMLElement.h>`

Inherits: CMagic

## Public Members

- static int const cTextNode
- static int const cElementNode
- CXMLElement* getFather ()
- void addAttribute (const string& inAttribute,long inValue)
- void addAttribute (const string& inAttribute,double inValue)
- void addAttribute (const string& inAttribute,const string& inValue)
- pair<bool,bool> boolReadAttribute (const string& inAttribute)
- pair<bool,long> longReadAttribute (const string& inAttribute)
- pair<bool,double> doubleReadAttribute (const string& inAttribute)
- virtual pair<bool,string> stringReadAttribute (const string& inAttribute)
- CXMLElement* clone (bool inDeep=true)
- void toXML (string& outString,const int=0)
- void traverse (CXMLElementVisitor& inoutVisitor)
- list<CXMLElement*>::const_iterator child_list_begin ()
- list<CXMLElement*>::const_iterator child_list_end ()
- list<CXMLElement*>::iterator child_list_begin ()
- list<CXMLElement*>::iterator child_list_end ()
- virtual void addChild (CXMLElement* inChild)
- virtual void addChild (const string&, const char* const* const inAttributeList=0)
- void moveUp ()
- bool isSubtreeFinished ()
- CXMLElement (const string&, const char* const* const inAttributeList=0)
- CXMLElement (const int inType, const string&)
- CXMLElement (const string& inString, const list< pair<string,string> >& inList)
- CXMLElement (const string& inString, const CAttributeList& inList)
- CXMLElement (const CXMLElement& in)
- list<pair<string,string> >* createNamedValueList ()
- string getText ()
- string getName ()
- int getTypeOfNode ()
- int getNumberOfAttributes ()

## Protected Members

- lCChildren mChildren
- CAttributeList mAttributes
- string mName
- void setFather (CXMLElement*)
- string mText
- const int mTypeOfNode

## Detailed Description

This class captures the structure of an XML element. An Element has children and attributes.

The way a Document tree is built:

AddChildToCurrent: Adds a child, AND MAKES THE CHILD THE NEW CURRENT NODE. moveUp: Makes the father the new current node.

## static int const cTextNode

This constant is destined to be a value of mTypeOfNode

## static int const cElementNode

This constant is destined to be a value of mTypeOfNode

## CXMLElement* getFather()

read the father of this

## void addAttribute(const string& inAttribute,long inValue)

adding an attribute for integers using the function for strings

## void addAttribute(const string& inAttribute,double inValue)

adding an attribute for doubles using using the function for strings

## void addAttribute(const string& inAttribute,const string& inValue)

adding an attribute

## pair<bool,bool> boolReadAttribute(const string& inAttribute)

reading an attribute for booleans using stringReadAttributeit supports several pairs: yes/no true/false y/n

## pair<bool,long> longReadAttribute(const string& inAttribute)

reading an attribute for integers using stringReadAttribute

## pair<bool,double> doubleReadAttribute(const string& inAttribute)

reading an attribute for doubles using stringReadAttribute

## virtual pair<bool,string> stringReadAttribute(const string& inAttribute)

reading an attribute for strings All the attribute functions implement a primitive version of inheritance: We look also at the parents of this, if we do not find a given attribute in this.

this is virtual in order to plug in other methods of inheritance

## CXMLElement* clone(bool inDeep=true)

clone this element with all its content @parameter inDeep if true, this function clones deeply, i.e. children will be cloned, instead of just cloning the pointers to the children and the attributes.

## void toXML(string& outString,const int=0)

Convert this into an XML string

## void traverse(CXMLElementVisitor& inoutVisitor)

Visit the subtree using a visitor

## list<CXMLElement*>::const_iterator child_list_begin()

For interoperating with the STL

## list<CXMLElement*>::const_iterator child_list_end()

For interoperating with the STL

## list<CXMLElement*>::iterator child_list_begin()

For interoperating with the STL

## list<CXMLElement*>::iterator child_list_end()

For interoperating with the STL

## virtual void addChild(CXMLElement* inChild)

Like above. Hovewer, here we would like to add anything inherited from CXMLElement.

## virtual void addChild(const string&, const char* const* const inAttributeList=0)

Add a child with the given attributes to the current node, and MAKE THIS CHILD THE NEW CURRENT NODE.

## void moveUp()

make the father of the current node the new current node.

## bool isSubtreeFinished()

A subtree is finished if the current child is identical with itself

## CXMLElement(const string&, const char* const* const inAttributeList=0)

Constructing this from a list which is built from what we get from expat

## CXMLElement(const int inType, const string&)

Constructing a text node from what expat gives us

## CXMLElement(const string& inString, const list< pair<string,string> >& inList)

Constructing this from more c++-like structures

## CXMLElement(const string& inString, const CAttributeList& inList)

Constructing this from more c++-like structures

## CXMLElement(const CXMLElement& in)

Make this a deep copy of the input

## list<pair<string,string> >* createNamedValueList()

For doing flat configuration, we need to find out all attributes which are visible in this algorithm

## string getText()

get the text of this

## string getName()

get the name of this

## int getTypeOfNode()

get the name of this

## int getNumberOfAttributes()

get the number of attributes in this

## lCChildren mChildren

a list containing the children of this element

## CAttributeList mAttributes

the content: attributes

## string mName

the name of this element

## void setFather(CXMLElement*)

change the father of this

## string mText

The text/CData contained in this element FIXME: look at zero characters

## const int mTypeOfNode

The kind of this node: Stroustrup would kill me for that, but I think doing some inheritance here is not really what I want, so I do some if-ing

Author: Wolfgang Müller Documentation generated by muellerw@pc7170 on Son Okt 8 16:04:40 CEST 2000 | Kdoc