lib

list.h
1/***************************************************************************
2 * list.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_LIST_H
21#define KROSS_API_LIST_H
22
23#include <tqstring.h>
24#include <tqvaluelist.h>
25#include <tqintdict.h>
26
27#include "object.h"
28#include "value.h"
29
30#include "krossdebug.h"
31
32namespace Kross { namespace Api {
33
38 class KOFFICE_EXPORT List : public Value< List, TQValueList<Object::Ptr> >
39 {
40 friend class Value< List, TQValueList<Object::Ptr> >;
41 public:
42
46 typedef TDESharedPtr<List> Ptr;
47
48/*
49 operator TQStringList () {
50 //TQValueList<Object::Ptr> getValue()
51 krossdebug("999999999999 ...........................");
52 return TQStringList();
53 }
54*/
55
62 List(TQValueList<Object::Ptr> value = TQValueList<Object::Ptr>());
63
67 virtual ~List();
68
72 virtual const TQString getClassName() const;
73
79 virtual const TQString toString();
80
94 Object::Ptr item(uint idx, Object* defaultobject = 0);
95
102 uint count();
103
110 void append(Object::Ptr object);
111
112 template<typename TYPE>
113 static Object::Ptr toObject(TYPE t) { return t; }
114 };
115
120 template< class OBJECT >
121 class ListT : public List
122 {
123 public:
124 ListT() : List() {}
125 ListT(TQValueList<OBJECT> values) : List(values) {}
126
127 template< typename TYPE >
128 ListT(TQValueList<TYPE> values) : List()
129 {
130 TQValueListIterator<TYPE> it(values.begin()), end(values.end());
131 for(; it != end; ++it)
132 this->append( new OBJECT(*it) );
133 }
134
135 template< typename TYPE >
136 ListT(TQIntDict<TYPE> values) : List()
137 {
138 TQIntDictIterator<TYPE> it( values );
139 TYPE *t;
140 while( (t = it.current()) != 0 ) {
141 this->append( new OBJECT(t) );
142 ++it;
143 }
144 }
145
146 template< typename TYPE >
147 ListT(const TQPtrList<TYPE> values) : List()
148 {
149 TQPtrListIterator<TYPE> it(values);
150 TYPE *t;
151 while( (t = it.current()) != 0 ) {
152 this->append( new OBJECT(t) );
153 ++it;
154 }
155 }
156
157 virtual ~ListT() {}
158
159 template<typename TYPE>
160 static Object::Ptr toObject(TYPE t)
161 {
162 return new ListT(t);
163 }
164 };
165
166}}
167
168#endif
169
virtual const TQString getClassName() const
See.
Definition list.cpp:34
Object::Ptr item(uint idx, Object *defaultobject=0)
Return the Object with defined index from the TQValueList this list holds.
Definition list.cpp:48
List(TQValueList< Object::Ptr > value=TQValueList< Object::Ptr >())
Constructor.
Definition list.cpp:25
TDESharedPtr< List > Ptr
Shared pointer to implement reference-counting.
Definition list.h:46
uint count()
Return the number of items in the TQValueList this list holds.
Definition list.cpp:60
void append(Object::Ptr object)
Append an Kross::Api::Object to the list.
Definition list.cpp:65
virtual const TQString toString()
Definition list.cpp:39
The common Object class all other object-classes are inheritated from.
Definition object.h:50
TDESharedPtr< Object > Ptr
Shared pointer to implement reference-counting.
Definition object.h:56
Value(TQValueList< Object::Ptr > value)
Definition value.h:48
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