ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Very simple string class for UTF-32 strings in ScummVM. More...

#include <ustr.h>

List of all members.

Public Types

typedef uint32 value_type
typedef uint32 unsigned_type
typedef value_typeiterator
typedef const value_typeconst_iterator

Public Member Functions

 U32String ()
 Construct a new empty string.
 U32String (const value_type *str)
 Construct a new string from the given NULL-terminated C string.
 U32String (const value_type *str, uint32 len)
 Construct a new string containing exactly len characters read from address str.
 U32String (const value_type *beginP, const value_type *endP)
 Construct a new string containing the characters between beginP (including) and endP (excluding).
 U32String (const U32String &str)
 Construct a copy of the given string.
 U32String (const char *str)
 Construct a new string from the given NULL-terminated C string.
 U32String (const char *str, uint32 len)
 Construct a new string containing exactly len characters read from address str.
 U32String (const char *beginP, const char *endP)
 Construct a new string containing the characters between beginP (including) and endP (excluding).
 U32String (const String &str)
 Construct a copy of the given string.
 ~U32String ()
U32Stringoperator= (const U32String &str)
U32Stringoperator= (const String &str)
U32Stringoperator= (const value_type *str)
U32Stringoperator= (const char *str)
U32Stringoperator+= (const U32String &str)
U32Stringoperator+= (value_type c)
bool operator== (const U32String &x) const
bool operator== (const String &x) const
bool operator== (const value_type *x) const
bool operator== (const char *x) const
bool operator!= (const U32String &x) const
bool operator!= (const String &x) const
bool operator!= (const value_type *x) const
bool operator!= (const char *x) const
bool equals (const U32String &x) const
 Compares whether two U32String are the same based on memory comparison.
bool equals (const String &x) const
 Compares whether two U32String are the same based on memory comparison.
bool contains (value_type x) const
const value_typec_str () const
uint32 size () const
bool empty () const
value_type operator[] (int idx) const
void setChar (value_type c, uint32 p)
 Set character c at position p, replacing the previous character there.
void insertChar (value_type c, uint32 p)
 Insert character c before position p.
void deleteChar (uint32 p)
 Removes the value at position p from the string.
void deleteLastChar ()
 Remove the last character from the string.
void erase (uint32 p, uint32 len=npos)
 Remove all characters from position p to the p + len.
void clear ()
 Clears the string, making it empty.
void toLowercase ()
 Convert all characters in the string to lowercase.
void toUppercase ()
 Convert all characters in the string to uppercase.
uint32 find (value_type x, uint32 pos=0) const
uint32 find (const U32String &str, uint32 pos=0) const
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
String encode (CodePage page=kUtf8) const
 Python-like method.

Static Public Attributes

static const uint32 npos = 0xFFFFFFFF

Private Member Functions

bool isStorageIntern () const
void makeUnique ()
void ensureCapacity (uint32 new_size, bool keep_old)
void incRefCount () const
void decRefCount (int *oldRefCount)
void initWithCStr (const value_type *str, uint32 len)
void initWithCStr (const char *str, uint32 len)
void encodeUTF8 (String &dst) const
void encodeOneByte (String &dst, CodePage page) const

Private Attributes

uint32 _size
 Length of the string.
value_type_str
 Pointer to the actual string storage.
union {
   value_type   _storage [_builtinCapacity]
 Internal string storage.
   struct {
      int *   _refCount
      uint32   _capacity
   }   _extern
 External string storage data -- the refcounter, and the capacity of the string _str points to.
}; 

Static Private Attributes

static const uint32 _builtinCapacity = 32
 The size of the internal storage.

Detailed Description

Very simple string class for UTF-32 strings in ScummVM.

The main intention behind this class is to feature a simple way of displaying UTF-32 strings through the Graphics::Font API.

Please note that operations like equals, deleteCharacter, toUppercase, etc. are only very simplified convenience operations. They might not fully work as you would expect for a proper UTF-32 string class.

The presence of characters in the string will cause undefined behavior in some operations.

Definition at line 45 of file ustr.h.


Member Typedef Documentation

Definition at line 203 of file ustr.h.

Definition at line 202 of file ustr.h.

Definition at line 50 of file ustr.h.

