KJS::UString
#include <ustring.h>
Classes | |
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 () | |
UString & | append (char c) |
UString & | append (const char *t) |
UString & | append (const char *t, int tSize) |
UString & | append (const UString &subStr, int subPos, int subLength=-1) |
UString & | append (const UString &t) |
UString & | append (UChar c) |
UString & | append (unsigned short) |
char * | ascii () const |
void | copyForWriting () |
size_t | cost () const |
CString | cstring () const |
const UChar * | data () 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 |
UString & | operator+= (const char *s) |
UString & | operator+= (const UString &s) |
UString & | operator= (const char *c) |
UString & | operator= (const UString &s) |
UString & | operator= (Empty) |
const UChar | operator[] (int pos) const |
KJS_EXTERNAL_EXPORT QConstString | qconststring () const |
KJS_EXTERNAL_EXPORT QString | qstring () const |
Rep * | rep () 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 UString & | null () |
Detailed Description
Member Enumeration Documentation
◆ Empty
enum KJS::UString::Empty |
Constructor & Destructor Documentation
◆ UString() [1/9]
|
inline |
◆ UString() [2/9]
|
explicit |
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]
|
inline |
◆ 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]
Concatenation constructor.
Makes operator+ more efficient.
Definition at line 496 of file ustring.cpp.
◆ ~UString()
Member Function Documentation
◆ append()
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 |
- Returns
- The string converted to the 8-bit string type CString().
Definition at line 929 of file ustring.cpp.
◆ data()
|
inline |
◆ domString()
KJS_EXTERNAL_EXPORT DOM::DOMString KJS::UString::domString | ( | ) | const |
- See also
- UString(const QString&).
◆ find()
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 1188 of file ustring.cpp.
◆ from() [1/4]
|
static |
Constructs a string from a double.
Definition at line 637 of file ustring.cpp.
◆ from() [2/4]
|
static |
Constructs a string from an int.
Definition at line 559 of file ustring.cpp.
◆ from() [3/4]
|
static |
Constructs a string from a long int.
Definition at line 607 of file ustring.cpp.
◆ from() [4/4]
|
static |
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().
- Returns
- True if the string doesn't contain any non-ASCII characters.
Definition at line 1006 of file ustring.cpp.
◆ isEmpty()
|
inline |
◆ isNull()
|
inline |
◆ maxUChars()
|
static |
◆ null()
|
static |
Static instance of a null string.
Definition at line 553 of file ustring.cpp.
◆ operator+=()
◆ 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 |
- See also
- UString(const QString&).
◆ qstring()
KJS_EXTERNAL_EXPORT QString KJS::UString::qstring | ( | ) | const |
- See also
- UString(const QString&).
◆ rfind()
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 1230 of file ustring.cpp.
◆ size()
|
inline |
◆ substr()
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 1276 of file ustring.cpp.
◆ toArrayIndex()
|
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.
◆ 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.
- 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 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:
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.