Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

/home/jeroen/FOX/fox/fox-1.7.33/include/FXSettings.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                           S e t t i n g s   C l a s s                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXSETTINGS_H
00022 #define FXSETTINGS_H
00023 
00024 #ifndef FXDICT_H
00025 #include "FXDict.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 class FXStringDict;
00032 
00033 
00041 class FXAPI FXSettings : public FXDict {
00042   FXDECLARE(FXSettings)
00043 protected:
00044   FXbool modified;
00045 protected:
00046   virtual void *createData(void*);
00047   virtual void deleteData(void*);
00048 protected:
00049   FXStringDict* insert(const FXchar* ky){ return (FXStringDict*)FXDict::insert(ky,NULL); }
00050   FXStringDict* replace(const FXchar* ky,FXStringDict* section){ return (FXStringDict*)FXDict::replace(ky,section,true); }
00051   FXStringDict* remove(const FXchar* ky){ return (FXStringDict*)FXDict::remove(ky); }
00052 private:
00053   FXSettings(const FXSettings&);
00054   FXSettings &operator=(const FXSettings&);
00055 public:
00056 
00058   FXSettings();
00059 
00061   FXbool isModified() const { return modified; }
00062 
00064   void setModified(FXbool mdfy=true){ modified=mdfy; }
00065 
00067   FXbool parseFile(const FXString& filename,FXbool mrk=true);
00068 
00070   FXbool unparseFile(const FXString& filename);
00071 
00073   FXbool parse(const FXString& string,FXbool mrk=true);
00074 
00076   FXbool unparse(FXString& string) const;
00077 
00079   FXStringDict* find(const FXchar *section) const { return (FXStringDict*)FXDict::find(section); }
00080   FXStringDict* find(const FXString& section) const { return (FXStringDict*)FXDict::find(section.text()); }
00081 
00083   FXStringDict* data(FXint pos) const { return (FXStringDict*)FXDict::data(pos); }
00084 
00086   FXint readFormatEntry(const FXchar *section,const FXchar *name,const FXchar *fmt,...) const FX_SCANF(4,5) ;
00087   FXint readFormatEntry(const FXString& section,const FXchar *name,const FXchar *fmt,...) const FX_SCANF(4,5) ;
00088   FXint readFormatEntry(const FXString& section,const FXString& name,const FXchar *fmt,...) const FX_SCANF(4,5) ;
00089 
00091   FXint writeFormatEntry(const FXchar *section,const FXchar *name,const FXchar *fmt,...) FX_PRINTF(4,5) ;
00092   FXint writeFormatEntry(const FXString& section,const FXchar *name,const FXchar *fmt,...) FX_PRINTF(4,5) ;
00093   FXint writeFormatEntry(const FXString& section,const FXString& name,const FXchar *fmt,...) FX_PRINTF(4,5) ;
00094 
00096   const FXchar *readStringEntry(const FXchar *section,const FXchar *name,const FXchar *def=NULL) const;
00097   const FXchar *readStringEntry(const FXString& section,const FXchar *name,const FXchar *def=NULL) const;
00098   const FXchar *readStringEntry(const FXString& section,const FXString& name,const FXchar *def=NULL) const;
00099 
00101   FXbool writeStringEntry(const FXchar *section,const FXchar *name,const FXchar *val);
00102   FXbool writeStringEntry(const FXString& section,const FXchar *name,const FXchar *val);
00103   FXbool writeStringEntry(const FXString& section,const FXString& name,const FXchar *val);
00104 
00106   FXint readIntEntry(const FXchar *section,const FXchar *name,FXint def=0) const;
00107   FXint readIntEntry(const FXString& section,const FXchar *name,FXint def=0) const;
00108   FXint readIntEntry(const FXString& section,const FXString& name,FXint def=0) const;
00109 
00111   FXbool writeIntEntry(const FXchar *section,const FXchar *name,FXint val);
00112   FXbool writeIntEntry(const FXString& section,const FXchar *name,FXint val);
00113   FXbool writeIntEntry(const FXString& section,const FXString& name,FXint val);
00114 
00116   FXuint readUIntEntry(const FXchar *section,const FXchar *name,FXuint def=0) const;
00117   FXuint readUIntEntry(const FXString& section,const FXchar *name,FXuint def=0) const;
00118   FXuint readUIntEntry(const FXString& section,const FXString& name,FXuint def=0) const;
00119 
00121   FXbool writeUIntEntry(const FXchar *section,const FXchar *name,FXuint val);
00122   FXbool writeUIntEntry(const FXString& section,const FXchar *name,FXuint val);
00123   FXbool writeUIntEntry(const FXString& section,const FXString& name,FXuint val);
00124 
00126   FXlong readLongEntry(const FXchar *section,const FXchar *name,FXlong def=0) const;
00127   FXlong readLongEntry(const FXString& section,const FXchar *name,FXlong def=0) const;
00128   FXlong readLongEntry(const FXString& section,const FXString& name,FXlong def=0) const;
00129 
00131   FXbool writeLongEntry(const FXchar *section,const FXchar *name,FXlong val);
00132   FXbool writeLongEntry(const FXString& section,const FXchar *name,FXlong val);
00133   FXbool writeLongEntry(const FXString& section,const FXString& name,FXlong val);
00134 
00136   FXulong readULongEntry(const FXchar *section,const FXchar *name,FXulong def=0) const;
00137   FXulong readULongEntry(const FXString& section,const FXchar *name,FXulong def=0) const;
00138   FXulong readULongEntry(const FXString& section,const FXString& name,FXulong def=0) const;
00139 
00141   FXbool writeULongEntry(const FXchar *section,const FXchar *name,FXulong val);
00142   FXbool writeULongEntry(const FXString& section,const FXchar *name,FXulong val);
00143   FXbool writeULongEntry(const FXString& section,const FXString& name,FXulong val);
00144 
00146   FXdouble readRealEntry(const FXchar *section,const FXchar *name,FXdouble def=0.0) const;
00147   FXdouble readRealEntry(const FXString& section,const FXchar *name,FXdouble def=0.0) const;
00148   FXdouble readRealEntry(const FXString& section,const FXString& name,FXdouble def=0.0) const;
00149 
00151   FXbool writeRealEntry(const FXchar *section,const FXchar *name,FXdouble val);
00152   FXbool writeRealEntry(const FXString& section,const FXchar *name,FXdouble val);
00153   FXbool writeRealEntry(const FXString& section,const FXString& name,FXdouble val);
00154 
00156   FXColor readColorEntry(const FXchar *section,const FXchar *name,FXColor def=0) const;
00157   FXColor readColorEntry(const FXString& section,const FXchar *name,FXColor def=0) const;
00158   FXColor readColorEntry(const FXString& section,const FXString& name,FXColor def=0) const;
00159 
00161   FXbool writeColorEntry(const FXchar *section,const FXchar *name,FXColor val);
00162   FXbool writeColorEntry(const FXString& section,const FXchar *name,FXColor val);
00163   FXbool writeColorEntry(const FXString& section,const FXString& name,FXColor val);
00164 
00166   FXbool readBoolEntry(const FXchar *section,const FXchar *name,FXbool def=false) const;
00167   FXbool readBoolEntry(const FXString& section,const FXchar *name,FXbool def=false) const;
00168   FXbool readBoolEntry(const FXString& section,const FXString& name,FXbool def=false) const;
00169 
00171   FXbool writeBoolEntry(const FXchar *section,const FXchar *name,FXbool val);
00172   FXbool writeBoolEntry(const FXString& section,const FXchar *name,FXbool val);
00173   FXbool writeBoolEntry(const FXString& section,const FXString& name,FXbool val);
00174 
00176   FXbool existingEntry(const FXchar *section,const FXchar *name) const;
00177   FXbool existingEntry(const FXString& section,const FXchar *name) const;
00178   FXbool existingEntry(const FXString& section,const FXString& name) const;
00179 
00181   FXbool deleteEntry(const FXchar *section,const FXchar *name);
00182   FXbool deleteEntry(const FXString& section,const FXchar *name);
00183   FXbool deleteEntry(const FXString& section,const FXString& name);
00184 
00186   FXbool existingSection(const FXchar *section) const;
00187   FXbool existingSection(const FXString& section) const;
00188 
00190   FXbool deleteSection(const FXchar *section);
00191   FXbool deleteSection(const FXString& section);
00192 
00194   FXbool clear();
00195 
00197   virtual ~FXSettings();
00198   };
00199 
00200 }
00201 
00202 #endif

Copyright © 1997-2011 Jeroen van der Zijp