• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • KJS
  • UString
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
KJS::UString Class Reference

#include <ustring.h>

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 TQString &)
 
 UString (const DOM::DOMString &)
 
 UString (const UString &, const UString &)
 
 ~UString ()
 
UString & append (const UString &)
 
CString cstring () const
 
char * ascii () const
 
DOM::DOMString string () const
 
TQString qstring () const
 
TQConstString 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 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 toUInt32 (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

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

Static Public Attributes

static 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() [1/9]

UString::UString ( )

Constructs a null string.

Definition at line 269 of file ustring.cpp.

◆ UString() [2/9]

UString::UString ( char  c)
explicit

Constructs a string from the single character c.

Definition at line 275 of file ustring.cpp.

◆ UString() [3/9]

UString::UString ( const char *  c)

Constructs a string from a classical zero determined char string.

Definition at line 282 of file ustring.cpp.

◆ UString() [4/9]

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

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

Definition at line 299 of file ustring.cpp.

◆ UString() [5/9]

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

◆ UString() [6/9]

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

Copy constructor.

Makes a shallow copy only.

Definition at line 256 of file ustring.h.

◆ UString() [7/9]

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

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

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

◆ UString() [8/9]

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

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

◆ UString() [9/9]

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

Concatenation constructor.

Makes operator+ more efficient.

Definition at line 325 of file ustring.cpp.

◆ ~UString()

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

◆ append()

UString & UString::append ( const UString &  t)

Append another string.

Definition at line 457 of file ustring.cpp.

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

◆ cstring()

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

Definition at line 480 of file ustring.cpp.

◆ data()

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

Definition at line 339 of file ustring.h.

◆ find() [1/2]

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

◆ find() [2/2]

int UString::find ( UChar  ch,
int  pos = 0 
) const

Definition at line 820 of file ustring.cpp.

◆ from() [1/4]

UString UString::from ( double  d)
static

Constructs a string from a double.

Definition at line 389 of file ustring.cpp.

◆ from() [2/4]

UString UString::from ( int  i)
static

Constructs a string from an int.

Definition at line 340 of file ustring.cpp.

◆ from() [3/4]

UString UString::from ( long  l)
static

Constructs a string from a long.

Definition at line 363 of file ustring.cpp.

◆ from() [4/4]

UString UString::from ( unsigned int  u)
static

Constructs a string from an unsigned int.

Definition at line 345 of file ustring.cpp.

◆ is8Bit()

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

◆ isEmpty()

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

Definition at line 347 of file ustring.h.

◆ isNull()

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

Definition at line 343 of file ustring.h.

◆ operator+=()

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

Appends the specified string.

Definition at line 334 of file ustring.h.

◆ operator=() [1/2]

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

Assignment operator.

Definition at line 522 of file ustring.cpp.

◆ operator=() [2/2]

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

Definition at line 540 of file ustring.cpp.

◆ operator[]() [1/2]

UCharReference UString::operator[] ( int  pos)

Writable reference to character at specified position.

Definition at line 570 of file ustring.cpp.

◆ operator[]() [2/2]

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

Const character at specified position.

Definition at line 562 of file ustring.cpp.

◆ qconststring()

TQConstString KJS::UString::qconststring ( ) const
See also
UString(const TQString&).

◆ qstring()

TQString KJS::UString::qstring ( ) const
See also
UString(const TQString&).

◆ rfind() [1/2]

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

◆ rfind() [2/2]

int UString::rfind ( UChar  ch,
int  pos 
) const

Definition at line 854 of file ustring.cpp.

◆ size()

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

Definition at line 359 of file ustring.h.

◆ string()

DOM::DOMString KJS::UString::string ( ) const
See also
UString(const TQString&).

◆ substr()

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

Definition at line 868 of file ustring.cpp.

◆ toArrayIndex()

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

◆ toDouble() [1/3]

double UString::toDouble ( ) const

Definition at line 680 of file ustring.cpp.

◆ toDouble() [2/3]

double UString::toDouble ( bool  tolerateTrailingJunk) const

Definition at line 675 of file ustring.cpp.

◆ toDouble() [3/3]

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

◆ toLower()

UString UString::toLower ( ) const

Returns this string converted to lower case characters.

Definition at line 706 of file ustring.cpp.

◆ toStrictUInt32()

unsigned int UString::toStrictUInt32 ( bool *  ok = 0) const

Definition at line 738 of file ustring.cpp.

◆ toUInt32()

unsigned int UString::toUInt32 ( bool *  ok = 0) const

Definition at line 722 of file ustring.cpp.

◆ toULong() [1/2]

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. @param ok make this point to a bool in case you need to know whether the conversion succeeded.

Parameters
tolerateEmptyStringif false, toULong will return false for *ok for an empty string.

Definition at line 685 of file ustring.cpp.

◆ toULong() [2/2]

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

Definition at line 701 of file ustring.cpp.

◆ toUpper()

UString UString::toUpper ( ) const

Returns this string converted to upper case characters.

Definition at line 714 of file ustring.cpp.

Friends And Related Function Documentation

◆ Identifier

friend class Identifier
friend

Definition at line 192 of file ustring.h.

◆ PropertyMap

friend class PropertyMap
friend

Definition at line 193 of file ustring.h.

◆ PropertyMapHashTableEntry

friend class PropertyMapHashTableEntry
friend

Definition at line 194 of file ustring.h.

◆ UCharReference

friend class UCharReference
friend

Definition at line 191 of file ustring.h.

Member Data Documentation

◆ null

UString UString::null
static

Static instance of a null string.

Definition at line 428 of file ustring.h.


The documentation for this class was generated from the following files:
  • ustring.h
  • ustring.cpp

kjs

Skip menu "kjs"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kjs

Skip menu "kjs"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.9.4
This website is maintained by Timothy Pearson.