Logo Search packages:      
Sourcecode: scummvm version File versions  Download package

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes

Common::String Class Reference

#include <str.h>

Collaboration diagram for Common::String:
Collaboration graph
[legend]

List of all members.

Public Types

typedef const char * const_iterator
typedef char * iterator

Public Member Functions

iterator begin ()
const_iterator begin () const
const char * c_str () const
void clear ()
int compareTo (const String &x) const
int compareTo (const char *x) const
int compareToIgnoreCase (const String &x) const
int compareToIgnoreCase (const char *x) const
bool contains (const String &x) const
bool contains (const char *x) const
bool contains (char x) const
void deleteChar (uint32 p)
void deleteLastChar ()
bool empty () const
iterator end ()
const_iterator end () const
bool equals (const String &x) const
bool equals (const char *x) const
bool equalsIgnoreCase (const String &x) const
bool equalsIgnoreCase (const char *x) const
uint hash () const
bool hasPrefix (const String &x) const
bool hasPrefix (const char *x) const
bool hasSuffix (const String &x) const
bool hasSuffix (const char *x) const
void insertChar (char c, uint32 p)
char lastChar () const
bool matchString (const char *pat, bool ignoreCase=false, bool pathMode=false) const
bool matchString (const String &pat, bool ignoreCase=false, bool pathMode=false) const
bool operator!= (const String &x) const
bool operator!= (const char *x) const
Stringoperator+= (const char *str)
Stringoperator+= (const String &str)
Stringoperator+= (char c)
bool operator< (const String &x) const
bool operator<= (const String &x) const
Stringoperator= (const char *str)
Stringoperator= (char c)
Stringoperator= (const String &str)
bool operator== (const String &x) const
bool operator== (const char *x) const
bool operator> (const String &x) const
bool operator>= (const String &x) const
char operator[] (int idx) const
void setChar (char c, uint32 p)
uint size () const
 String (const char *str)
 String (const String &str)
 String (const char *beginP, const char *endP)
 String (const char *str, uint32 len)
 String ()
 String (char c)
void toLowercase ()
void toUppercase ()
void trim ()

Static Public Member Functions

static Common::String printf (const char *fmt,...) GCC_PRINTF(1

Protected Member Functions

void decRefCount (int *oldRefCount)
void ensureCapacity (uint32 new_size, bool keep_old)
void incRefCount () const
void initWithCStr (const char *str, uint32 len)
bool isStorageIntern () const
void makeUnique ()

Protected Attributes

union {
   struct {
      uint32   _capacity
      int *   _refCount
   }   _extern
   char   _storage [_builtinCapacity]
}; 
uint32 _size
char * _str

Static Protected Attributes

static const uint32 _builtinCapacity = 32 - sizeof(uint32) - sizeof(char *)

Detailed Description

Simple string class for ScummVM. Provides automatic storage managment, and overloads several operators in a 'natural' fashion, mimicking the std::string class. Even provides simple iterators.

This class tries to avoid allocating lots of small blocks on the heap, since that is inefficient on several platforms supported by ScummVM. Instead, small strings are stored 'inside' the string object (i.e. on the stack, for stack allocated objects), and only for strings exceeding a certain length do we allocate a buffer on the heap.

The presence of \0 characters in the string will cause undefined behaviour in some operations.

Definition at line 46 of file str.h.


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

Generated by  Doxygen 1.6.0   Back to index