00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXSETTINGS_H
00025 #define FXSETTINGS_H
00026
00027 #ifndef FXDICT_H
00028 #include "FXDict.h"
00029 #endif
00030
00031 namespace FX {
00032
00033
00034 class FXStringDict;
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class FXAPI FXSettings : public FXDict {
00045 FXDECLARE(FXSettings)
00046 protected:
00047 bool modified;
00048 protected:
00049 virtual void *createData(const void*);
00050 virtual void deleteData(void*);
00051 FXchar* dequote(FXchar* text) const;
00052 FXchar* enquote(FXchar* result,const FXchar* text);
00053 FXStringDict* insert(const FXchar* ky){ return (FXStringDict*)FXDict::insert(ky,NULL); }
00054 FXStringDict* replace(const FXchar* ky,FXStringDict* section){ return (FXStringDict*)FXDict::replace(ky,section,true); }
00055 FXStringDict* remove(const FXchar* ky){ return (FXStringDict*)FXDict::remove(ky); }
00056 public:
00057
00058
00059 FXSettings();
00060
00061
00062 FXSettings(const FXSettings& orig);
00063
00064
00065 FXSettings &operator=(const FXSettings& orig);
00066
00067
00068 bool parseFile(const FXString& filename,bool mark);
00069
00070
00071 bool unparseFile(const FXString& filename);
00072
00073
00074 FXStringDict* data(FXuint pos) const { return (FXStringDict*)FXDict::data(pos); }
00075
00076
00077 FXStringDict* find(const FXchar *section) const { return (FXStringDict*)FXDict::find(section); }
00078
00079
00080 FXint readFormatEntry(const FXchar *section,const FXchar *key,const FXchar *fmt,...) FX_SCANF(4,5) ;
00081
00082
00083 const FXchar *readStringEntry(const FXchar *section,const FXchar *key,const FXchar *def=NULL);
00084
00085
00086 FXint readIntEntry(const FXchar *section,const FXchar *key,FXint def=0);
00087
00088
00089 FXuint readUnsignedEntry(const FXchar *section,const FXchar *key,FXuint def=0);
00090
00091
00092 FXdouble readRealEntry(const FXchar *section,const FXchar *key,FXdouble def=0.0);
00093
00094
00095 FXColor readColorEntry(const FXchar *section,const FXchar *key,FXColor def=0);
00096
00097
00098 FXbool readBoolEntry(const FXchar *section,const FXchar *key,FXbool def=FALSE);
00099
00100
00101 FXint writeFormatEntry(const FXchar *section,const FXchar *key,const FXchar *fmt,...) FX_PRINTF(4,5) ;
00102
00103
00104 bool writeStringEntry(const FXchar *section,const FXchar *key,const FXchar *val);
00105
00106
00107 bool writeIntEntry(const FXchar *section,const FXchar *key,FXint val);
00108
00109
00110 bool writeUnsignedEntry(const FXchar *section,const FXchar *key,FXuint val);
00111
00112
00113 bool writeRealEntry(const FXchar *section,const FXchar *key,FXdouble val);
00114
00115
00116 bool writeColorEntry(const FXchar *section,const FXchar *key,FXColor val);
00117
00118
00119 bool writeBoolEntry(const FXchar *section,const FXchar *key,FXbool val);
00120
00121
00122 bool deleteEntry(const FXchar *section,const FXchar *key);
00123
00124
00125 bool existingEntry(const FXchar *section,const FXchar *key);
00126
00127
00128 bool deleteSection(const FXchar *section);
00129
00130
00131 bool existingSection(const FXchar *section);
00132
00133
00134 bool clear();
00135
00136
00137 void setModified(bool mdfy=true){ modified=mdfy; }
00138
00139
00140 bool isModified() const { return modified; }
00141
00142
00143 virtual ~FXSettings();
00144 };
00145
00146 }
00147
00148 #endif