Search for usage in LXR

#include <ustring.h>


struct  Rep

Public Types

enum  Empty { empty }

Public Member Functions

 UString ()
 UString (char c)
 UString (const char *c)
 UString (const char *c, size_t length)
KJS_EXTERNAL_EXPORT UString (const DOM::DOMString &)
KJS_EXTERNAL_EXPORT UString (const QString &)
 UString (const UChar *c, int length)
 UString (const UString &, const UString &)
 UString (const UString &s)
 UString (const Vector< UChar > &buffer)
 UString (Empty)
 UString (PassRefPtr< Rep > r)
 UString (UChar *c, int length, bool copy)
 ~UString ()
UStringappend (char c)
UStringappend (const char *t)
UStringappend (const char *t, int tSize)
UStringappend (const UString &subStr, int subPos, int subLength=-1)
UStringappend (const UString &t)
UStringappend (UChar c)
UStringappend (unsigned short)
char * ascii () const
void copyForWriting ()
size_t cost () const
CString cstring () const
const UChardata () const
KJS_EXTERNAL_EXPORT DOM::DOMString domString () const
int find (const UString &f, int pos=0) const
int find (UChar, int pos=0) const
bool is8Bit () const
bool isEmpty () const
bool isNull () const
UStringoperator+= (const char *s)
UStringoperator+= (const UString &s)
UStringoperator= (const char *c)
UStringoperator= (const UString &s)
UStringoperator= (Empty)
const UChar operator[] (int pos) const
KJS_EXTERNAL_EXPORT QConstString qconststring () const
KJS_EXTERNAL_EXPORT QString qstring () const
Reprep () const
int rfind (const UString &f, int pos) const
int rfind (UChar, int pos) const
int size () const
UString spliceSubstringsWithSeparators (const Range *substringRanges, int rangeCount, const UString *separators, int separatorCount) const
UString substr (int pos=0, int len=-1) const
unsigned toArrayIndex (bool *ok=nullptr) const
double toDouble () const
double toDouble (bool tolerateTrailingJunk) const
double toDouble (bool tolerateTrailingJunk, bool tolerateEmptyString) const
uint32_t toStrictUInt32 (bool *ok=nullptr) const
CString UTF8String () const

Static Public Member Functions

static bool equal (const UString::Rep *a, const UString::Rep *b)
static UString from (double d)
static UString from (int i)
static UString from (long u)
static UString from (unsigned int u)
static size_t maxUChars ()
static const UStringnull ()

Detailed Description

Unicode string class.

Definition at line 153 of file ustring.h.

Member Enumeration Documentation

◆ Empty

Constructs an empty string.

Definition at line 237 of file ustring.h.

Constructor & Destructor Documentation

◆ UString() [1/9]

KJS_EXPORT KJS::UString::UString ( )

Constructs a null string.

Definition at line 545 of file ustring.h.

◆ UString() [2/9]

KJS::UString::UString ( char  c)

Constructs a string from the single character c.

Definition at line 414 of file ustring.cpp.

◆ UString() [3/9]

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

Constructs a string from a classical zero determined char string.

Definition at line 420 of file ustring.cpp.

◆ UString() [4/9]

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

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

Definition at line 467 of file ustring.cpp.

◆ UString() [5/9]

KJS::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 476 of file ustring.cpp.

◆ UString() [6/9]

KJS::UString::UString ( const UString s)

Copy constructor.

Makes a shallow copy only.

Definition at line 263 of file ustring.h.

◆ UString() [7/9]

KJS_EXTERNAL_EXPORT 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 !

◆ UString() [8/9]

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

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

◆ UString() [9/9]

