kjs Library API Documentation

KJS::UString Class Reference

Unicode string class. More...

#include <ustring.h>

List of all members.

Public Member Functions

 UString ()
 UString (char c)
 UString (const char *c)
 UString (const UChar *c, int length)
 UString (UChar *c, int length, bool copy)
 UString (const UString &s)
 UString (const QString &)
 UString (const DOM::DOMString &)
 UString (const UString &, const UString &)
 ~UString ()
UStringappend (const UString &)
CString cstring () const
char * ascii () const
DOM::DOMString string () const
QString qstring () const
QConstString qconststring () const
UStringoperator= (const char *c)
UStringoperator= (const UString &)
UStringoperator+= (const UString &s)
const UChardata () const
bool isNull () const
bool isEmpty () const
bool is8Bit () const
int size () const
UChar operator[] (int pos) const
UCharReference operator[] (int pos)
double toDouble (bool tolerateTrailingJunk, bool tolerateEmptyString) const
double toDouble (bool tolerateTrailingJunk) const
double toDouble () const
unsigned long toULong (bool *ok, bool tolerateEmptyString) const
unsigned long toULong (bool *ok=0) const
unsigned int toStrictUInt32 (bool *ok=0) const
unsigned toArrayIndex (bool *ok=0) const
UString toLower () const
UString toUpper () const
int find (const UString &f, int pos=0) const
int find (UChar, int pos=0) const
int rfind (const UString &f, int pos) const
int rfind (UChar, int pos) const
UString substr (int pos=0, int len=-1) const

Static Public Member Functions

UString from (int i)
UString from (unsigned int u)
UString from (long l)
UString from (double d)

Static Public Attributes

UString null

Friends

class UCharReference
class Identifier
class PropertyMap
class PropertyMapHashTableEntry
bool operator== (const UString &, const UString &)


Detailed Description

Unicode string class.

Definition at line 189 of file ustring.h.


Constructor & Destructor Documentation

UString::UString  ) 
 

Constructs a null string.

Definition at line 264 of file ustring.cpp.

References rep.

Referenced by from().

UString::UString char  c  )  [explicit]
 

Constructs a string from the single character c.

Definition at line 270 of file ustring.cpp.

UString::UString const char *  c  ) 
 

Constructs a string from a classical zero determined char string.

Definition at line 277 of file ustring.cpp.

References KJS::UChar::uc.

UString::UString const UChar c,
int  length
 

Constructs a string from an array of Unicode characters of the specified length.

Definition at line 294 of file ustring.cpp.

UString::UString UChar c,
int  length,
bool  copy
 

If copy is false the string data will be adopted.

That means that the data will NOT be copied and the pointer will be deleted when the UString object is modified or destroyed. Behaviour defaults to a deep copy if copy is true.

Definition at line 305 of file ustring.cpp.

KJS::UString::UString const UString s  )  [inline]
 

Copy constructor.

Makes a shallow copy only.

Definition at line 256 of file ustring.h.

References rep.

KJS::UString::UString const QString  ) 
 

Convenience declaration only ! You'll be on your own to write the implementation for a construction from QString.

Note: feel free to contact me if you want to see a dummy header for your favorite FooString class here !

KJS::UString::UString const DOM::DOMString &   ) 
 

Convenience declaration only ! See UString(const QString&).

UString::UString const UString ,
const UString
 

Concatenation constructor.

Makes operator+ more efficient.

Definition at line 320 of file ustring.cpp.

References data(), and size().

KJS::UString::~UString  )  [inline]
 

Destructor.

If this handle was the only one holding a reference to the string the data will be freed.

Definition at line 277 of file ustring.h.


Member Function Documentation

UString UString::from int  i  )  [static]
 

Constructs a string from an int.

Definition at line 335 of file ustring.cpp.

UString UString::from unsigned int  u  )  [static]
 

Constructs a string from an unsigned int.

Definition at line 340 of file ustring.cpp.

References UString().

UString UString::from long  l  )  [static]
 

Constructs a string from a long.

Definition at line 358 of file ustring.cpp.

References UString().

UString UString::from double  d  )  [static]
 

Constructs a string from a double.

Definition at line 384 of file ustring.cpp.

References UString().

UString & UString::append const UString  ) 
 

Append another string.

Definition at line 452 of file ustring.cpp.

References data(), and size().

Referenced by operator+=().

CString UString::cstring  )  const
 

Returns:
The string converted to the 8-bit string type CString().

Definition at line 475 of file ustring.cpp.

References ascii().

char * UString::ascii  )  const
 

Convert the Unicode string to plain ASCII chars chopping of any higher bytes.