Definition at line 49 of file ustr.h.


Constructor & Destructor Documentation

Common::U32String::U32String (  )  [inline]

Construct a new empty string.

Definition at line 92 of file ustr.h.

Common::U32String::U32String ( const value_type str  )  [explicit]

Construct a new string from the given NULL-terminated C string.

Definition at line 36 of file ustr.cpp.

Common::U32String::U32String ( const value_type str,
uint32  len 
)

Construct a new string containing exactly len characters read from address str.

Definition at line 50 of file ustr.cpp.

Common::U32String::U32String ( const value_type beginP,
const value_type endP 
)

Construct a new string containing the characters between beginP (including) and endP (excluding).

Definition at line 54 of file ustr.cpp.

Common::U32String::U32String ( const U32String str  ) 

Construct a copy of the given string.

Definition at line 59 of file ustr.cpp.

Common::U32String::U32String ( const char *  str  )  [explicit]

Construct a new string from the given NULL-terminated C string.

Definition at line 75 of file ustr.cpp.

Common::U32String::U32String ( const char *  str,
uint32  len 
)

Construct a new string containing exactly len characters read from address str.

Definition at line 84 of file ustr.cpp.

Common::U32String::U32String ( const char *  beginP,
const char *  endP 
)

Construct a new string containing the characters between beginP (including) and endP (excluding).

Definition at line 88 of file ustr.cpp.

Common::U32String::U32String ( const String str  ) 

Construct a copy of the given string.

Definition at line 93 of file ustr.cpp.

Common::U32String::~U32String (  ) 

Definition at line 97 of file ustr.cpp.


Member Function Documentation

iterator Common::U32String::begin (  )  [inline]

Definition at line 205 of file ustr.h.

const_iterator Common::U32String::begin (  )  const [inline]

Definition at line 219 of file ustr.h.

const value_type* Common::U32String::c_str (  )  const [inline]

Definition at line 149 of file ustr.h.

void Common::U32String::clear (  ) 

Clears the string, making it empty.

Definition at line 269 of file ustr.cpp.

bool Common::U32String::contains ( value_type  x  )  const

Definition at line 216 of file ustr.cpp.

void Common::U32String::decRefCount ( int *  oldRefCount  )  [private]

Definition at line 411 of file ustr.cpp.

void Common::U32String::deleteChar ( uint32  p  ) 

Removes the value at position p from the string.

Using this on decomposed characters will not remove the whole character!

Definition at line 236 of file ustr.cpp.

void Common::U32String::deleteLastChar (  ) 

Remove the last character from the string.

Definition at line 245 of file ustr.cpp.

bool Common::U32String::empty (  )  const [inline]

Definition at line 152 of file ustr.h.

String Common::U32String::encode ( CodePage  page = kUtf8  )  const

Python-like method.

Definition at line 393 of file str-enc.cpp.

void Common::U32String::encodeOneByte ( String dst,
CodePage  page 
) const [private]

Definition at line 345 of file str-enc.cpp.

void Common::U32String::encodeUTF8 ( String dst  )  const [private]

Definition at line 100 of file str-enc.cpp.

iterator Common::U32String::end (  )  [inline]

Definition at line 215 of file ustr.h.

const_iterator Common::U32String::end (  )  const [inline]

Definition at line 223 of file ustr.h.

void Common::U32String::ensureCapacity ( uint32  new_size,
bool  keep_old 
) [private]

Definition at line 334 of file ustr.cpp.

bool Common::U32String::equals ( const U32String x  )  const

Compares whether two U32String are the same based on memory comparison.

This does *not* do comparison based on canonical equivalence.

Definition at line 193 of file ustr.cpp.

bool Common::U32String::equals ( const String x  )  const

Compares whether two U32String are the same based on memory comparison.

This does *not* do comparison based on canonical equivalence.

Definition at line 205 of file ustr.cpp.

void Common::U32String::erase ( uint32  p,
uint32  len = npos 
)

Remove all characters from position p to the p + len.

If len = String::npos, removes all characters to the end

Definition at line 250 of file ustr.cpp.

uint32 Common::U32String::find ( const U32String str,
uint32  pos = 0 
) const

Definition at line 305 of file ustr.cpp.

