00001 /* 00002 * This file is part of the Standard Portable Library (SPL). 00003 * 00004 * SPL is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * SPL 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 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with SPL. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef _configurationsectoin_h 00018 #define _configurationsection_h 00019 00020 #include <spl/collection/Array.h> 00021 #include <spl/collection/List.h> 00022 #include <spl/String.h> 00023 #include <spl/collection/Hashtable.h> 00024 00030 class ConfigurationSection; 00031 typedef RefCountPtr<ConfigurationSection> ConfigurationSectionPtr; 00032 00033 class ConfigurationSection : public IMemoryValidate 00034 { 00035 protected: 00036 String m_name; 00037 Hashtable<String, List<StringPtr> > m_idx; 00038 00039 public: 00040 ConfigurationSection(); 00041 ConfigurationSection(const String& name); 00042 ConfigurationSection(const ConfigurationSection& cs); 00043 virtual ~ConfigurationSection(); 00044 00045 ConfigurationSection& operator =(const ConfigurationSection& cs); 00046 00047 inline String& Name() { return m_name; } 00048 00049 inline Hashtable<String, List<StringPtr> >::Iterator Begin() { return m_idx.Begin(); } 00050 00051 Array<String> Keys(); 00052 00053 inline bool ContainsKey(const String& key) { return m_idx.ContainsKey(key); } 00054 00055 StringPtr Value(const String& key); 00056 List<StringPtr>& Values(const String& key); 00057 00058 void Set(const String& key, const String& value); 00059 void Remove(const String& key); 00060 00061 StringPtr ToIniString(); 00062 StringPtr ToXmlString(); 00063 00064 #ifdef DEBUG 00065 void ValidateMem() const; 00066 void CheckMem() const; 00067 #endif 00068 }; 00069 00072 #endif