lib

variant.h
1/***************************************************************************
2 * variant.h
3 * This file is part of the KDE project
4 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
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 GNU
13 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 ***************************************************************************/
19
20#ifndef KROSS_API_VARIANT_H
21#define KROSS_API_VARIANT_H
22
23#include <tqstring.h>
24#include <tqvariant.h>
25
26#include "object.h"
27#include "value.h"
28#include "exception.h"
29
30namespace Kross { namespace Api {
31
32 class List;
33
38 class KOFFICE_EXPORT Variant : public Value<Variant, TQVariant>
39 {
40 friend class Value<Variant, TQVariant>;
41 public:
42
50 Variant(const TQVariant& value);
51
52 inline operator bool () { return getValue().toBool(); }
53 inline operator int () { return getValue().toInt(); }
54 inline operator uint () { return getValue().toUInt(); }
55 inline operator double () { return getValue().toDouble(); }
56 inline operator const char* () { return getValue().toString().latin1(); }
57
58 inline operator TQString () { return getValue().toString(); }
59 inline operator const TQString () { return getValue().toString(); }
60 inline operator const TQString& () { return getValue().asString(); }
61
62 inline operator TQCString () { return getValue().toCString(); }
63 inline operator const TQCString () { return getValue().toCString(); }
64 inline operator const TQCString& () { return getValue().asCString(); }
65
66 inline operator TQVariant () { return getValue(); }
67 inline operator const TQVariant () { return getValue(); }
68 inline operator const TQVariant& () { return getValue(); }
69
80 inline operator TQStringList () {
81 return toStringList(this);
82 }
83 inline operator TQValueList<TQVariant> () {
84 return toList(this);
85 }
86
90 virtual ~Variant();
91
93 virtual const TQString getClassName() const;
94
100 virtual const TQString toString();
101
110 static const TQVariant& toVariant(Object::Ptr object);
111
120 static const TQString toString(Object::Ptr object);
121
130 static int toInt(Object::Ptr object);
131
140 static uint toUInt(Object::Ptr object);
141
150 static double toDouble(Object::Ptr object);
151
160 static TQ_LLONG toLLONG(Object::Ptr object);
161
170 static TQ_ULLONG toULLONG(Object::Ptr object);
171
180 static bool toBool(Object::Ptr object);
181
190 static TQStringList toStringList(Object::Ptr object);
191
200 static TQValueList<TQVariant> toList(Object::Ptr object);
201
202 };
203
204}}
205
206#endif
207
The List class implementates Value to handle lists and collections.
Definition list.h:39
static TQStringList toStringList(Object::Ptr object)
Try to convert the given Object into a TQStringList.
Definition variant.cpp:136
Variant(const TQVariant &value)
Constructor.
Definition variant.cpp:27
The common Kross API used as common codebase.
Definition callable.h:33
The Kross scripting bridge to embed scripting functionality into an application.
Definition callable.h:33