23#ifndef _KJS_USTRING_H_
24#define _KJS_USTRING_H_
57 UChar(
unsigned char u);
63 UChar(
unsigned char h ,
unsigned char l);
68 UChar(
unsigned short u);
73 unsigned char high()
const {
return uc >> 8; }
77 unsigned char low()
const {
return uc; }
81 unsigned short unicode()
const {
return uc; }
86 UChar toLower()
const;
90 UChar toUpper()
const;
100 inline UChar::UChar(
unsigned char h ,
unsigned char l) : uc(h << 8 | l) { }
119 class KJS_EXPORT UCharReference {
120 friend class UString;
121 UCharReference(UString *s,
unsigned int off) : str(s), offset(off) { }
134 unsigned short unicode()
const {
return ref().uc; }
138 unsigned char low()
const {
return ref().uc; }
142 unsigned char high()
const {
return ref().uc >> 8; }
160 inline UChar::UChar(
const UCharReference &c) : uc(c.unicode()) { }
165 class KJS_EXPORT CString {
167 CString() : data(0L), length(0) { }
168 CString(
const char *c);
169 CString(
const char *c,
int len);
170 CString(
const CString &);
174 CString &append(
const CString &);
175 CString &operator=(
const char *c);
176 CString &operator=(
const CString &);
177 CString &operator+=(
const CString &c) {
return append(c); }
179 int size()
const {
return length; }
180 const char *c_str()
const {
return data; }
191 friend class UCharReference;
192 friend class Identifier;
193 friend class PropertyMap;
194 friend class PropertyMapHashTableEntry;
198 struct KJS_EXPORT Rep {
202 static Rep *create(
UChar *d,
int l);
206 int size()
const {
return len; }
208 unsigned hash()
const {
if (_hash == 0) _hash = computeHash(dat, len);
return _hash; }
210 static unsigned computeHash(
const UChar *,
int length);
211 static unsigned computeHash(
const char *);
214 void deref() {
if (--rc == 0) destroy(); }
220 mutable unsigned _hash;
222 enum { capacityForIdentifier = 0x10000000 };
286 static UString from(
unsigned int u);
343 bool isNull()
const {
return (rep == &Rep::null); }
359 int size()
const {
return rep->size(); }
363 UChar operator[](
int pos)
const;
377 double toDouble(
bool tolerateTrailingJunk,
bool tolerateEmptyString)
const;
378 double toDouble(
bool tolerateTrailingJunk)
const;
379 double toDouble()
const;
386 unsigned long toULong(
bool *ok,
bool tolerateEmptyString)
const;
387 unsigned long toULong(
bool *ok = 0)
const;
389 unsigned int toUInt32(
bool *ok = 0)
const;
390 unsigned int toStrictUInt32(
bool *ok = 0)
const;
398 unsigned toArrayIndex(
bool *ok = 0)
const;
412 int find(
const UString &f,
int pos = 0)
const;
413 int find(
UChar,
int pos = 0)
const;
419 int rfind(
const UString &f,
int pos)
const;
420 int rfind(
UChar,
int pos)
const;
424 UString substr(
int pos = 0,
int len = -1)
const;
433 static void globalClear();
443 KJS_EXPORT
inline bool operator==(
const UChar &c1,
const UChar &c2) {
444 return (c1.uc == c2.uc);
446 KJS_EXPORT
inline bool operator!=(
const UChar& c1,
const UChar& c2) {
447 return !KJS::operator==(c1, c2);
451 return !KJS::operator==(s1, s2);
454 KJS_EXPORT
bool operator==(
const UString& s1,
const char *s2);
455 KJS_EXPORT
inline bool operator!=(
const UString& s1,
const char *s2) {
456 return !KJS::operator==(s1, s2);
458 KJS_EXPORT
inline bool operator==(
const char *s1,
const UString& s2) {
459 return operator==(s2, s1);
461 KJS_EXPORT
inline bool operator!=(
const char *s1,
const UString& s2) {
462 return !KJS::operator==(s1, s2);
465 KJS_EXPORT
inline bool operator!=(
const CString& s1,
const CString& s2) {
466 return !KJS::operator==(s1, s2);
8 bit char based string class
Dynamic reference to a string character.
UCharReference & operator=(char c)
Same operator as above except the argument that it takes.
unsigned char high() const
unsigned char low() const
UCharReference & operator=(UChar c)
Set the referenced character to c.
unsigned short unicode() const
DOM::DOMString string() const
UString()
Constructs a null string.
UString & operator=(const char *c)
Assignment operator.
UString & operator+=(const UString &s)
Appends the specified string.
UString(const DOM::DOMString &)
Convenience declaration only !
TQConstString qconststring() const
static UString null
Static instance of a null string.
UString(const UString &s)
Copy constructor.
UString(const TQString &)
Convenience declaration only !
const UChar * data() const
UString & append(const UString &)
Append another string.
unsigned char low() const
static UChar null
A static instance of UChar(0).
UChar()
Construct a character with uninitialized value.
unsigned char high() const
unsigned short unicode() const