nxmlnode.h

Go to the documentation of this file.
00001 // LICENSE: (Please see the file COPYING for details)
00002 //
00003 // NUS - Nemesis Utilities System: A C++ application development framework 
00004 // Copyright (C) 2006, 2008 Otavio Rodolfo Piske
00005 //
00006 //  This file is part of NUS
00007 //
00008 //  This library is free software; you can redistribute it and/or
00009 //  modify it under the terms of the GNU Lesser General Public
00010 //  License as published by the Free Software Foundation version 2.1
00011 //  of the License.
00012 //
00013 //  This library is distributed in the hope that it will be useful,
00014 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //  Lesser General Public License for more details.
00017 //
00018 //  You should have received a copy of the GNU Lesser General Public
00019 //  License along with this library; if not, write to the Free Software
00020 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021 //
00022 #ifndef NXMLNODE_H
00023 #define NXMLNODE_H
00024 
00025 #include <libxml/tree.h>
00026 
00035 #include "ndefs.h"
00036 #include "nobject.h"
00037 #include "nexception.h"
00038 #include "nstring.h"
00039 #include "nexception.h"
00040 #include "nxmlerror.h"
00041 
00042 
00048 class DllDeclSpec NXmlNode: public NObject { 
00049       // Since I don't want to expose the interface (i.e.: by making the constructor
00050       // NXmlNode(xmlNodePtr node) public) I set NXmlDocument, NXmlReader and NXmlWriter
00051       //  our 'friend' classes. TODO: avoid using all this 'friendship'
00052       friend class NXmlDocument;
00053       friend class NXmlReader;
00054       friend class NXmlWriter;
00055       
00056       public:
00060             enum CopyMode { 
00061                   RECURSIVE,        
00062                   NONRECURSIVE      
00063             };
00064             
00068             NXmlNode(void);
00069             
00074             NXmlNode(const NString &name);
00075             
00081             NXmlNode(const NString &name, const NString &data);
00082             
00087             NXmlNode (const NXmlNode &other);
00088             
00089             
00093             ~NXmlNode(void);
00094             
00099             void setName(const NString &name);  
00100             
00105             NString getName(void) const;
00106             
00111             void setData(const NString &data);
00112             
00117             NString getData(void) const;
00118             
00123             bool isBlank(void) const;
00124             
00129             bool isText(void) const;
00130             
00138             bool isNull(void) const;
00139             
00145             NXmlNode addChild(const NString &name);
00152             NXmlNode addChild(const NString &name, const NString &data);
00153             
00154             
00160             NXmlNode addNextSibling(const NString &name);
00161             
00168             NXmlNode addNextSibling(const NString &name, const NString &data);
00169             
00170             
00176             NXmlNode addPreviousSibling(const NString &name);
00177             
00184             NXmlNode addPreviousSibling(const NString &name, const NString &data);
00185             
00186             
00192             NXmlNode getChild(void);
00193             
00198             NXmlNode getLast(void);
00199             
00204             NXmlNode getParent(void);
00205             
00210             NXmlNode getNext(void);
00211             
00217             NXmlNode getPrevious(void);
00218                         
00223             bool hasChild(void) const;
00224             
00229             bool hasLast(void) const;
00230             
00237             bool hasParent(void) const;
00238             
00243             bool hasNext(void) const;
00244             
00249             bool hasPrevious(void) const;
00250             
00251             
00257             const NXmlNode getChild(void) const;
00258             
00263             const NXmlNode getLast(void) const;
00264             
00269             const NXmlNode getParent(void) const;
00270             
00275             const NXmlNode getNext(void) const;
00276             
00282             const NXmlNode getPrevious(void) const;
00283             
00284             
00291             NXmlNode &addProperty(const NString &name, const NString &data);
00292             
00298             bool removeProperty(const NString &name);
00299             
00305             NString getProperty(const NString &name) const;
00306             
00312             bool hasProperty(const NString &name) const;
00313             
00319             bool removeChild(void);
00320             
00327             bool removeChild(const NString &name);
00328             
00334             bool removeNextSibling(void);
00335             
00342             bool removeNextSibling(const NString &name);
00343             
00349             bool removePreviousSibling(void);
00350             
00357             bool removePreviousSibling(const NString &name);
00358             
00359             
00365             NXmlNode find(const NString &name);
00366             
00372             const NXmlNode find(const NString &name) const;
00373             
00374             
00380             NXmlNode copy(const NXmlNode &other) const;
00381             
00382             
00388             NXmlNode &operator=(const NXmlNode &rhs);
00389       private:
00390             xmlNodePtr m_node;
00391             
00392             void init(const NString &name);
00393             const xmlNodePtr getNode(void) const;
00394             
00395             xmlNodePtr createNode(const NString &name);
00396             xmlNodePtr createNode(const NString &name, const NString &data);
00397             
00398             // Used by NXmlDocument and NXmlReader
00399             NXmlNode(xmlNodePtr node);
00400 
00401 };
00402 
00403 #endif // NXMLNODE_H

Generated on Wed Mar 5 23:10:36 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4