Doomseeker
   
  • Doomseeker
  • Wadseeker
  • Download
  • Tracker
  • Git
  • Docs
  • Main Page
  • Classes
  • Files
  • File List
  • File Members

src/core/ini/inivariable.h

00001 //------------------------------------------------------------------------------
00002 // inivariable.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 __INIVARIABLE_H__
00024 #define __INIVARIABLE_H__
00025 
00026 #include "global.h"
00027 
00028 #include <QHash>
00029 #include <QString>
00030 #include <QVariant>
00031 
00032 class IniSection;
00033 
00040 class MAIN_EXPORT IniVariable
00041 {
00042         public:
00047                 IniVariable();
00048 
00053                 IniVariable(IniSection* pSection, const QString& key);
00054 
00061                 IniVariable(const IniSection* pSection, const QString& key);
00062 
00067                 bool                    isNull() const { return pConstSection == NULL; }
00068 
00074                 QString                 valueString() const { return this->value().toString(); }
00075 
00076                 const IniVariable &operator=(const QString &str);
00077                 const IniVariable &operator=(const char* str) { return *this = QString(str); }
00078                 const IniVariable &operator=(int i);
00079                 const IniVariable &operator=(unsigned int i);
00080                 const IniVariable &operator=(short i);
00081                 const IniVariable &operator=(unsigned short i);
00082 
00089                 const IniVariable &operator=(bool b);
00090                 const IniVariable &operator=(float f);
00091                 const IniVariable &operator=(const IniVariable &other);
00092 
00096                 QString operator*() const { return value().toString(); }
00097 
00101                 operator QString () const { return value().toString(); }
00102 
00106                 operator float() const;
00110                 operator int() const;
00111                 operator unsigned int() const;
00112 
00113                 operator short() const;
00114                 operator unsigned short() const;
00115 
00120                 operator bool() const;
00121                 operator IniVariable&() { return *this; }
00122                 operator const IniVariable&() const { return *this; }
00123 
00127                 void                            setValue(const QVariant& value);
00128 
00132                 QVariant                        value() const;
00133 
00134         private:
00135                 friend class TestReadINIVariable;
00136                 friend class TestReadINIList;
00137 
00142                 IniSection*                     pSection;
00143 
00148                 const IniSection*       pConstSection;
00149 
00153                 QString                         key;
00154 
00155 
00156 };
00157 
00158 typedef QHash<QString, IniVariable>                                     IniVariables;   // the first QString is the name
00159 typedef QHash<QString, IniVariable>::iterator           IniVariablesIt;
00160 typedef QHash<QString, IniVariable>::const_iterator     IniVariablesConstIt;
00161 
00162 #endif
   
Doomseeker © 2009-2024 The Doomseeker Team