MAUtil::String Class Reference

#include <MAUtil/String.h>

List of all members.


Detailed Description

A dynamic, reference-counted string that behaves much like a subset of std::string.

Each String references an instance of StringData, and these instances are shared between strings as much as possible by using the copy-on-write idiom.


Public Types

enum  { npos = -1 }

Public Member Functions

 String ()
 String (int capacity)
 String (const char *text)
 String (const char *text, int len)
 String (const String &s)
const char * c_str () const
Stringoperator= (const String &other)
char & operator[] (int index)
const char & operator[] (int index) const
bool operator== (const String &other) const
bool operator!= (const String &other) const
bool operator< (const String &other) const
bool operator> (const String &other) const
bool operator<= (const String &other) const
bool operator>= (const String &other) const
String operator+ (const String &other) const
Stringoperator+= (const String &other)
String operator+ (char c) const
Stringoperator+= (char c)
int find (const String &s, unsigned int offset=0) const
int findLastOf (const char findThis) const
int findFirstOf (const char findThis, int position=0) const
int findFirstNotOf (const char findNotThis, int position=0) const
void insert (int position, const String &other)
void insert (int position, char c)
void remove (int position, int number)
String substr (int startIndex, int length=npos) const
int size () const
int capacity () const
int length () const
void resize (int newSize)
void reserve (int newSize)
void clear ()
void append (const char *other, int len)
void setData (StringData *data)
char * pointer ()
 ~String ()

Protected Member Functions

void allocStringData (const char *text, int len)

Protected Attributes

StringDatasd


Member Enumeration Documentation

anonymous enum
 

Enumerator:
npos 


Constructor & Destructor Documentation

MAUtil::String::String  ) 
 

Initializes the new string with shared empty data.

MAUtil::String::String int  capacity  )  [explicit]
 

Initializes the string with empty data and the given capacity.

MAUtil::String::String const char *  text  ) 
 

Copies the specified C string into the new string.

MAUtil::String::String const char *  text,
int  len
 

Copies len bytes of the C string text into the new string.

MAUtil::String::String const String s  ) 
 

Makes the new string share the data of s.

MAUtil::String::~String  ) 
 


Member Function Documentation

const char* MAUtil::String::c_str  )  const
 

Returns a pointer to the null-terminated character data. This pointer becomes invalid as soon as non-const medthod of this class is called.

String& MAUtil::String::operator= const String other  ) 
 

Makes this string share the other string's data.

char& MAUtil::String::operator[] int  index  ) 
 

Returns a reference to the character at position index.

const char& MAUtil::String::operator[] int  index  )  const
 

Returns a const reference to the character at position index.

bool MAUtil::String::operator== const String other  )  const
 

Returns true if the strings are equal, false otherwise.

bool MAUtil::String::operator!= const String other  )  const
 

Returns false if the strings are equal, true otherwise.

bool MAUtil::String::operator< const String other  )  const
 

Returns true if this is lexiographically less than other, false otherwise.

bool MAUtil::String::operator> const String other  )  const
 

Returns true if this is lexiographically greater than other, false otherwise.

bool MAUtil::String::operator<= const String other  )  const
 

Returns true if this is lexiographically less than or equal to other, false otherwise.

bool MAUtil::String::operator>= const String other  )  const
 

Returns true if this is lexiographically greater than or equal to other, false otherwise.

String MAUtil::String::operator+ const String other  )  const
 

Returns a copy of this string concatenated with the other.

String& MAUtil::String::operator+= const String other  ) 
 

Concatenates a string in-place with other and returns a reference to itself.

String MAUtil::String::operator+ char  c  )  const
 

Returns a copy of this string concatenated with the c.

String& MAUtil::String::operator+= char  c  ) 
 

Concatenates a string in-place with c and returns a reference to itself.

int MAUtil::String::find const String s,
unsigned int  offset = 0
const
 

Returns the index of the first instance of the given string inside this string, starting at the given position. Returns npos if not found.

int MAUtil::String::findLastOf const char  findThis  )  const
 

Returns the last index of the given character. Returns npos if not found.

int MAUtil::String::findFirstOf const char  findThis,
int  position = 0
const
 

Returns the first index of the given character starting at the given position. Returns npos if not found.

int MAUtil::String::findFirstNotOf const char  findNotThis,
int  position = 0
const
 

Returns the first index _not_ matching the given character, starting at the given position. Returns npos if not found.

void MAUtil::String::insert int  position,
const String other
 

Inserts the given string at the given position.

void MAUtil::String::insert int  position,
char  c
 

Inserts the given character at the given position.

void MAUtil::String::remove int  position,
int  number
 

Removes the given number of characters starting at the given position.

String MAUtil::String::substr int  startIndex,
int  length = npos
const
 

Returns a new string that is a copy of the specified portion of this string.

int MAUtil::String::size  )  const
 

Returns the number of characters in the string.

int MAUtil::String::capacity  )  const
 

Returns the size of the reserved space in the string data object.

int MAUtil::String::length  )  const
 

Returns the number of characters in the string.

void MAUtil::String::resize int  newSize  ) 
 

Resizes the string. Any new characters are undefined.

void MAUtil::String::reserve int  newSize  ) 
 

Reserves space in the string data object.

void MAUtil::String::clear  ) 
 

Resizes the string to zero.

void MAUtil::String::append const char *  other,
int  len
 

Appends a string at the end of the string.

void MAUtil::String::setData StringData data  ) 
 

Replaces this string's data object.

char* MAUtil::String::pointer  ) 
 

Returns a pointer to the string data. The pointer becomes invalidated by any non-const method of this class.

void MAUtil::String::allocStringData const char *  text,
int  len
[protected]
 


Member Data Documentation

StringData* MAUtil::String::sd [protected]
 

A pointer to the string data object shared by this string.


Generated on Sat Feb 13 00:15:40 2010 for MoSync 2 beta 1 by  doxygen 1.4.6-NO