types.h
00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 00005 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this library; see the file COPYING.LIB. If not, write to 00019 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 * Boston, MA 02111-1307, USA. 00021 * 00022 * $Id: types.h,v 1.31.2.1 2003/05/17 11:19:25 mueller Exp $ 00023 */ 00024 00025 #ifndef _KJS_TYPES_H_ 00026 #define _KJS_TYPES_H_ 00027 00028 // internal data types 00029 00030 #include "value.h" 00031 00032 namespace KJS { 00033 00037 /* TODO: KDE 4.0: remove this one rename Reference2 in internal.h. */ 00038 class Reference : public Value { 00039 public: 00040 Reference(const Object& b, const UString& p); 00041 Reference(const Null& b, const UString& p); 00042 Reference(ReferenceImp *v); 00043 Reference(const Reference &v); 00044 Reference(const Value& v); 00045 virtual ~Reference(); 00046 00047 Reference& operator=(const Reference &v); 00048 static Reference dynamicCast(const Value &v); 00049 }; 00050 00051 class List; 00052 class ListIterator; 00053 class ListNode; 00054 00058 class ListIterator { 00059 friend class List; 00060 friend class ListImp; 00061 ListIterator(); 00062 ListIterator(ListNode *n); 00063 public: 00068 ListIterator(const List &l); 00072 ListIterator& operator=(const ListIterator &iterator); 00076 ListIterator(const ListIterator &i); 00077 ~ListIterator(); 00082 ValueImp* operator->() const; 00083 // operator Value* () const { return node->member; } 00084 Value operator*() const; 00089 // operator Value*() const { return node->member; } 00094 Value operator++(); 00098 Value operator++(int); 00102 Value operator--(); 00106 Value operator--(int); 00112 bool operator==(const ListIterator &it) const; 00117 bool operator!=(const ListIterator &it) const; 00118 private: 00119 ListNode *node; 00120 }; 00121 00132 class List : public Value { 00133 friend class ListIterator; 00134 public: 00135 List(); 00136 List(ListImp *v); 00137 List(const List &v); 00138 virtual ~List(); 00139 00140 List& operator=(const List &v); 00141 00151 static List dynamicCast(const Value &v); 00157 void append(const Value& val); 00163 void prepend(const Value& val); 00167 void appendList(const List& lst); 00172 void prependList(const List& lst); 00176 void removeFirst(); 00180 void removeLast(); 00181 /* 00182 * Remove val from list. 00183 */ 00184 void remove(const Value &val); 00188 void clear(); 00193 List copy() const; 00197 ListIterator begin() const; 00201 ListIterator end() const; 00205 bool isEmpty() const; 00209 int size() const; 00218 Value at(int i) const; 00222 Value operator[](int i) const; 00227 static const List empty(); 00228 #ifdef KJS_DEBUG_MEM 00229 static void globalClear(); 00230 #endif 00231 }; 00232 00236 enum ComplType { Normal, Break, Continue, ReturnValue, Throw }; 00237 00248 class Completion : public Value { 00249 public: 00250 Completion(ComplType c = Normal, const Value& v = Value(), 00251 const UString &t = UString::null); 00252 Completion(CompletionImp *v); 00253 Completion(const Completion &v); 00254 virtual ~Completion(); 00255 00256 Completion& operator=(const Completion &v); 00257 00267 static Completion dynamicCast(const Value &v); 00268 00269 ComplType complType() const; 00270 Value value() const; 00271 UString target() const; 00272 bool isValueCompletion() const; 00273 }; 00274 00275 } // namespace 00276 00277 #endif // _KJS_TYPES_H_