Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

/include/ZE_ZConfigFile.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002         This file is Part of the ZEngine Library for 2D game development.
00003                    Copyright (C) 2002, 2003 James Turk
00004 
00005                      Licensed under a BSD-style license.
00006 
00007     The maintainer of this library is James Turk (james@conceptofzero.net) 
00008      and the home of this Library is http://www.zengine.sourceforge.net
00009 *******************************************************************************/
00010 
00025 #ifndef __ze_zconfigfile_h__
00026 #define __ze_zconfigfile_h__
00027 
00028 #include "ZE_ZEngine.h"
00029 
00030 namespace ZE
00031 {
00032 
00038 class ZConfigFile
00039 {
00040     private:
00041 
00042         //Private Types//
00043 
00050         class ZCF_Variable
00051         {
00052             public:
00054                 string var;
00056                 string val;
00057         };
00058 
00064         class ZCF_Section
00065         {
00066             public:
00068                 string section;
00070                 list<ZCF_Variable> varList;
00071         };
00072 
00073     protected:
00075         list<ZCF_Section> rFileLayout;
00077         string rFilename;
00078 
00086         string CleanString(string str)  const;
00087         
00095         bool Exists(string sec) const;
00096 
00105         bool Exists(string sec, string var) const;
00106 
00115         void SetVariable(string sec, string var, string val);
00116 
00126         string GetVariable(string sec, string var, string defVal) const;
00127 
00128     public:
00129 
00135         ZConfigFile();
00136 
00143         ZConfigFile(string filename);
00144 
00150         virtual ~ZConfigFile();
00151 
00158         void Process(string filename);
00159 
00170         float GetFloat(string section, string var, float defVal) const;
00171 
00181         int GetInt(string section, string var, int defVal) const;
00182 
00193         bool GetBool(string section, string var, bool defVal) const;
00194 
00204         string GetString(string section, string var, string defVal) const;
00205 
00216         void SetFloat(string section, string var, float val);
00217 
00227         void SetInt(string section, string var, int val);
00228 
00238         void SetBool(string section, string var, bool val);
00239 
00249         void SetString(string section, string var, string val);
00250         
00256         void Flush();
00257 
00263         void Close();
00264 };
00265 
00266 }
00267 
00268 #endif //__ze_zconfigfile_h__

Generated on Sun Apr 27 14:53:40 2003 for ZEngine by doxygen1.3-rc2