• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • kjs
identifier.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2003 Apple Computer, Inc
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 #ifndef KJS_IDENTIFIER_H
23 #define KJS_IDENTIFIER_H
24 
25 #include "ustring.h"
26 
27 namespace KJS {
28 
32  class KJS_EXPORT Identifier {
33  friend class PropertyMap;
34  public:
38  Identifier() { }
45  Identifier(const char *s) : _ustring(add(s)) { }
46  Identifier(const UChar *s, int length) : _ustring(add(s, length)) { }
47  explicit Identifier(const UString &s) : _ustring(add(s.rep)) { }
48 
52  const UString &ustring() const { return _ustring; }
53  DOM::DOMString string() const;
57  TQString qstring() const;
58 
62  const UChar *data() const { return _ustring.data(); }
66  int size() const { return _ustring.size(); }
67 
71  const char *ascii() const { return _ustring.ascii(); }
72 
73  static Identifier from(unsigned y) { return Identifier(UString::from(y)); }
74 
78  bool isNull() const { return _ustring.isNull(); }
82  bool isEmpty() const { return _ustring.isEmpty(); }
83 
84  unsigned long toULong(bool *ok) const { return _ustring.toULong(ok); }
85  unsigned toStrictUInt32(bool *ok) const { return _ustring.toStrictUInt32(ok); }
86  unsigned toArrayIndex(bool *ok) const { return _ustring.toArrayIndex(ok); }
87 
88  double toDouble() const { return _ustring.toDouble(); }
89 
93  static const Identifier &null();
94 
95  friend bool operator==(const Identifier &, const Identifier &);
96  friend bool operator!=(const Identifier &, const Identifier &);
97 
98  friend bool operator==(const Identifier &, const char *);
99 
100  static void remove(UString::Rep *);
101 
102  private:
103  UString _ustring;
104 
105  static bool equal(UString::Rep *, const char *);
106  static bool equal(UString::Rep *, const UChar *, int length);
107  static bool equal(UString::Rep *, UString::Rep *);
108 
109  static bool equal(const Identifier &a, const Identifier &b)
110  { return a._ustring.rep == b._ustring.rep; }
111  static bool equal(const Identifier &a, const char *b)
112  { return equal(a._ustring.rep, b); }
113 
114  static UString::Rep *add(const char *);
115  static UString::Rep *add(const UChar *, int length);
116  static UString::Rep *add(UString::Rep *);
117 
118  static void insert(UString::Rep *);
119 
120  static void rehash(int newTableSize);
121  static void expand();
122  static void shrink();
123 
124  // TODO: move into .cpp file
125  static UString::Rep **_table;
126  static int _tableSize;
127  static int _tableSizeMask;
128  static int _keyCount;
129  };
130 
131  inline bool operator==(const Identifier &a, const Identifier &b)
132  { return Identifier::equal(a, b); }
133 
134  inline bool operator!=(const Identifier &a, const Identifier &b)
135  { return !Identifier::equal(a, b); }
136 
137  inline bool operator==(const Identifier &a, const char *b)
138  { return Identifier::equal(a, b); }
139 
140  KJS_EXPORT extern const Identifier argumentsPropertyName;
141  KJS_EXPORT extern const Identifier calleePropertyName;
142  KJS_EXPORT extern const Identifier callerPropertyName;
143  KJS_EXPORT extern const Identifier constructorPropertyName;
144  KJS_EXPORT extern const Identifier lengthPropertyName;
145  KJS_EXPORT extern const Identifier messagePropertyName;
146  KJS_EXPORT extern const Identifier namePropertyName;
147  KJS_EXPORT extern const Identifier prototypePropertyName;
148  KJS_EXPORT extern const Identifier specialPrototypePropertyName;
149  KJS_EXPORT extern const Identifier toLocaleStringPropertyName;
150  KJS_EXPORT extern const Identifier toStringPropertyName;
151  KJS_EXPORT extern const Identifier valueOfPropertyName;
152 
153 }
154 
155 #endif
KJS::UString::from
static UString from(int i)
Constructs a string from an int.
Definition: ustring.cpp:340
KJS::Identifier::isNull
bool isNull() const
Returns the identfiers state of being unset.
Definition: identifier.h:78
KJS::Identifier::data
const UChar * data() const
returns a UChar pointer to the string of the identifier with a size defined by size().
Definition: identifier.h:62
KJS::Identifier::isEmpty
bool isEmpty() const
Returns that the identifiers string is set, but is empty.
Definition: identifier.h:82
KJS::Identifier::Identifier
Identifier(const char *s)
Creates an identifier with the name of the string.
Definition: identifier.h:45
KJS::Identifier::ascii
const char * ascii() const
Char * of the identifier's string.
Definition: identifier.h:71
KJS::UString
Unicode string class.
Definition: ustring.h:189
KJS::UChar
Unicode character.
Definition: ustring.h:51
KJS
Definition: array_instance.h:27
KJS::Identifier::ustring
const UString & ustring() const
returns a UString of the identifier
Definition: identifier.h:52
KJS::Identifier::size
int size() const
The size of the UChar string returned.
Definition: identifier.h:66
KJS::Identifier::Identifier
Identifier()
Creates an empty identifier.
Definition: identifier.h:38
KJS::Identifier
Represents an Identifier for a Javascript object.
Definition: identifier.h:32
KJS::PropertyMap
Javascript Property Map.
Definition: property_map.h:68
TDEStdAccel::insert
const TDEShortcut & insert()

kjs

Skip menu "kjs"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kjs

Skip menu "kjs"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.8.8
This website is maintained by Timothy Pearson.