wutil_config_store.h

00001 // wutil_config_store.h
00002 //
00003 // CConfigStore interface - allows configuration settings to be stored to disk in a text file
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022 //
00023 
00024 
00025 #ifndef _WUTIL_CONFIG_STORE_H_
00026 #define _WUTIL_CONFIG_STORE_H_
00027 
00028 #include <string>
00029 #include <map>
00030 
00031 
00032 namespace wUtil
00033 {
00034 
00036 
00038 
00039 class CConfigStore
00040 {
00041 public:
00043      CConfigStore(void) { }
00044 
00046      virtual ~CConfigStore(void) { }
00047 
00051      std::pair<bool, std::wstring> GetStringEntry(std::wstring sKey) const;
00052 
00056      std::pair<bool, long int> GetLongIntEntry(std::wstring sKey) const;
00057 
00061      std::pair<bool, double> GetDoubleEntry(std::wstring sKey) const;
00062 
00066      void SetStringEntry(std::wstring sKey, std::wstring sValue);
00067 
00071      void SetLongIntEntry(std::wstring sKey, long int lValue);
00072 
00076      void SetDoubleEntry(std::wstring sKey, double dValue);
00077 
00080      void RemoveEntry(std::wstring sKey);
00081 
00085      bool EntryExists(std::wstring sKey) const;
00086 
00089      void StoreToFile(std::wstring sFilename) const;
00090 
00095      bool ReadFromFile(std::wstring sFilename);
00096 
00098      void Clear(void);
00099 
00100 
00101 protected:
00102      typedef std::map<std::wstring, std::wstring> t_SettingsMap;  
00103      t_SettingsMap m_SettingsMap;  
00104 };
00105 
00106 };
00107 
00108 
00109 #include "unit_tests/wutil_config_store_unittests.h"
00110 
00111 #endif  // _WUTIL_CONFIG_STORE_H_
00112 

Generated on Wed May 16 23:11:26 2007 for wGui by  doxygen 1.5.1