Ipelib

ipe::String Class Reference

Strings and buffers. More...

#include <ipebase.h>

List of all members.

Classes

Public Member Functions


Detailed Description

Strings and buffers.

String is is an implicitly shared byte string. It is designed to be efficient for strings of arbitrary length, and supposed to be passed by value (the size of String is a single pointer). Sharing is implicit---the string creates its own representation as soon as it is modified.

String can be used for binary data. For text, it is usually assumed that the string is UTF-8 encoded, but only the unicode member function actually requires this. In particular, all indices into the string are byte indices, not Unicode character indices.


Constructor & Destructor Documentation

String::String ( )

Construct an empty string.

String::String ( const char *  str)

Construct a string by making copy of str.

String::String ( const String rhs)

Copy constructor. This only copies the reference and takes constant time.

String::String ( const String rhs,
int  index,
int  len 
)

Construct a substring.

index must be >= 0. len can be negative or too large to return entire string.

String::~String ( )

Destruct string if reference count has reached zero.


Member Function Documentation

String & String::operator= ( const String rhs)

Assignment takes constant time.

char ipe::String::operator[] ( int  i) const [inline]

Return character at index i.

bool ipe::String::empty ( ) const [inline]

Is the string empty?

bool ipe::String::isEmpty ( ) const [inline]

Is the string empty?

const char* ipe::String::data ( ) const [inline]

Return read-only pointer to the data.

int ipe::String::size ( ) const [inline]

Return number of bytes in the string.

void ipe::String::operator+= ( const String rhs) [inline]

Operator syntax for append.

void ipe::String::operator+= ( char  ch) [inline]

Operator syntax for append.

String ipe::String::substr ( int  i,
int  len = -1 
) const [inline]

Create substring.

String ipe::String::left ( int  i) const [inline]

Create substring at the left.

String String::right ( int  i) const

Create substring at the right.

Returns the entire string if i is larger than its length.

bool ipe::String::operator!= ( const String rhs) const [inline]

Operator !=.

int String::find ( char  ch) const

Return index of first occurrence of ch.

Return -1 if character does not appear.

int String::rfind ( char  ch) const

Return index of last occurrence of ch.

Return -1 if character does not appear.

int String::find ( const char *  rhs) const

Return index of first occurrence of rhs.

Return -1 if not substring is not present.

void String::erase ( )

Make string empty.

void String::append ( const String rhs)

Append rhs to this string.

void String::append ( char  ch)

Append ch to this string.

bool String::operator== ( const String rhs) const

Equality operator (bytewise comparison).

bool String::operator< ( const String rhs) const

Inequality operator (bytewise comparison).

String String::operator+ ( const String rhs) const

Concatenate this string with rhs.

int String::unicode ( int &  index) const

Return Unicode value from UTF-8 string.

The index is incremented to the next UTF-8 character. This returns 0xfffd if there is any problem in parsing UTF-8.

const char * String::z ( ) const

Return a C style string with final zero byte.


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