libktorrent  2.2.0
value.h
1 /***************************************************************************
2  * Copyright (C) 2005 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program 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 *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BTVALUE_H
21 #define BTVALUE_H
22 
23 #include <qstring.h>
24 #include <util/constants.h>
25 #include <ktorrent_export.h>
26 
27 namespace bt
28 {
29 
33  class KTORRENT_EXPORT Value
34  {
35  public:
36  enum Type
37  {
38  STRING,INT,INT64
39  };
40 
41 
42  Value();
43  Value(int val);
44  Value(Int64 val);
45  Value(const QByteArray & val);
46  Value(const Value & val);
47  ~Value();
48 
49  Value & operator = (const Value & val);
50  Value & operator = (Int32 val);
51  Value & operator = (Int64 val);
52  Value & operator = (const QByteArray & val);
53 
54  Type getType() const {return type;}
55  Int32 toInt() const {return ival;}
56  Int64 toInt64() const {return big_ival;}
57  QString toString() const {return QString::fromUtf8(strval);}
58  QString toString(QTextCodec* tc) const;
59  QByteArray toByteArray() const {return strval;}
60  private:
61  Type type;
62  Int32 ival;
63  QByteArray strval;
64  Int64 big_ival;
65  };
66 }
67 
68 #endif
bt::Value
Definition: value.h:34