System documentation of the GNU Image-Finding Tool

CXMLElement.h
1 /* -*- mode: c++ -*-
2 */
3 /*
4 
5  GIFT, a flexible content based image retrieval system.
6  Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
7 
8  Copyright (C) 2003, 2004 Bayreuth University
9  2005 Bamberg University
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 
24 */
25 /* -*- Mode: c++ -*- */
26 /* the tag above is for making xemacs find the right mode for this file
27  (avoids typing M-x c++-mode M-x font-lock-mode M-x font-lock-mode)
28  */
29 #ifndef _CXMLElement
30 #define _CXMLElement
31 #include "libMRML/include/uses-declarations.h"
32 #include <map>
33 #include <list>
34 #include <string>
35 #include "libMRML/include/CMagic.h"
36 #include "libMRML/include/CAttributeList.h"
37 class CXMLElementVisitor;
38 #include "libMRML/include/CMutex.h"
39 #include "libMRML/include/CNoDelete.h" //debugging
51 class CXMLElement:public CMagic,public CNoDelete{
52 public:
54  typedef list<CXMLElement*> lCChildren;
55 protected:
60 protected:
66  string mName;
68  void setFather(CXMLElement*);
69 
74  string mText;
81  const int mTypeOfNode;
82 public:
86  static int const cTextNode;
90  static int const cElementNode;
91 
92 public:
94  CXMLElement* getFather()const;
95 
97  void addAttribute(const string& inAttribute,long inValue);
99  void addAttribute(const string& inAttribute,double inValue);
101  void addAttribute(const string& inAttribute,const string& inValue);
102 
109  pair<bool,bool> boolReadAttribute(const string& inAttribute)const;
111  pair<bool,long> longReadAttribute(const string& inAttribute)const;
113  pair<bool,double> doubleReadAttribute(const string& inAttribute)const;
123  virtual pair<bool,string> stringReadAttribute(const string& inAttribute)const;
124 
132  CXMLElement* clone(bool inDeep=true)const;
133 
137  void toXML(string& outString,const int=0)const;
141  void traverse(CXMLElementVisitor& inoutVisitor)const;
145  void traverse(CXMLElementVisitor& inoutVisitor);
146 
148  list<CXMLElement*>::const_iterator child_list_begin()const;
151  list<CXMLElement*>::const_iterator child_list_end()const;
153  list<CXMLElement*>::iterator child_list_begin();
156  list<CXMLElement*>::iterator child_list_end();
157 
158 
163  virtual void addChild(CXMLElement* inChild);
169  virtual void addChild(const string&,
170  const char* const* const inAttributeList=0);
171 
175  void moveUp();
180  bool isSubtreeFinished()const;
181 
186  CXMLElement(const string&,
187  const char* const* const inAttributeList=0);
189  virtual ~CXMLElement();
193  CXMLElement(const int inType,
194  const string&);
196  CXMLElement(const string& inString,
197  const list< pair<string,string> >& inList);
199  CXMLElement(const string& inString,
200  const CAttributeList& inList);
204  CXMLElement(const CXMLElement& in);
210  list<pair<string,string> >* createNamedValueList()const;
212  string getText()const;
214  string getName()const;
216  int getTypeOfNode()const;
218  int getNumberOfAttributes()const;
220  void check()const;
221 
222 };
223 
224 #endif
string getText() const
get the text of this
bool isSubtreeFinished() const
A subtree is finished if the current child is identical with itself.
void addAttribute(const string &inAttribute, long inValue)
adding an attribute for integers using the function for strings
pair< bool, long > longReadAttribute(const string &inAttribute) const
reading an attribute for integers using stringReadAttribute
int getNumberOfAttributes() const
get the number of attributes in this
This class is designed for visiting XML document trees.
Definition: CXMLElementVisitor.h:35
list< CXMLElement * >::const_iterator child_list_begin() const
For interoperating with the STL.
This class captures the structure of an XML element.
Definition: CXMLElement.h:51
const int mTypeOfNode
The kind of this node: Stroustrup would kill me for that, but I think doing some inheritance here is ...
Definition: CXMLElement.h:81
CXMLElement * mFather
the father of this
Definition: CXMLElement.h:57
CAttributeList mAttributes
the content: attributes
Definition: CXMLElement.h:64
The use of this class is to control where an element is destroyed.
Definition: CNoDelete.h:40
CXMLElement * mCurrentChild
The child-grandchild-etc.
Definition: CXMLElement.h:59
void moveUp()
make the father of the current node the new current node.
int getTypeOfNode() const
get the name of this
virtual void addChild(CXMLElement *inChild)
Like above.
a simple class destined to contain attribute-value pairs in an easily accessible fashion ...
Definition: CAttributeList.h:36
void traverse(CXMLElementVisitor &inoutVisitor) const
Visit the subtree using a visitor.
CXMLElement * getFather() const
read the father of this
virtual ~CXMLElement()
delete this by first deleting the children
string mName
the name of this element
Definition: CXMLElement.h:66
CXMLElement * clone(bool inDeep=true) const
clone this element with all its content
virtual pair< bool, string > stringReadAttribute(const string &inAttribute) const
reading an attribute for strings
list< pair< string, string > > * createNamedValueList() const
For doing flat configuration, we need to find out all attributes which are visible in this algorithm...
void check() const
checks consistency of attributes
void setFather(CXMLElement *)
change the father of this
CXMLElement(const string &, const char *const *const inAttributeList=0)
Constructing this from a list which is built from what we get from expat.
pair< bool, double > doubleReadAttribute(const string &inAttribute) const
reading an attribute for doubles using stringReadAttribute
string mText
The text/CData contained in this element FIXME: look at zero characters.
Definition: CXMLElement.h:74
pair< bool, bool > boolReadAttribute(const string &inAttribute) const
reading an attribute for booleans using stringReadAttribute it supports several pairs: yes/no true/fa...
lCChildren mChildren
a list containing the children of this element
Definition: CXMLElement.h:62
void toXML(string &outString, const int=0) const
Convert this into an XML string.
string getName() const
get the name of this
static int const cTextNode
This constant is destined to be a value of mTypeOfNode.
Definition: CXMLElement.h:86
static int const cElementNode
This constant is destined to be a value of mTypeOfNode.
Definition: CXMLElement.h:90
list< CXMLElement * >::const_iterator child_list_end() const
For interoperating with the STL.
list< CXMLElement * > lCChildren
a typedef for simple convenience
Definition: CXMLElement.h:54
This is a simple class for debugging.
Definition: CMagic.h:12

Need for discussion? Want to contribute? Contact
help-gift@gnu.org Generated using Doxygen