# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

form.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef _NLGEORGES_FORM_H
00027 #define _NLGEORGES_FORM_H
00028 
00029 #include        "nel/misc/types_nl.h"
00030 #include        "nel/georges/u_form.h"
00031 #include        "form_elm.h"
00032 #include        "header.h"
00033 
00034 extern bool convertFormFile (const char *oldFileName, const char *newFileName);
00035 
00036 namespace NLGEORGES
00037 {
00038 
00039 class UFormElm;
00040 
00044 class CForm : public UForm
00045 {
00046         friend class CFormLoader;
00047         friend bool convertFormFile (const char *oldFileName, const char *newFileName);
00048 public:
00049 
00050         enum { HeldElementCount = 4 };
00051 
00052         // From UForm
00053         UFormElm&               getRootNode ();
00054         const UFormElm& getRootNode () const;
00055         const std::string &getComment () const;
00056 
00057 
00058 #pragma warning (disable : 4355)
00059         CForm ();
00060         ~CForm ();
00061 
00062         // Clean the form. Erase parents.
00063         void                            clean ();
00064 
00065         // ** Types
00066 
00067         // ** Header
00068         CFileHeader                     Header;
00069 
00070         // ** Body
00071 
00073         CFormElmStruct          Elements;
00074 
00076         CFormElmStruct          *HeldElements[HeldElementCount];
00077 
00078         // ** IO functions
00079         // Set the filename before saving the form
00080         void                            write (xmlDocPtr doc, const char *filename, bool georges4CVS);
00081 
00082         // ** Parent access
00083 
00084         // Insert parent before parent indexed "before".
00085         bool                            insertParent (uint before, const char *filename, CForm *parent);
00086 
00087         // Remove a parent from parent list
00088         void                            removeParent (uint parent);
00089 
00090         // Get a parent
00091         CForm *                         getParent (uint parent) const;
00092         const std::string       &getParentFilename (uint parent) const;
00093 
00094         // Get parent count
00095         uint                            getParentCount () const;
00096 
00097         // Clear parents
00098         void                            clearParents ();
00099 
00100         // Get the form filename with extension
00101         const std::string       &getFilename () const;
00102 
00103         // Error handling
00104         void                            warning (bool exception, const char *function, const char *format, ... ) const;
00105 
00106 private:
00107 
00108         // A parent structure
00109         class CParent
00110         {
00111         public:
00112                 std::string                                     ParentFilename;
00113                 NLMISC::CSmartPtr<CForm>        Parent;
00114         };
00115 
00117         std::vector<CParent>                    ParentList;
00118 
00119         // CFormLoader call it
00120         // Set the filename before reading the form
00121         void                            read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const char *filename);
00122 
00123         // Called by read
00124         void                            readParent (const char *parent, CFormLoader &loader);
00125 
00126         // The form filename
00127         std::string                     _Filename;
00128 };
00129 
00130 } // NLGEORGES
00131 
00132 #endif // _NLGEORGES_FORM_H
00133