lib
list.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KROSS_API_LIST_H
00021 #define KROSS_API_LIST_H
00022
00023 #include <qstring.h>
00024 #include <qvaluelist.h>
00025 #include <qintdict.h>
00026
00027 #include "object.h"
00028 #include "value.h"
00029
00030 namespace Kross { namespace Api {
00031
00036 class List : public Value< List, QValueList<Object::Ptr> >
00037 {
00038 friend class Value< List, QValueList<Object::Ptr> >;
00039 public:
00040
00044 typedef KSharedPtr<List> Ptr;
00045
00053 List(QValueList<Object::Ptr> value = QValueList<Object::Ptr>(), const QString& name = "list");
00054
00058 virtual ~List();
00059
00063 virtual const QString getClassName() const;
00064
00070 virtual const QString toString();
00071
00080 Object::Ptr item(uint idx);
00081
00088 uint count();
00089
00096 void append(Object::Ptr object);
00097
00098 };
00099
00104 template< class OBJECT, class TYPE >
00105 class ListT : public List
00106 {
00107 public:
00108 ListT(QValueList<TYPE> values) : List(values) {}
00109
00110 ListT(QIntDict<TYPE> values) : List() {
00111 QIntDictIterator<TYPE> it( values );
00112 TYPE *t;
00113 while( (t = it.current()) != 0 ) {
00114 this->append( new OBJECT(t) );
00115 ++it;
00116 }
00117 }
00118
00119 ListT(const QPtrList<TYPE> values) : List() {
00120 QPtrListIterator<TYPE> it( values );
00121 TYPE *t;
00122 while( (t = it.current()) != 0 ) {
00123 this->append( new OBJECT(t) );
00124 ++it;
00125 }
00126 }
00127
00128 virtual ~ListT() {}
00129 };
00130
00131 }}
00132
00133 #endif
00134
|