Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KJS::UString Class Reference

Unicode string class. More...

#include <ustring.h>

List of all members.

Public Methods

 UString ()
 UString (char c)
 UString (const char *c)
 UString (const UChar *c, int length)
 UString (UChar *c, int length, bool copy)
 UString (const UString &)
 UString (const QString &)
 UString (const DOM::DOMString &)
 ~UString ()
UString & append (const UString &)
CString cstring () const
char * ascii () const
DOM::DOMString string () const
QString qstring () const
QConstString qconststring () const
UString & operator= (const char *c)
UString & operator= (const UString &)
UString & operator+= (const UString &s)
const UChar * data () 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 tolerant=false) const
unsigned long toULong (bool *ok=0L) const
UString toLower () const
UString toUpper () const
int find (const UString &f, int pos=0) const
int rfind (const UString &f, int pos) const
UString substr (int pos=0, int len=-1) const

Static Public Methods

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

Static Public Attributes

UString null


Detailed Description

Unicode string class.

Definition at line 187 of file ustring.h.


Constructor & Destructor Documentation

KJS::UString::UString (    ) 
 

Constructs a null string.

KJS::UString::UString (  char    c ) 
 

Constructs a string from the single character c.

KJS::UString::UString (  const char *    c ) 
 

Constructs a string from a classical zero determined char string.

KJS::UString::UString (  const UChar *    c,
int    length
) 
 

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

KJS::UString::UString (  UChar *    c,
int    length,
bool    copy
) 
 

If copy is false a shallow copy of the string will be created. That means that the data will NOT be copied and you'll have to guarantee that it doesn't get deleted during the lifetime of the UString object. Behaviour defaults to a deep copy if copy is true.

KJS::UString::UString (  const UString &    ) 
 

Copy constructor. Makes a shallow copy only.

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 favourite FooString class here !

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

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

KJS::UString::~UString (    ) 
 

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


Member Function Documentation

UString& KJS::UString::append (  const UString &    ) 
 

Append another string.

char* KJS::UString::ascii (    ) 
 

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.

CString KJS::UString::cstring (    ) 
 

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

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

Returns:
A pointer to the internal Unicode data.

Definition at line 315 of file ustring.h.

int KJS::UString::find (  const UString &    f,
int    pos = 0
)  const
 

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

UString KJS::UString::from (  double    d )  [static]
 

Constructs a string from a double.

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

Constructs a string from an unsigned int.

UString KJS::UString::from (  int    i )  [static]
 

Constructs a string from an int.

bool KJS::UString::is8Bit (    ) 
 

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.

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

Returns:
True if null or zero length.

Definition at line 323 of file ustring.h.

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

Returns:
True if null.

Definition at line 319 of file ustring.h.

UString& KJS::UString::operator+= (  const UString &    s ) 
 

Appends the specified string.

UString& KJS::UString::operator= (  const UString &    ) 
 

Assignment operator.

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

Assignment operator.

UCharReference KJS::UString::operator[] (  int    pos ) 
 

Writable reference to character at specified position.

UChar KJS::UString::operator[] (  int    pos )  const
 

Const character at specified position.

QConstString KJS::UString::qconststring (    ) 
 

See also:
UString(const QString&).

QString KJS::UString::qstring (    ) 
 

See also:
UString(const QString&).

int KJS::UString::rfind (  const UString &    f,
int    pos
)  const
 

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

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

Returns:
The length of the string.

Definition at line 335 of file ustring.h.

DOM::DOMString KJS::UString::string (    ) 
 

See also:
UString(const QString&).

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

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

double KJS::UString::toDouble (  bool    tolerant = false )  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:
tolerant  if true, toDouble can tolerate garbage after the number.

UString KJS::UString::toLower (    ) 
 

Returns this string converted to lower case characters

unsigned long KJS::UString::toULong (  bool *    ok = 0L )  const
 

Attempts an conversion to an unsigned long integer. ok will be set according to the success.

UString KJS::UString::toUpper (    ) 
 

Returns this string converted to upper case characters


Member Data Documentation

UString KJS::UString::null [static]
 

Static instance of a null string.

Definition at line 384 of file ustring.h.


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:34 2003 for kdelibs by doxygen1.2.18