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 class FXAPI FXSettings : public FXDict {
00043 FXDECLARE(FXSettings)
00044 protected:
00045 FXbool modified;
00046 protected:
00047 virtual void *createData(const void*);
00048 virtual void deleteData(void*);
00049 FXbool parseValue(FXchar* value,const FXchar* buffer);
00050 FXbool unparseValue(FXchar* buffer,const FXchar* value);
00051 FXStringDict* insert(const FXchar* ky){ return (FXStringDict*)FXDict::insert(ky,NULL); }
00052 FXStringDict* replace(const FXchar* ky,FXStringDict* section){ return (FXStringDict*)FXDict::replace(ky,section,TRUE); }
00053 FXStringDict* remove(const FXchar* ky){ return (FXStringDict*)FXDict::remove(ky); }
00054 private:
00055 FXSettings(const FXSettings&);
00056 FXSettings &operator=(const FXSettings&);
00057 public:
00058
00059
00060 FXSettings();
00061
00062
00063 FXbool parseFile(const FXString& filename,FXbool mark);
00064
00065
00066 FXbool unparseFile(const FXString& filename);
00067
00068
00069 FXStringDict* data(FXuint pos) const { return (FXStringDict*)FXDict::data(pos); }
00070
00071
00072 FXStringDict* find(const FXchar *section) const { return (FXStringDict*)FXDict::find(section); }
00073
00074
00075 FXint readFormatEntry(const FXchar *section,const FXchar *key,const FXchar *fmt,...) FX_SCANF(4,5) ;
00076
00077
00078 const FXchar *readStringEntry(const FXchar *section,const FXchar *key,const FXchar *def=NULL);
00079
00080
00081 FXint readIntEntry(const FXchar *section,const FXchar *key,FXint def=0);
00082
00083
00084 FXuint readUnsignedEntry(const FXchar *section,const FXchar *key,FXuint def=0);
00085
00086
00087 FXdouble readRealEntry(const FXchar *section,const FXchar *key,FXdouble def=0.0);
00088
00089
00090 FXColor readColorEntry(const FXchar *section,const FXchar *key,FXColor def=0);
00091
00092
00093 FXint writeFormatEntry(const FXchar *section,const FXchar *key,const FXchar *fmt,...) FX_PRINTF(4,5) ;
00094
00095
00096 FXbool writeStringEntry(const FXchar *section,const FXchar *key,const FXchar *val);
00097
00098
00099 FXbool writeIntEntry(const FXchar *section,const FXchar *key,FXint val);
00100
00101
00102 FXbool writeUnsignedEntry(const FXchar *section,const FXchar *key,FXuint val);
00103
00104
00105 FXbool writeRealEntry(const FXchar *section,const FXchar *key,FXdouble val);
00106
00107
00108 FXbool writeColorEntry(const FXchar *section,const FXchar *key,FXColor val);
00109
00110
00111 FXbool deleteEntry(const FXchar *section,const FXchar *key);
00112
00113
00114 FXbool existingEntry(const FXchar *section,const FXchar *key);
00115
00116
00117 FXbool deleteSection(const FXchar *section);
00118
00119
00120 FXbool existingSection(const FXchar *section);
00121
00122
00123 FXbool clear();
00124
00125
00126 void setModified(FXbool mdfy=TRUE){ modified=mdfy; }
00127
00128
00129 FXbool isModified() const { return modified; }
00130
00131
00132 virtual ~FXSettings();
00133 };
00134
00135 }
00136
00137 #endif