Main Page   Namespace List   Class Hierarchy   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_ZObject.h"        //included even though ZCF isn't derived (to obtain all other needed headers)
00029 
00030 namespace ZE
00031 {
00032 
00038 class ZConfigFile : public ZObject
00039 {
00040     private:
00041 
00042         //Private Types//
00043 
00044 
00051         class ZCF_Variable
00052         {
00053             public:
00055                 string var;
00057                 string val;
00058         };
00059 
00065         class ZCF_Section
00066         {
00067             public:
00069                 string section;
00071                 list<ZCF_Variable> varList;
00072         };
00073 
00075         list<ZCF_Section> mFileLayout;
00076 
00078         string mFilename;
00079 
00087         string CleanString(string str)  const;
00088         
00096         bool Exists(string sec) const;
00097 
00106         bool Exists(string sec, string var) const;
00107 
00116         void SetVariable(string sec, string var, string val);
00117 
00127         string GetVariable(string sec, string var, string defVal) const;
00128 
00129     public:
00130 
00136         ZConfigFile();
00137 
00144         ZConfigFile(string filename);
00145 
00151         ~ZConfigFile();
00152 
00159         void Process(string filename);
00160 
00170         int GetInt(string section, string var, int defVal) const;
00171 
00182         bool GetBool(string section, string var, bool defVal) const;
00183 
00193         string GetString(string section, string var, string defVal) const;
00194 
00204         void SetInt(string section, string var, int val);
00205 
00215         void SetBool(string section, string var, bool val);
00216 
00226         void SetString(string section, string var, string val);
00227         
00233         void Flush();
00234 
00240         void Close();
00241 };
00242 
00243 }
00244 
00245 #endif //__ze_zconfigfile_h__

Generated on Sun Jan 19 01:04:50 2003 for ZEngine by doxygen1.3-rc2