src/core/ini/inisection.h
00001 //------------------------------------------------------------------------------
00002 // inisection.h
00003 //------------------------------------------------------------------------------
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301  USA
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
00022 //------------------------------------------------------------------------------
00023 #ifndef __INISECTION_H__
00024 #define __INISECTION_H__
00025 
00026 #include <QVariant>
00027 #include <QVector>
00028 #include "global.h"
00029 
00030 class Ini;
00031 class IniVariable;
00032 
00038 class MAIN_EXPORT IniSection
00039 {
00040         public:
00045                 IniSection();
00046 
00059                 IniSection(Ini* pIni, const QString& sectionName);
00060 
00081                 IniVariable                             createSetting(const QString& name, const QVariant& data);
00082 
00090                 void                                    deleteSetting(const QString& name);
00091 
00096                 bool                                    isNull() const { return d.pIni == NULL; }
00097 
00107                 IniVariable                             retrieveSetting(const QString& name);
00108 
00112                 const IniVariable               retrieveSetting(const QString& name) const;
00113 
00117                 const QString&                  sectionName() const { return d.name; }
00118 
00128                 IniVariable                             setting(const QString& name);
00129 
00139                 void                                    setValue(const QString& key, const QVariant& value);
00140 
00144                 IniVariable                             operator[](const QString& name);
00145 
00149                 const IniVariable               operator[](const QString& name) const;
00150 
00157                 QVariant                                value(const QString& key) const;
00158 
00159         private:
00160                 class PrivData
00161                 {
00162                         public:
00166                                 QString                                 name;
00167 
00171                                 Ini*                    pIni;
00172                 };
00173 
00174                 PrivData d;
00175 
00179                 void remove(const QString& key);
00180 };
00181 
00182 typedef QHash<QString, IniSection>                                      IniSections;    
00183 typedef QHash<QString, IniSection>::iterator            IniSectionsIt;
00184 typedef QHash<QString, IniSection>::const_iterator      IniSectionsConstIt;
00185 
00186 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator