Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Element.h

00001 // Copyright (C) 2001 Kevin Duffy <kevin@buhbird.com>
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License, or (at your option) any later version.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 #ifndef ELEMENT_H
00017 #define ELEMENT_H
00018 
00019 #include "StartTag.h"
00020 #include "EndTag.h"
00021 #include "XMLChild.h"
00022 #include <Containable.h>
00023 #include <list>
00024 
00026 typedef list<XMLChild*> ChildList, XMLChildList;
00027 
00029 
00032 class Element : virtual public Object,
00033                 virtual public Writeable,
00034                 virtual public Containable<XMLChild*>
00035 {
00036    public:
00038 
00042       Element(const string& name = "Element",
00043               const StringMap& atts = StringMap(),
00044               const ChildList& children = ChildList());
00045 
00055       virtual string       Get(const string& att) const; 
00056 
00058       virtual StartTag*    GetStartTag() const;
00059 
00061       virtual EndTag*      GetEndTag() const;
00062 
00064       virtual ChildList    GetChildren() const;
00065 
00069       virtual StringVector GetAttributes() const;
00070 
00074       virtual StringVector GetValues() const;
00075 
00079       virtual StringMap    GetAttributeMap() const;
00080 
00082       virtual string       GetName() const;
00083 
00085 
00090 
00098       virtual Element Set(const string& att, const string& val);
00099 
00104       virtual Element SetAttributeMap(const StringMap& newAttributeMap);
00105 
00110       virtual Element SetChildren(const ChildList& newChildren);
00111 
00118       virtual Element SetValues(const StringVector& newVals, 
00119                                 const StringVector& newAtts = StringVector());
00120 
00126       virtual string& operator[] (const string& newAtt);
00127 
00132       virtual Element SetName(const string& newName);
00134 
00143       virtual void Add(XMLChild* const &); 
00144 
00148       virtual void Delete(XMLChild* const &); 
00149 
00151       virtual size_t Size() const; 
00152       
00154       virtual bool IsEmpty() const;
00156 
00157 
00163       virtual string ToString() const;
00165 
00166    protected:
00168       virtual void Init(const string& newNname,
00169                         const StringMap& newAtts,
00170                         const ChildList& newChildren);
00171 
00176 
00177       Element& Copy(const Element& rhs);
00178 
00180       virtual  bool Equals(const Element& rhs) const;
00181 
00183       virtual void NullifyPointers();
00184 
00186       virtual void Clear();
00188 
00190       StartTag* start;
00191       EndTag* end;
00192 
00193    private:
00194       ChildList* children;
00195 };
00196 
00197 typedef list<Element*> ElementList, XMLementList;
00198 typedef Element XMLement;
00199 #endif

Generated at Wed May 2 00:21:01 2001 for libXMLement by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001