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

#include <ipebase.h>

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.

Referenced by left(), right(), and substr().

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.

References size().

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
bool ipe::String::isEmpty ( ) const
inline
const char* ipe::String::data ( ) const
inline
int ipe::String::size ( ) const
inline
void ipe::String::operator+= ( const String rhs)
inline

Operator syntax for append.

References append().

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

Operator syntax for append.

References append().

String ipe::String::substr ( int  i,
int  len = -1 
) const
inline
String ipe::String::left ( int  i) const
inline
String String::right ( int  i) const

Create substring at the right.

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

References size(), and String().

Referenced by ipe::Document::formatFromFilename(), and ipe::Platform::latexDirectory().

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.

References size().

Referenced by ipe::Painter::dashStyle(), ipe::CairoPainter::doDrawText(), ipe::Reference::flagsFromName(), ipe::Document::runLatex(), and ipe::StyleSheet::saveAsXml().

int String::rfind ( char  ch) const

Return index of last occurrence of ch.

Return -1 if character does not appear.

References size().

Referenced by ipe::Reference::flagsFromName().

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

Return index of first occurrence of rhs.

Return -1 if not substring is not present.

References size().

void String::erase ( )

Make string empty.

Referenced by ipe::PdfParser::getToken().

void String::append ( const String rhs)

Append rhs to this string.

References size().

Referenced by ipe::PdfParser::getToken(), operator+(), operator+=(), and ipe::Platform::readFile().

void String::append ( char  ch)

Append ch to this string.

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

Equality operator (bytewise comparison).

References size().

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

Inequality operator (bytewise comparison).

References size().

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

Concatenate this string with rhs.

References append().

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.

Referenced by ipe::Latex::createLatexSource().

const char * String::z ( ) const

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