Ipelib
Classes | Public Member Functions | List of all members
ipe::String Class Reference

#include <ipebase.h>

Classes

struct  Imp

Public Member Functions

 String ()
 String (const char *str)
 String (const String &rhs)
 String (const String &rhs, int index, int len)
Stringoperator= (const String &rhs)
 ~String ()
char operator[] (int i) const
bool empty () const
bool isEmpty () const
const char * data () const
int size () const
void operator+= (const String &rhs)
void operator+= (char ch)
String substr (int i, int len=-1) const
String left (int i) const
String right (int i) const
bool operator!= (const String &rhs) const
int find (char ch) const
int rfind (char ch) const
int find (const char *rhs) const
void erase ()
void append (const String &rhs)
void append (char ch)
bool operator== (const String &rhs) const
bool operator< (const String &rhs) const
String operator+ (const String &rhs) const
int unicode (int &index) const
const char * z () const

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: