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 
00021 #ifndef __ze_zconfigfile_h__
00022 #define __ze_zconfigfile_h__
00023 
00024 #include "ZE_ZEngine.h"
00025 
00026 namespace ZE
00027 {
00028 
00034 class ZConfigFile
00035 {
00036     private:
00037 
00038         //Private Types//
00039 
00046         class ZCF_Variable
00047         {
00048             public:
00050                 std::string var;
00052                 std::string val;
00053         };
00054 
00060         class ZCF_Section
00061         {
00062             public:
00064                 std::string section;
00066                 std::list<ZCF_Variable> varList;
00067         };
00068 
00069     protected:
00071         std::list<ZCF_Section> rFileLayout;
00073         std::string rFilename;
00074 
00082         std::string CleanString(std::string str)  const;
00083         
00091         bool Exists(std::string sec) const;
00092 
00101         bool Exists(std::string sec, std::string var) const;
00102 
00111         void SetVariable(std::string sec, std::string var, std::string val);
00112 
00122         std::string GetVariable(std::string sec, std::string var, std::string defVal) const;
00123 
00124     public:
00125 
00131         ZConfigFile();
00132 
00139         ZConfigFile(std::string filename);
00140 
00146         virtual ~ZConfigFile();
00147 
00154         void Process(std::string filename);
00155 
00166         float GetFloat(std::string section, std::string var, float defVal) const;
00167 
00177         int GetInt(std::string section, std::string var, int defVal) const;
00178 
00189         bool GetBool(std::string section, std::string var, bool defVal) const;
00190 
00200         std::string GetString(std::string section, std::string var, std::string defVal) const;
00201 
00212         void SetFloat(std::string section, std::string var, float val);
00213 
00223         void SetInt(std::string section, std::string var, int val);
00224 
00234         void SetBool(std::string section, std::string var, bool val);
00235 
00245         void SetString(std::string section, std::string var, std::string val);
00246         
00252         void Flush();
00253 
00259         void Close();
00260 };
00261 
00262 }
00263 
00264 #endif //__ze_zconfigfile_h__

Generated on Sun Jun 29 14:13:50 2003 for ZEngine by doxygen1.3