Ipelib: IpeString class Reference

Main Page | Modules | Class Hierarchy | Class List | Class Members

# IpeString Class Reference
[Ipe Base]

Strings and buffers. More...

List of all members.

## Public Member Functions

- IpeString (const char *str)
- IpeString (const IpeString &rhs)
- IpeString (const IpeString &rhs, int index, int len)
- IpeString & operator= (const IpeString &rhs)
- char operator[] (int i) const
- bool empty () const
- const char * data () const
- int size () const
- void operator+= (const IpeString &rhs)
- void operator+= (char ch)
- IpeString substr (int i, int len=-1) const
- bool operator!= (const IpeString &rhs) const
- void erase ()
- void append (const IpeString &rhs)
- void append (char ch)
- bool operator== (const IpeString &rhs) const
- bool operator< (const IpeString &rhs) const
- IpeString operator+ (const IpeString &rhs) const
- int unicode (int &index) const
- const char * CString () const

## Detailed Description

Strings and buffers.

IpeString 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 IpeString is a single pointer). Sharing is implicit---the string creates its own representation as soon as it is modified.

IpeString 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.

Ipe is not using the STL string type because the C++ standard does neither guarantee that passing by value is efficient, nor that std::string is efficient for very long strings (although in practice that is probably true). However, IpeString is designed to be plug-in compatible with std::string, so Ipe can switch any time it is deemed appropriate (in particular, unlike the rest of Ipe, IpeString uses lower-case member names!).

## Member Function Documentation

char IpeString::operator[] | ( | int | i | ) | const`[inline]`

| Return character at index i.

bool IpeString::empty | ( |  | ) | const`[inline]`

| Is the string empty?

const char* IpeString::data | ( |  | ) | const`[inline]`

| Return read-only pointer to the data.

int IpeString::size | ( |  | ) | const`[inline]`

| Return number of bytes in the string.

void IpeString::operator+= | ( | const IpeString & | rhs | ) | `[inline]`

| Operator syntax for append.

void IpeString::operator+= | ( | char | ch | ) | `[inline]`

| Operator syntax for append.

IpeString IpeString::substr | ( | int | i,
|  | int | len = -1
| ) | const`[inline]`

| Create substring.

bool IpeString::operator!= | ( | const IpeString & | rhs | ) | const`[inline]`

| Operator !=.

int IpeString::unicode | ( | int & | index | ) | const

| Return Unicode value from UTF-8 string. The index is incremented to the next UTF-8 character.

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

- ipebase.h
- ipebase.cpp