# kjs Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# identifier.h

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (C) 2003 Apple Computer, Inc.
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License as published by the Free Software Foundation; either
    00008  *  version 2 of the License, or (at your option) any later version.
    00009  *
    00010  *  This library is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  *  Library General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU Library General Public License
    00016  *  along with this library; see the file COPYING.LIB.  If not, write to
    00017  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  *  Boston, MA 02111-1307, USA.
    00019  *
    00020  */
    00021
    00022 #ifndef KJS_IDENTIFIER_H
    00023 #define KJS_IDENTIFIER_H
    00024
    00025 #include "ustring.h"
    00026
    00027 namespace KJS {
    00028
    00032     class KJS_EXPORT Identifier {
    00033         friend class PropertyMap;
    00034     public:
    00038         Identifier() { }
    00045         Identifier(const char *s) : _ustring(add(s)) { }
    00046         Identifier(const UChar *s, int length) : _ustring(add(s, length)) { }
    00047         explicit Identifier(const UString &s) : _ustring(add(s.rep)) { }
    00048
    00052         const UString &ustring() const { return _ustring; }
    00053         DOM::DOMString string() const;
    00057     QString qstring() const;
    00058
    00062         const UChar *data() const { return _ustring.data(); }
    00066         int size() const { return _ustring.size(); }
    00067
    00071         const char *ascii() const { return _ustring.ascii(); }
    00072
    00073         static Identifier from(unsigned y) { return Identifier(UString::from(y)); }
    00074
    00078         bool isNull() const { return _ustring.isNull(); }
    00082         bool isEmpty() const { return _ustring.isEmpty(); }
    00083
    00084         unsigned long toULong(bool *ok) const { return _ustring.toULong(ok); }
    00085         unsigned toStrictUInt32(bool *ok) const { return _ustring.toStrictUInt32(ok); }
    00086         unsigned toArrayIndex(bool *ok) const { return _ustring.toArrayIndex(ok); }
    00087
    00088         double toDouble() const { return _ustring.toDouble(); }
    00089
    00093         static const Identifier &null();
    00094
    00095         friend bool operator==(const Identifier &, const Identifier &);
    00096         friend bool operator!=(const Identifier &, const Identifier &);
    00097
    00098         friend bool operator==(const Identifier &, const char *);
    00099
    00100         static void remove(UString::Rep *);
    00101
    00102     private:
    00103         UString _ustring;
    00104
    00105         static bool equal(UString::Rep *, const char *);
    00106         static bool equal(UString::Rep *, const UChar *, int length);
    00107         static bool equal(UString::Rep *, UString::Rep *);
    00108
    00109         static bool equal(const Identifier &a, const Identifier &b)
    00110             { return a._ustring.rep == b._ustring.rep; }
    00111         static bool equal(const Identifier &a, const char *b)
    00112             { return equal(a._ustring.rep, b); }
    00113
    00114         static UString::Rep *add(const char *);
    00115         static UString::Rep *add(const UChar *, int length);
    00116         static UString::Rep *add(UString::Rep *);
    00117
    00118         static void insert(UString::Rep *);
    00119
    00120         static void rehash(int newTableSize);
    00121         static void expand();
    00122         static void shrink();
    00123
    00124     // TODO: move into .cpp file
    00125         static UString::Rep **_table;
    00126         static int _tableSize;
    00127         static int _tableSizeMask;
    00128         static int _keyCount;
    00129     };
    00130
    00131     inline bool operator==(const Identifier &a, const Identifier &b)
    00132         { return Identifier::equal(a, b); }
    00133
    00134     inline bool operator!=(const Identifier &a, const Identifier &b)
    00135         { return !Identifier::equal(a, b); }
    00136
    00137     inline bool operator==(const Identifier &a, const char *b)
    00138         { return Identifier::equal(a, b); }
    00139
    00140     KJS_EXPORT extern const Identifier argumentsPropertyName;
    00141     KJS_EXPORT extern const Identifier calleePropertyName;
    00142     KJS_EXPORT extern const Identifier constructorPropertyName;
    00143     KJS_EXPORT extern const Identifier lengthPropertyName;
    00144     KJS_EXPORT extern const Identifier messagePropertyName;
    00145     KJS_EXPORT extern const Identifier namePropertyName;
    00146     KJS_EXPORT extern const Identifier prototypePropertyName;
    00147     KJS_EXPORT extern const Identifier specialPrototypePropertyName;
    00148     KJS_EXPORT extern const Identifier toLocaleStringPropertyName;
    00149     KJS_EXPORT extern const Identifier toStringPropertyName;
    00150     KJS_EXPORT extern const Identifier valueOfPropertyName;
    00151
    00152 }
    00153
    00154 #endif

This file is part of the documentation for kjs Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:23:06 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003