string_object.h
00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 */ 00021 00022 #ifndef _STRING_OBJECT_H_ 00023 #define _STRING_OBJECT_H_ 00024 00025 #include "internal.h" 00026 #include "function_object.h" 00027 00028 namespace KJS { 00029 00030 class StringInstanceImp : public ObjectImp { 00031 public: 00032 StringInstanceImp(ObjectImp *proto); 00033 StringInstanceImp(ObjectImp *proto, const UString &string); 00034 00035 virtual Value get(ExecState *exec, const Identifier &propertyName) const; 00036 virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None); 00037 virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const; 00038 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); 00039 virtual ReferenceList propList(ExecState *exec, bool recursive); 00040 00041 virtual const ClassInfo *classInfo() const { return &info; } 00042 static const ClassInfo info; 00043 }; 00044 00051 class StringPrototypeImp : public StringInstanceImp { 00052 public: 00053 StringPrototypeImp(ExecState *exec, 00054 ObjectPrototypeImp *objProto); 00055 Value get(ExecState *exec, const Identifier &p) const; 00056 virtual const ClassInfo *classInfo() const { return &info; } 00057 static const ClassInfo info; 00058 }; 00059 00066 class StringProtoFuncImp : public InternalFunctionImp { 00067 public: 00068 StringProtoFuncImp(ExecState *exec, int i, int len); 00069 00070 virtual bool implementsCall() const; 00071 virtual Value call(ExecState *exec, Object &thisObj, const List &args); 00072 00073 enum { ToString, ValueOf, CharAt, CharCodeAt, Concat, IndexOf, LastIndexOf, 00074 Match, Replace, Search, Slice, Split, 00075 Substr, Substring, FromCharCode, ToLowerCase, ToUpperCase, 00076 ToLocaleLowerCase, ToLocaleUpperCase, LocaleCompare 00077 #ifndef KJS_PURE_ECMA 00078 , Big, Small, Blink, Bold, Fixed, Italics, Strike, Sub, Sup, 00079 Fontcolor, Fontsize, Anchor, Link 00080 #endif 00081 }; 00082 private: 00083 int id; 00084 }; 00085 00091 class StringObjectImp : public InternalFunctionImp { 00092 public: 00093 StringObjectImp(ExecState *exec, 00094 FunctionPrototypeImp *funcProto, 00095 StringPrototypeImp *stringProto); 00096 00097 virtual bool implementsConstruct() const; 00098 virtual Object construct(ExecState *exec, const List &args); 00099 virtual bool implementsCall() const; 00100 virtual Value call(ExecState *exec, Object &thisObj, const List &args); 00101 }; 00102 00109 class StringObjectFuncImp : public InternalFunctionImp { 00110 public: 00111 StringObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto); 00112 virtual bool implementsCall() const; 00113 virtual Value call(ExecState *exec, Object &thisObj, const List &args); 00114 }; 00115 00116 } // namespace 00117 00118 #endif 00119