This method should only be used for *debugging* purposes as it is neither Unicode safe nor free from side effects. In order not to waste any memory the char buffer is static and *shared* by all UString instances.

Definition at line 480 of file ustring.cpp.

References data(), size(), and KJS::UChar::uc.

Referenced by cstring(), and toDouble().

DOM::DOMString KJS::UString::string  )  const
 

See also:
UString(const QString&).

QString KJS::UString::qstring  )  const
 

See also:
UString(const QString&).

QConstString KJS::UString::qconststring  )  const
 

See also:
UString(const QString&).

UString & UString::operator= const char *  c  ) 
 

Assignment operator.

Definition at line 517 of file ustring.cpp.

References KJS::UChar::uc.

UString& KJS::UString::operator+= const UString s  )  [inline]
 

Appends the specified string.

Definition at line 334 of file ustring.h.

References append().

const UChar* KJS::UString::data  )  const [inline]
 

Returns:
A pointer to the internal Unicode data.

Definition at line 339 of file ustring.h.

Referenced by append(), ascii(), find(), is8Bit(), operator[](), rfind(), substr(), and UString().

bool KJS::UString::isNull  )  const [inline]
 

Returns:
True if null.

Definition at line 343 of file ustring.h.

bool KJS::UString::isEmpty  )  const [inline]
 

Returns:
True if null or zero length.

Definition at line 347 of file ustring.h.

bool UString::is8Bit  )  const
 

Use this if you want to make sure that this string is a plain ASCII string.

For example, if you don't want to lose any information when using cstring() or ascii().

Returns:
True if the string doesn't contain any non-ASCII characters.

Definition at line 544 of file ustring.cpp.

References data(), size(), and KJS::UChar::uc.

Referenced by toDouble().

int KJS::UString::size  )  const [inline]
 

Returns:
The length of the string.

Definition at line 359 of file ustring.h.

Referenced by append(), ascii(), find(), is8Bit(), operator[](), rfind(), substr(), toLower(), toUpper(), and UString().

UChar UString::operator[] int  pos  )  const
 

Const character at specified position.

Definition at line 557 of file ustring.cpp.

References data(), and size().

UCharReference UString::operator[] int  pos  ) 
 

Writable reference to character at specified position.

Definition at line 565 of file ustring.cpp.

double UString::toDouble bool  tolerateTrailingJunk,
bool  tolerateEmptyString
const
 

Attempts an conversion to a number.

Apart from floating point numbers, the algorithm will recognize hexadecimal representations (as indicated by a 0x or 0X prefix) and +/- Infinity. Returns NaN if the conversion failed.

Parameters:
tolerateTrailingJunk if true, toDouble can tolerate garbage after the number.
tolerateEmptyString if false, toDouble will turn an empty string into NaN rather than 0.

Definition at line 597 of file ustring.cpp.

References ascii(), and is8Bit().

Referenced by toULong().

unsigned long UString::toULong bool *  ok,
bool  tolerateEmptyString
const
 

Attempts an conversion to an unsigned long integer.

ok will be set according to the success.

Parameters:
tolerateEmptyString if false, toULong will return false for *ok for an empty string.

Definition at line 675 of file ustring.cpp.

References toDouble().

unsigned UString::toArrayIndex bool *  ok = 0  )  const
 

Attempts an conversion to an array index.

The "ok" boolean will be set to true if it is a valid array index according to the rule from ECMA 15.2 about what an array index is. It must exactly match the string form of an unsigned integer, and be less than 2^32 - 1.

Definition at line 764 of file ustring.cpp.

UString UString::toLower  )  const
 

Returns this string converted to lower case characters.

Definition at line 696 of file ustring.cpp.

References size().

UString UString::toUpper  )  const
 

Returns this string converted to upper case characters.

Definition at line 704 of file ustring.cpp.

References size().

int UString::find const UString f,
int  pos = 0
const
 

Returns:
Position of first occurrence of f starting at position pos. -1 if the search was not successful.

Definition at line 772 of file ustring.cpp.

References data(), and size().

int UString::rfind const UString f,
int  pos
const
 

Returns:
Position of first occurrence of f searching backwards from position pos. -1 if the search was not successful.

Definition at line 804 of file ustring.cpp.

References data(), and size().

UString UString::substr int  pos = 0,
int  len = -1
const
 

Returns:
The sub string starting at position pos and length len.

Definition at line 840 of file ustring.cpp.

References data(), and size().


Member Data Documentation

UString UString::null [static]
 

Static instance of a null string.

Definition at line 126 of file ustring.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kjs Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Jan 21 09:57:42 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003