KJS::UString

#include <ustring.h>

Classes

struct  Rep
 

Public Types

enum  Empty { empty }
 

Public Member Functions

 UString ()
 
 UString (Empty)
 
 UString (char c)
 
 UString (const char *c)
 
 UString (const char *c, size_t length)
 
 UString (const UChar *c, int length)
 
 UString (UChar *c, int length, bool copy)
 
 UString (const UString &s)
 
 UString (const Vector< UChar > &buffer)
 
KJS_EXTERNAL_EXPORT UString (const QString &)
 
KJS_EXTERNAL_EXPORT UString (const DOM::DOMString &)
 
 UString (const UString &, const UString &)
 
 UString (PassRefPtr< Rep > r)
 
 ~UString ()
 
UStringappend (const UString &subStr, int subPos, int subLength=-1)
 
UStringappend (const UString &t)
 
UStringappend (const char *t)
 
UStringappend (const char *t, int tSize)
 
UStringappend (unsigned short)
 
UStringappend (char c)
 
UStringappend (UChar c)
 
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 UString &s)
 
UStringoperator+= (const char *s)
 
UStringoperator= (const UString &s)
 
UStringoperator= (const char *c)
 
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 (bool tolerateTrailingJunk, bool tolerateEmptyString) const
 
double toDouble (bool tolerateTrailingJunk) const
 
double toDouble () 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 (int i)
 
static UString from (unsigned int u)
 
static UString from (long u)
 
static UString from (double d)
 
static size_t maxUChars ()
 
static const UStringnull ()
 

Friends

KJS_EXPORT friend bool operator== (const UString &, const UString &)
 

Detailed Description

Unicode string class.

Definition at line 153 of file ustring.h.

Member Enumeration Documentation

Constructs an empty string.

Definition at line 237 of file ustring.h.

Constructor & Destructor Documentation

KJS_EXPORT KJS::UString::UString ( )
inline

Constructs a null string.

Definition at line 545 of file ustring.h.

KJS::UString::UString ( char  c)
explicit

Constructs a string from the single character c.

Definition at line 417 of file ustring.cpp.

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

Constructs a string from a classical zero determined char string.

Definition at line 423 of file ustring.cpp.

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

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

Definition at line 470 of file ustring.cpp.

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 479 of file ustring.cpp.

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

Copy constructor.

Makes a shallow copy only.

Definition at line 263 of file ustring.h.

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 !

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

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

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

Concatenation constructor.

Makes operator+ more efficient.

Definition at line 499 of file ustring.cpp.

KJS::UString::~UString ( )
inline

Destructor.

Definition at line 288 of file ustring.h.

Member Function Documentation

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

Append another string.

Definition at line 764 of file ustring.cpp.

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 937 of file ustring.cpp.

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

Definition at line 932 of file ustring.cpp.

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

Definition at line 391 of file ustring.h.

KJS_EXTERNAL_EXPORT DOM::DOMString KJS::UString::domString ( ) const
int KJS::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 1191 of file ustring.cpp.

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

Constructs a string from an int.

Definition at line 562 of file ustring.cpp.

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

Constructs a string from an unsigned int.

Definition at line 592 of file ustring.cpp.

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

Constructs a string from a long int.

Definition at line 610 of file ustring.cpp.

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

Constructs a string from a double.

Definition at line 640 of file ustring.cpp.

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().

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

Definition at line 1009 of file ustring.cpp.

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

Definition at line 405 of file ustring.h.

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

Definition at line 398 of file ustring.h.

size_t KJS::UString::maxUChars ( )
static

Maximum permitted string length.

Since
5.20

Definition at line 1302 of file ustring.cpp.

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

Static instance of a null string.

Definition at line 556 of file ustring.cpp.

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

Appends the specified string.

Definition at line 379 of file ustring.h.

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

Assignment operator.

Definition at line 972 of file ustring.cpp.

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

Const character at specified position.

Definition at line 1023 of file ustring.cpp.

KJS_EXTERNAL_EXPORT QConstString KJS::UString::qconststring ( ) const
KJS_EXTERNAL_EXPORT QString KJS::UString::qstring ( ) const
int KJS::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 1233 of file ustring.cpp.

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

Definition at line 420 of file ustring.h.

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

Definition at line 1279 of file ustring.cpp.

unsigned KJS::UString::toArrayIndex ( bool *  ok = nullptr) const
inline

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.

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.

Parameters
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 1031 of file ustring.cpp.

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 1134 of file ustring.cpp.

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 1534 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-2020 The KDE developers.
Generated on Sun Jul 5 2020 23:00:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.