uint32 Common::U32String::find ( value_type  x,
uint32  pos = 0 
) const

Definition at line 295 of file ustr.cpp.

void Common::U32String::incRefCount (  )  const [private]

Definition at line 396 of file ustr.cpp.

void Common::U32String::initWithCStr ( const value_type str,
uint32  len 
) [private]

Definition at line 438 of file ustr.cpp.

void Common::U32String::initWithCStr ( const char *  str,
uint32  len 
) [private]

Definition at line 458 of file ustr.cpp.

void Common::U32String::insertChar ( value_type  c,
uint32  p 
)

Insert character c before position p.

Definition at line 226 of file ustr.cpp.

bool Common::U32String::isStorageIntern (  )  const [inline, private]

Definition at line 86 of file ustr.h.

void Common::U32String::makeUnique (  )  [private]

Definition at line 330 of file ustr.cpp.

bool Common::U32String::operator!= ( const String x  )  const

Definition at line 181 of file ustr.cpp.

bool Common::U32String::operator!= ( const char *  x  )  const

Definition at line 189 of file ustr.cpp.

bool Common::U32String::operator!= ( const U32String x  )  const

Definition at line 177 of file ustr.cpp.

bool Common::U32String::operator!= ( const value_type x  )  const

Definition at line 185 of file ustr.cpp.

U32String & Common::U32String::operator+= ( const U32String str  ) 

Definition at line 137 of file ustr.cpp.

U32String & Common::U32String::operator+= ( value_type  c  ) 

Definition at line 152 of file ustr.cpp.

U32String & Common::U32String::operator= ( const char *  str  ) 

Definition at line 132 of file ustr.cpp.

U32String & Common::U32String::operator= ( const U32String str  ) 

Definition at line 101 of file ustr.cpp.

U32String & Common::U32String::operator= ( const value_type str  ) 

Definition at line 128 of file ustr.cpp.

U32String & Common::U32String::operator= ( const String str  ) 

Definition at line 123 of file ustr.cpp.

bool Common::U32String::operator== ( const String x  )  const

Definition at line 165 of file ustr.cpp.

bool Common::U32String::operator== ( const char *  x  )  const

Definition at line 173 of file ustr.cpp.

bool Common::U32String::operator== ( const value_type x  )  const

Definition at line 169 of file ustr.cpp.

bool Common::U32String::operator== ( const U32String x  )  const

Definition at line 161 of file ustr.cpp.

value_type Common::U32String::operator[] ( int  idx  )  const [inline]

Definition at line 154 of file ustr.h.

void Common::U32String::setChar ( value_type  c,
uint32  p 
) [inline]

Set character c at position p, replacing the previous character there.

Definition at line 160 of file ustr.h.

uint32 Common::U32String::size (  )  const [inline]

Definition at line 150 of file ustr.h.

void Common::U32String::toLowercase (  ) 

Convert all characters in the string to lowercase.

Be aware that this only affects the case of ASCII characters. All other characters will not be touched at all.

Definition at line 277 of file ustr.cpp.

void Common::U32String::toUppercase (  ) 

Convert all characters in the string to uppercase.

Be aware that this only affects the case of ASCII characters. All other characters will not be touched at all.

Definition at line 286 of file ustr.cpp.


Member Data Documentation

union { ... } [private]
const uint32 Common::U32String::_builtinCapacity = 32 [static, private]

The size of the internal storage.

Increasing this means less heap allocations are needed, at the cost of more stack memory usage, and of course lots of wasted memory.

Definition at line 57 of file ustr.h.

Definition at line 82 of file ustr.h.

External string storage data -- the refcounter, and the capacity of the string _str points to.

Definition at line 81 of file ustr.h.

Length of the string.

Definition at line 62 of file ustr.h.

Internal string storage.

Definition at line 75 of file ustr.h.

Pointer to the actual string storage.

Either points to _storage, or to a block allocated on the heap via malloc.

Definition at line 68 of file ustr.h.

const uint32 Common::U32String::npos = 0xFFFFFFFF [static]

Definition at line 47 of file ustr.h.


The documentation for this class was generated from the following files:


Generated on Sat May 30 2020 05:02:59 for ResidualVM by doxygen 1.7.1
curved edge   curved edge