00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _NLGEORGES__FORM_DFN_H
00027 #define _NLGEORGES__FORM_DFN_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/smart_ptr.h"
00031 #include "nel/georges/u_form_dfn.h"
00032 #include "nel/georges/u_form_elm.h"
00033 #include "header.h"
00034 #include "georges/type.h"
00035
00036 bool convertDfnFile (const char *oldFileName, const char *newFileName);
00037
00038 namespace NLGEORGES
00039 {
00040
00041 class CFormLoader;
00042
00046 class CFormDfn : public UFormDfn
00047 {
00048 friend class CForm;
00049 friend class CType;
00050 friend class CFormElm;
00051 friend class CFormLoader;
00052 friend class CFormElmStruct;
00053 friend bool convertDfnFile (const char *oldFileName, const char *newFileName);
00054 public:
00055
00056
00057 CFormDfn ()
00058 {
00059 Round = 0xffffffff;
00060 }
00061
00062
00063 class CEntry
00064 {
00065 friend class CType;
00066 friend class CForm;
00067 friend class CFormElm;
00068 friend class CFormDfn;
00069 friend class CFormElmStruct;
00070 friend bool convertDfnFile (const char *oldFileName, const char *newFileName);
00071 public:
00072
00073 CEntry ()
00074 {
00075 TypeElement = EntryType;
00076 FilenameExt = "*.*";
00077 }
00078
00079
00080 class CType *getTypePtr ();
00081
00082
00083 const CType *getTypePtr () const;
00084
00085
00086 CFormDfn *getDfnPtr ();
00087
00088
00089 const CFormDfn *getDfnPtr () const;
00090
00091
00092 TEntryType getType () const;
00093
00094
00095 void setType (CFormLoader &loader, const char *filename);
00096
00097
00098 void setDfn (CFormLoader &loader, const char *filename);
00099
00100
00101 void setDfnPointer ();
00102
00103
00104 const std::string &getName () const;
00105
00106
00107 void setName (const char *name);
00108
00109
00110 const std::string &getFilename() const;
00111
00112
00113 const std::string &getFilenameExt() const;
00114
00115
00116 void setFilename (const char *def);
00117
00118
00119 void setFilenameExt (const char *ext);
00120
00121
00122 const std::string &getDefault () const;
00123
00124
00125 void setDefault (const char *def);
00126
00127
00128 void setArrayFlag (bool flag);
00129
00130
00131 bool getArrayFlag () const;
00132
00133 private:
00134
00135 std::string Name;
00136
00137
00138 TEntryType TypeElement;
00139
00140
00141 bool Array;
00142
00143
00144 std::string Filename;
00145
00146
00147 std::string Default;
00148
00149
00150 std::string FilenameExt;
00151
00152
00153 NLMISC::CSmartPtr<CType> Type;
00154
00155
00156 NLMISC::CSmartPtr<CFormDfn> Dfn;
00157 };
00158
00159
00160 class CParent
00161 {
00162 public:
00163
00164 std::string ParentFilename;
00165
00166
00167 NLMISC::CSmartPtr<CFormDfn> Parent;
00168 };
00169
00170
00171 void write (xmlDocPtr root, const char *filename, bool georges4CVS);
00172
00173
00174 uint countParentDfn (uint32 round=UFormElm::LastRound++) const;
00175
00176
00177 void getParentDfn (std::vector<CFormDfn*> &array, uint32 round=UFormElm::LastRound++);
00178
00179
00180 void getParentDfn (std::vector<const CFormDfn*> &array, uint32 round=UFormElm::LastRound++) const;
00181
00182
00183 uint getNumParent () const;
00184
00185
00186 void setNumParent (uint size);
00187
00188
00189 void setParent (uint parent, CFormLoader &loader, const char *filename);
00190
00191
00192 CFormDfn *getParent (uint parent) const;
00193
00194
00195 const std::string &getParentFilename (uint parent) const;
00196
00197
00198 uint getNumEntry () const;
00199
00200
00201 void setNumEntry (uint size);
00202
00203
00204 const CEntry &getEntry (uint entry) const;
00205
00206
00207 CEntry &getEntry (uint entry);
00208
00209
00210 bool getEntryType (uint entry, TEntryType &type, bool &array) const;
00211 bool getEntryName (uint entry, std::string &name) const;
00212 bool getEntryDfn (uint entry, UFormDfn **dfn);
00213 bool getEntryType (uint entry, UType **type);
00214 uint getNumParents () const;
00215 bool getParent (uint parent, UFormDfn **parentRet);
00216 const std::string &getComment (std::string &comment) const;
00217 bool getEntryFilename (uint entry, std::string& filename) const;
00218 bool getParentFilename (uint parent, std::string &filename) const;
00219
00220
00221 CFormDfn *getSubDfn (uint index, uint &dfnIndex);
00222 const CFormDfn *getSubDfn (uint index, uint &dfnIndex) const;
00223
00224
00225 CFileHeader Header;
00226
00227
00228 void warning (bool exception, const char *function, const char *format, ... ) const;
00229
00230 private:
00231
00232 std::vector<CParent> Parents;
00233
00234
00235 std::vector<CEntry> Entries;
00236
00237
00238 mutable uint32 Round;
00239
00240
00241 std::string _Filename;
00242
00243 private:
00244
00245 void read (xmlNodePtr doc, CFormLoader &loader, bool forceLoad, const char *filename);
00246 };
00247
00248 }
00249
00250 #endif // _NLGEORGES__FORM_DFN_H
00251