00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef KJS_IDENTIFIER_H
00023
#define KJS_IDENTIFIER_H
00024
00025
#include "ustring.h"
00026
00027
namespace KJS {
00028
00029
class Identifier {
00030
friend class PropertyMap;
00031
public:
00032 Identifier() { }
00033 Identifier(
const char *s) : _ustring(add(s)) { }
00034 Identifier(
const UChar *s,
int length) : _ustring(add(s, length)) { }
00035
explicit Identifier(
const UString &s) : _ustring(add(s.rep)) { }
00036
00037
const UString &ustring()
const {
return _ustring; }
00038 DOM::DOMString string() const;
00039
QString qstring() const;
00040
00041 const
UChar *data()
const {
return _ustring.data(); }
00042
int size()
const {
return _ustring.size(); }
00043
00044
const char *ascii()
const {
return _ustring.ascii(); }
00045
00046
static Identifier from(
unsigned y) {
return Identifier(UString::from(y)); }
00047
00048
bool isNull()
const {
return _ustring.isNull(); }
00049
bool isEmpty()
const {
return _ustring.isEmpty(); }
00050
00051
unsigned long toULong(
bool *ok)
const {
return _ustring.toULong(ok); }
00052
unsigned toStrictUInt32(
bool *ok)
const {
return _ustring.toStrictUInt32(ok); }
00053
unsigned toArrayIndex(
bool *ok)
const {
return _ustring.toArrayIndex(ok); }
00054
00055
double toDouble()
const {
return _ustring.toDouble(); }
00056
00057
static const Identifier &null();
00058
00059
friend bool operator==(
const Identifier &,
const Identifier &);
00060
friend bool operator!=(
const Identifier &,
const Identifier &);
00061
00062
friend bool operator==(
const Identifier &,
const char *);
00063
00064
static void remove(UString::Rep *);
00065
00066
private:
00067
UString _ustring;
00068
00069
static bool equal(UString::Rep *,
const char *);
00070
static bool equal(UString::Rep *,
const UChar *,
int length);
00071
static bool equal(UString::Rep *, UString::Rep *);
00072
00073
static bool equal(
const Identifier &a,
const Identifier &b)
00074 {
return a._ustring.rep == b._ustring.rep; }
00075
static bool equal(
const Identifier &a,
const char *b)
00076 {
return equal(a._ustring.rep, b); }
00077
00078
static UString::Rep *add(
const char *);
00079
static UString::Rep *add(
const UChar *,
int length);
00080
static UString::Rep *add(UString::Rep *);
00081
00082
static void insert(UString::Rep *);
00083
00084
static void rehash(
int newTableSize);
00085
static void expand();
00086
static void shrink();
00087
00088
00089
static UString::Rep **_table;
00090
static int _tableSize;
00091
static int _tableSizeMask;
00092
static int _keyCount;
00093 };
00094
00095
inline bool operator==(
const Identifier &a,
const Identifier &b)
00096 {
return Identifier::equal(a, b); }
00097
00098
inline bool operator!=(
const Identifier &a,
const Identifier &b)
00099 {
return !Identifier::equal(a, b); }
00100
00101
inline bool operator==(
const Identifier &a,
const char *b)
00102 {
return Identifier::equal(a, b); }
00103
00104
extern const Identifier argumentsPropertyName;
00105
extern const Identifier calleePropertyName;
00106
extern const Identifier constructorPropertyName;
00107
extern const Identifier lengthPropertyName;
00108
extern const Identifier messagePropertyName;
00109
extern const Identifier namePropertyName;
00110
extern const Identifier prototypePropertyName;
00111
extern const Identifier specialPrototypePropertyName;
00112
extern const Identifier toLocaleStringPropertyName;
00113
extern const Identifier toStringPropertyName;
00114
extern const Identifier valueOfPropertyName;
00115
00116 }
00117
00118
#endif