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 deleteChar (uint32 p)
 Removes the value at position p from the string.
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 (const U32String &str, uint32 pos=0) const
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const

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)

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 44 of file ustr.h.


Member Typedef Documentation

Definition at line 187 of file ustr.h.

Definition at line 186 of file ustr.h.

Definition at line 49 of file ustr.h.

Definition at line 48 of file ustr.h.


Constructor & Destructor Documentation

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

Construct a new empty string.

Definition at line 91 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 189 of file ustr.h.

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

Definition at line 203 of file ustr.h.

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

Definition at line 148 of file ustr.h.

void Common::U32String::clear (  ) 

Clears the string, making it empty.

Definition at line 235 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 367 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 226 of file ustr.cpp.

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

Definition at line 151 of file ustr.h.

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

Definition at line 199 of file ustr.h.

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

Definition at line 207 of file ustr.h.

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

Definition at line 290 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.

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

Definition at line 261 of file ustr.cpp.

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

Definition at line 352 of file ustr.cpp.

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

Definition at line 409 of file ustr.cpp.

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

Definition at line 389 of file ustr.cpp.

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

Definition at line 85 of file ustr.h.

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

Definition at line 286 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 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.

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

Definition at line 189 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 value_type str  ) 

Definition at line 128 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 String str  ) 

Definition at line 123 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 U32String x  )  const

Definition at line 161 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 String x  )  const

Definition at line 165 of file ustr.cpp.

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

Definition at line 153 of file ustr.h.

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

Definition at line 149 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 243 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 252 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 56 of file ustr.h.

Definition at line 81 of file ustr.h.

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

Definition at line 80 of file ustr.h.

Length of the string.

Definition at line 61 of file ustr.h.

Internal string storage.

Definition at line 74 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 67 of file ustr.h.

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

Definition at line 46 of file ustr.h.


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


Generated on Sat Mar 23 2019 05:07:18 for ResidualVM by doxygen 1.7.1
curved edge   curved edge