form.h

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

Generated on Thu Jan 7 08:26:32 2010 for NeL by  doxygen 1.6.1