inivariable.h
1 //------------------------------------------------------------------------------
2 // inivariable.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __INIVARIABLE_H__
24 #define __INIVARIABLE_H__
25 
26 #include "dptr.h"
27 #include "global.h"
28 
29 #include <QHash>
30 #include <QString>
31 #include <QVariant>
32 
33 class IniSection;
34 
41 class MAIN_EXPORT IniVariable
42 {
43  public:
50  IniVariable();
51 
55  IniVariable(const IniSection &section, const QString& key);
56 
57  virtual ~IniVariable();
58 
62  const QString& key();
63 
68  bool isNull() const;
69 
75  QString valueString() const { return this->value().toString(); }
76 
77  const IniVariable &operator=(const QString &str);
78  const IniVariable &operator=(const char* str) { return *this = QString(str); }
79  const IniVariable &operator=(int i);
80  const IniVariable &operator=(unsigned int i);
81  const IniVariable &operator=(short i);
82  const IniVariable &operator=(unsigned short i);
83 
90  const IniVariable &operator=(bool b);
91  const IniVariable &operator=(float f);
92 
96  QString operator*() const { return value().toString(); }
97 
101  operator QString () const { return value().toString(); }
102 
106  operator float() const;
110  operator int() const;
111  operator unsigned int() const;
112 
113  operator short() const;
114  operator unsigned short() const;
115 
120  operator bool() const;
121 
125  void setValue(const QVariant& value);
126 
130  QVariant value() const;
131 
132  private:
133  friend class TestReadINIVariable;
134  friend class TestReadINIList;
135 
137 };
138 
139 #endif
QString valueString() const
Returns the underlying value as a QString.
Definition: inivariable.h:75
INI variable representation.
Definition: inivariable.h:41
QString operator*() const
Attempts to convert the value to QString.
Definition: inivariable.h:96
INI section representation.
Definition: inisection.h:40