WoopsiUI::WoopsiString Class Reference

#include <woopsistring.h>

Inheritance diagram for WoopsiUI::WoopsiString:
WoopsiUI::Text

List of all members.

Public Member Functions

 WoopsiString ()
 WoopsiString (const char *text)
 WoopsiString (const char letter)
virtual const char * getCharArray () const
virtual void setText (const char *text)
virtual void setText (const char text)
virtual void append (const char *text)
virtual void append (const char text)
virtual void insert (const char *text, const u32 index)
virtual void insert (const char text, const u32 index)
virtual void remove (const u32 startIndex)
virtual void remove (const u32 startIndex, const u32 count)
virtual const u32 getLength () const
 WoopsiString (const WoopsiString &string)
virtual ~WoopsiString ()
char & operator[] (const u32 index) const
virtual const char getCharAt (u32 index)

Protected Member Functions

virtual void allocateMemory (u32 chars, bool preserve)
virtual bool hasData () const
virtual u32 getAllocatedSize ()

Protected Attributes

char * _text

Detailed Description

Yet another string class. Where possible, the string avoids allocating memory each time the string grows or shrinks. This means that the string may consume more memory than the number of chars would seem to dictate if the object previously contained a large string that has subsequently been truncated. It also means that increasing the length of such a string is a cheaper operation as memory does not need to allocated and copied.

Additionally, the string increases its array size by _growAmount every time it needs to allocate extra memory, potentially reducing the number of reallocs needed.


Constructor & Destructor Documentation

WoopsiString::WoopsiString (  ) 

Constructor to create a blank object.

WoopsiString::WoopsiString ( const char *  text  ) 

Constructor to create a string from a char array.

Parameters:
text Pointer to a char array to use as the basis of the string.
WoopsiString::WoopsiString ( const char  letter  ) 

Constructor to create a string from a single character.

Parameters:
letter Single character to use as the basis of the string.
WoopsiUI::WoopsiString::WoopsiString ( const WoopsiString string  )  [inline]

Copy constructor.

Parameters:
string WoopsiString object to create a copy of.
virtual WoopsiUI::WoopsiString::~WoopsiString (  )  [inline, virtual]

Destructor.


Member Function Documentation

void WoopsiString::allocateMemory ( u32  chars,
bool  preserve 
) [protected, virtual]

Allocate memory for the string.

Parameters:
chars Number of chars to allocate.
preserve If true, the data in the existing memory will be preserved if new memory must be allocated
void WoopsiString::append ( const char  text  )  [virtual]

Append text to the end of the string.

Parameters:
text Char to append.

Reimplemented in WoopsiUI::Text.

void WoopsiString::append ( const char *  text  )  [virtual]

Append text to the end of the string.

Parameters:
text String to append.

Reimplemented in WoopsiUI::Text.

virtual u32 WoopsiUI::WoopsiString::getAllocatedSize (  )  [inline, protected, virtual]

Get the amount of allocated memory.

Returns:
The number of chars allocated in RAM.
virtual const char* WoopsiUI::WoopsiString::getCharArray (  )  const [inline, virtual]

Returns a pointer to the raw char array data.

Returns:
Pointer to the char array.
virtual const char WoopsiUI::WoopsiString::getCharAt ( u32  index  )  [inline, virtual]

Get the character at the specified index.

Parameters:
index The index of the character to retrieve.
Returns:
The character at the specified index.
virtual const u32 WoopsiUI::WoopsiString::getLength (  )  const [inline, virtual]

Get the length of the string in characters.

Returns:
The length of the string.
virtual bool WoopsiUI::WoopsiString::hasData (  )  const [inline, protected, virtual]

Check if we've got any string data stored or not.

Returns:
True if the string contains any data; false if no data has yet been supplied.
void WoopsiString::insert ( const char  text,
const u32  index 
) [virtual]

Insert text at the specified character index.

Parameters:
text Char to insert
index The index at which to insert the char.

Reimplemented in WoopsiUI::Text.

void WoopsiString::insert ( const char *  text,
const u32  index 
) [virtual]

Insert text at the specified character index.

Parameters:
text The text to insert.
index The index at which to insert the text.

Reimplemented in WoopsiUI::Text.

char& WoopsiUI::WoopsiString::operator[] ( const u32  index  )  const [inline]

Overload the [] operator to allow array-style access.

Parameters:
index The index to retrieve.
Returns:
The char at the specified index.
void WoopsiString::remove ( const u32  startIndex,
const u32  count 
) [virtual]

Remove specified number of characters from the string from the start index onwards.

Parameters:
startIndex Index to remove from.
count Number of characters to remove.

Reimplemented in WoopsiUI::Text.

void WoopsiString::remove ( const u32  startIndex  )  [virtual]

Remove all characters from the string from the start index onwards.

Parameters:
startIndex Index to remove from.

Reimplemented in WoopsiUI::Text.

void WoopsiString::setText ( const char  text  )  [virtual]

Set the text in the string.

Parameters:
text Character to to use as the new data for this string.

Reimplemented in WoopsiUI::Text.

void WoopsiString::setText ( const char *  text  )  [virtual]

Set the text in the string.

Parameters:
text Char array to use as the new data for this string.

Reimplemented in WoopsiUI::Text.


Member Data Documentation

char* WoopsiUI::WoopsiString::_text [protected]

Raw char array data


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Enumerator

Generated on Sat Oct 24 14:33:12 2009 for Woopsi by  doxygen 1.6.1