KJS::UString::UString ( const UString a,
const UString b 

Concatenation constructor.

Makes operator+ more efficient.

Definition at line 496 of file ustring.cpp.

◆ ~UString()

KJS::UString::~UString ( )


Definition at line 288 of file ustring.h.

Member Function Documentation

◆ append()

UString & KJS::UString::append ( const UString subStr,
int  subPos,
int  subLength = -1 

Append another string.

Definition at line 761 of file ustring.cpp.

◆ ascii()

char * KJS::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 934 of file ustring.cpp.

◆ cstring()

CString KJS::UString::cstring ( ) const
The string converted to the 8-bit string type CString().

Definition at line 929 of file ustring.cpp.

◆ data()

const UChar* KJS::UString::data ( ) const
A pointer to the internal Unicode data.

Definition at line 391 of file ustring.h.

◆ domString()

KJS_EXTERNAL_EXPORT DOM::DOMString KJS::UString::domString ( ) const

◆ find()

int KJS::UString::find ( const UString f,
int  pos = 0 
) const
Position of first occurrence of f starting at position pos. -1 if the search was not successful.

Definition at line 1188 of file ustring.cpp.

◆ from() [1/4]

UString KJS::UString::from ( double  d)

Constructs a string from a double.

Definition at line 637 of file ustring.cpp.

◆ from() [2/4]

UString KJS::UString::from ( int  i)

Constructs a string from an int.

Definition at line 559 of file ustring.cpp.

◆ from() [3/4]

UString KJS::UString::from ( long  u)

Constructs a string from a long int.

Definition at line 607 of file ustring.cpp.

◆ from() [4/4]

UString KJS::UString::from ( unsigned int  u)

Constructs a string from an unsigned int.

Definition at line 589 of file ustring.cpp.

◆ is8Bit()

bool KJS::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().

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

Definition at line 1006 of file ustring.cpp.

◆ isEmpty()

bool KJS::UString::isEmpty ( ) const
True if null or zero length.

Definition at line 405 of file ustring.h.

◆ isNull()

bool KJS::UString::isNull ( ) const
True if null.

Definition at line 398 of file ustring.h.

◆ maxUChars()

size_t KJS::UString::maxUChars ( )

Maximum permitted string length.


Definition at line 1299 of file ustring.cpp.

◆ null()

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

Static instance of a null string.

Definition at line 553 of file ustring.cpp.

◆ operator+=()

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

Appends the specified string.

Definition at line 379 of file ustring.h.

◆ operator=()

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

Assignment operator.

Definition at line 969 of file ustring.cpp.

◆ operator[]()

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

Const character at specified position.

Definition at line 1020 of file ustring.cpp.

◆ qconststring()

KJS_EXTERNAL_EXPORT QConstString KJS::UString::qconststring ( ) const

◆ qstring()

KJS_EXTERNAL_EXPORT QString KJS::UString::qstring ( ) const

◆ rfind()

int KJS::UString::rfind ( const UString f,
int  pos 
) const
Position of first occurrence of f searching backwards from position pos. -1 if the search was not successful.

Definition at line 1230 of file ustring.cpp.

◆ size()

int KJS::UString::size ( ) const
The length of the string.

Definition at line 420 of file ustring.h.

◆ substr()

UString KJS::UString::substr ( int  pos = 0,
int  len = -1 
) const
The sub string starting at position pos and length len.

Definition at line 1276 of file ustring.cpp.

◆ toArrayIndex()

unsigned KJS::UString::toArrayIndex ( bool *  ok = nullptr) 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 552 of file ustring.h.

◆ toDouble()

double KJS::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.

tolerateTrailingJunkif true, toDouble can tolerate garbage after the number.
tolerateEmptyStringif false, toDouble will turn an empty string into NaN rather than 0.

Definition at line 1028 of file ustring.cpp.

◆ toStrictUInt32()

uint32_t KJS::UString::toStrictUInt32 ( bool *  ok = nullptr) const

Attempts an conversion to a 32-bit integer.

ok will be set according to the success.

Definition at line 1131 of file ustring.cpp.

◆ UTF8String()

CString KJS::UString::UTF8String ( ) const

Convert the string to UTF-8, assuming it is UTF-16 encoded.

Since this function is tolerant of badly formed UTF-16, it can create UTF-8 strings that are invalid because they have characters in the range U+D800-U+DDFF, U+FFFE, or U+FFFF, but the UTF-8 string is guaranteed to be otherwise valid.

Definition at line 1531 of file ustring.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Feb 3 2023 04:01:30 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.