csutil/cfgmgr.h
00001 /* 00002 Copyright (C) 2001 by Martin Geisse <mgeisse@gmx.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_CFGMGR_H__ 00020 #define __CS_CFGMGR_H__ 00021 00022 #include "csextern.h" 00023 #include "iutil/cfgmgr.h" 00024 #include "refarr.h" 00025 #include "array.h" 00026 00032 class CS_CSUTIL_EXPORT csConfigManager : public iConfigManager 00033 { 00034 public: 00035 SCF_DECLARE_IBASE; 00036 00052 csConfigManager(iConfigFile *DynamicDomain, bool Optimize); 00054 virtual ~csConfigManager(); 00055 00060 virtual void AddDomain(iConfigFile*, int priority); 00070 virtual iConfigFile* AddDomain(char const* path, iVFS*, int priority); 00078 virtual void RemoveDomain(iConfigFile*); 00080 virtual void RemoveDomain(char const* path); 00085 virtual iConfigFile* LookupDomain(char const* path) const; 00087 virtual void SetDomainPriority(char const* path, int priority); 00092 virtual void SetDomainPriority(iConfigFile*, int priority); 00097 virtual int GetDomainPriority(char const* path) const; 00102 virtual int GetDomainPriority(iConfigFile*) const; 00103 00109 virtual bool SetDynamicDomain(iConfigFile*); 00115 virtual iConfigFile *GetDynamicDomain() const; 00117 virtual void SetDynamicDomainPriority(int priority); 00119 virtual int GetDynamicDomainPriority() const; 00120 00122 virtual void FlushRemoved(); 00123 00128 virtual const char* GetFileName () const; 00129 00134 virtual iVFS* GetVFS () const; 00135 00142 virtual void SetFileName (const char*, iVFS*); 00143 00160 virtual bool Load (const char* iFileName, iVFS* = 0, bool Merge = false, 00161 bool NewWins = true); 00162 00167 virtual bool Save (); 00168 00175 virtual bool Save (const char *iFileName, iVFS* = 0); 00176 00178 virtual void Clear (); 00179 00181 void CleanUp (); 00182 00189 virtual csPtr<iConfigIterator> Enumerate(const char *Subsection = 0); 00190 00192 virtual bool KeyExists(const char *Key) const; 00194 virtual bool SubsectionExists(const char *Subsection) const; 00195 00197 virtual int GetInt(const char *Key, int Def = 0) const; 00199 virtual float GetFloat(const char *Key, float Def = 0.0) const; 00201 virtual const char *GetStr(const char *Key, const char *Def = "") const; 00203 virtual bool GetBool(const char *Key, bool Def = false) const; 00205 virtual const char *GetComment(const char *Key) const; 00206 00208 virtual void SetStr (const char *Key, const char *Val); 00210 virtual void SetInt (const char *Key, int Value); 00212 virtual void SetFloat (const char *Key, float Value); 00214 virtual void SetBool (const char *Key, bool Value); 00221 virtual bool SetComment (const char *Key, const char *Text); 00223 virtual void DeleteKey(const char *Key); 00225 virtual const char *GetEOFComment() const; 00227 virtual void SetEOFComment(const char *Text); 00228 00229 private: 00230 friend class csConfigManagerIterator; 00232 bool Optimize; 00234 class csConfigDomain *DynamicDomain; 00236 class csConfigDomain *FirstDomain, *LastDomain; 00238 csRefArray<iConfigFile> Removed; 00240 csArray<iConfigIterator*> Iterators; 00241 00242 csConfigDomain *FindConfig(iConfigFile *cfg) const; 00243 csConfigDomain *FindConfig(const char *name) const; 00244 void ClearKeyAboveDynamic(const char *Key); 00245 void RemoveIterator(csConfigManagerIterator *it); 00246 void FlushRemoved(int n); 00247 int FindRemoved(const char *Filename) const; 00248 void RemoveDomain(class csConfigDomain *cfg); 00249 }; 00250 00251 #endif // __CS_CFGMGR_H__
Generated for Crystal Space by doxygen 1.2.18