WorldFile.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef WORLDFILE_HH
00029 #define WORLDFILE_HH
00030
00031 #include <libxml/parser.h>
00032
00033 #include "Vector.hh"
00034 #include "Color.hh"
00035
00036
00037 class WorldFileNode;
00038
00039
00041 class WorldFile
00042 {
00044 public: WorldFile();
00045
00047 public: ~WorldFile();
00048
00050 public: int Load( const char *filename );
00051
00053 public: int LoadString( const char *str );
00054
00057 public: int Save( const char *filename );
00058
00061 public: bool WarnUnused();
00062
00064 public: WorldFileNode *GetRootNode() const;
00065
00066
00067 private: WorldFileNode *CreateNodes( WorldFileNode *parent,
00068 xmlNodePtr xmlNode );
00069
00071 public: char *filename;
00072
00073
00074 private: xmlDocPtr xmlDoc;
00075
00076
00077 private: WorldFileNode *root;
00078 };
00079
00080
00082 class WorldFileNode
00083 {
00085 public: WorldFileNode( WorldFile *file, WorldFileNode *parent,
00086 xmlNodePtr xmlNode, xmlDocPtr xmlDoc );
00087
00089 public: ~WorldFileNode();
00090
00092 public: const char *GetName();
00093
00095 public: const char *GetNSPrefix();
00096
00098 public: WorldFileNode *GetNext();
00099
00101 public: WorldFileNode *GetChild();
00102
00105 public: WorldFileNode *GetChild( const char *name );
00106
00108 public: WorldFileNode *GetChildByNSPrefix( const char *prefix);
00109
00111 private: char* GetNodeValue( const char *key );
00112
00114 private: void SetNodeValue( const char *key, const char* value );
00115
00117 public: void Print();
00118
00120 public: bool WarnUnused();
00121
00123 public: bool IsDefined( const char *key ) {return GetNodeValue(key) != NULL;}
00124
00126 public: const char *GetString( const char *key, const char *def, int require = 0 );
00127
00129 public: void SetString( const char *key, const char *v);
00130
00136 public: const char *GetFilename( const char *key, const char *def,
00137 int require = 0);
00138
00146 public: const char *SearchFilename( const char *key, const char *path, const char *def,
00147 int require = 0);
00148
00150 public: int GetInt( const char *key, int def, int require = 0 );
00151
00153 public: double GetDouble( const char *key, double def, int require = 0 );
00154
00156 public: bool GetBool( const char *key, bool def, int require = 0 );
00157
00159 public: double GetLength( const char *key, double def, int require = 0 );
00160
00162 public: double GetAngle( const char *key, double def, int require = 0 );
00163
00165 public: double GetTime( const char *key, double def, int require = 0 );
00166
00168 public: GzVector GetPosition( const char *key, GzVector def );
00169
00171 public: void SetPosition( const char *key, GzVector v );
00172
00174 public: GzQuatern GetRotation( const char *key, GzQuatern def );
00175
00177 public: void SetRotation( const char *key, GzQuatern v );
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00191 public: GzColor GetColor( const char *key, GzColor def );
00192
00194 public: const char *GetTupleString( const char *key, int index,
00195 const char *def );
00196
00198 public: double GetTupleDouble( const char *key, int index, double def );
00199
00201 public: int GetTupleInt( const char *key, int index, int def );
00202
00204 public: double GetTupleLength( const char *key, int index, double def );
00205
00207 public: double GetTupleAngle( const char *key, int index, double def );
00208
00209
00210 private: WorldFile *file;
00211
00212
00213 private: WorldFileNode *parent;
00214
00215
00216 private: WorldFileNode *next, *prev;
00217
00218
00219 private: WorldFileNode *child_first, *child_last;
00220
00221
00222 private: xmlNodePtr xmlNode;
00223
00224
00225 private: xmlDocPtr xmlDoc;
00226
00227
00228 private: bool used;
00229
00230
00231 friend class WorldFile;
00232 };
00233
00234 #endif
00235
Last updated 12 September 2005 21:38:45
|