Ipelib
ipe::String Class Reference

#include <ipebase.h>

Public Member Functions

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

Static Public Member Functions

static String withData (char *data, int len=0) noexcept

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() [1/5]

String::String ( )
noexcept

◆ String() [2/5]

String::String ( const char * str)
noexcept

Construct a string by making copy of str.

◆ String() [3/5]

String::String ( const char * str,
int len )
noexcept

Construct string by making copy of str with given len.

◆ String() [4/5]

String::String ( const String & rhs)
noexcept

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

References String().

◆ String() [5/5]

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

Construct a substring.

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

References String().

◆ ~String()

String::~String ( )
noexcept

Destruct string if reference count has reached zero.

Member Function Documentation

◆ operator=()

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

Assignment takes constant time.

References String().

◆ withData()

String String::withData ( char * data,
int len = 0 )
staticnoexcept

Construct string by taking ownership of given data.

References data(), and String().

◆ operator[]()

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

Return character at index i.

◆ empty()

◆ data()

◆ size()

◆ operator+=() [1/3]

void ipe::String::operator+= ( const String & rhs)
inlinenoexcept

Operator syntax for append.

References append(), and String().

◆ operator+=() [2/3]

void ipe::String::operator+= ( const char * rhs)
inlinenoexcept

Operator syntax for append.

References append().

◆ operator+=() [3/3]

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

Operator syntax for append.

References append().

◆ substr()

◆ left()

◆ right()

String String::right ( int i) const
noexcept

Create substring at the right.

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

References ipe::size(), and String().

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

◆ operator!=() [1/2]

bool ipe::String::operator!= ( const String & rhs) const
inlinenoexcept

Operator !=.

References String().

◆ operator!=() [2/2]

bool ipe::String::operator!= ( const char * rhs) const
inlinenoexcept

Operator !=.

◆ find() [1/2]

int String::find ( char ch) const
noexcept

◆ rfind()

int String::rfind ( char ch) const
noexcept

Return index of last occurrence of ch.

Return -1 if character does not appear.

References ipe::size().

◆ find() [2/2]

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

Return index of first occurrence of rhs.

Return -1 if not substring is not present.

References ipe::size().

◆ erase()

void String::erase ( )
noexcept

Make string empty.

◆ append() [1/3]

void String::append ( const String & rhs)
noexcept

Append rhs to this string.

References String().

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

◆ append() [2/3]

void String::append ( const char * rhs)
noexcept

Append rhs to this string.

◆ append() [3/3]

void String::append ( char ch)
noexcept

Append ch to this string.

◆ appendUtf8()

void String::appendUtf8 ( uint16_t ch)
noexcept

Append a single unicode character ch in UTF-8 encoding.

References append().

Referenced by ipe::PdfString::decode().

◆ hasPrefix()

bool String::hasPrefix ( const char * rhs) const
noexcept

Does string start with this prefix? (bytewise comparison)

References ipe::size().

Referenced by ipe::Attribute::isMidArrow(), and ipe::Document::runLatexAsync().

◆ operator==() [1/2]

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

Equality operator (bytewise comparison).

References ipe::size(), size(), and String().

◆ operator==() [2/2]

bool String::operator== ( const char * rhs) const
noexcept

Equality operator (bytewise comparison).

References ipe::size().

◆ operator<()

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

Inequality operator (bytewise comparison).

References ipe::size(), and String().

◆ operator+()

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

Concatenate this string with rhs.

References append(), and String().

◆ unicode()

int String::unicode ( int & index) const
noexcept

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.

◆ getLine()

String String::getLine ( int & index) const
noexcept

Return line starting at position index. Index is updated to point to next line.

References ipe::size(), String(), and substr().

◆ z()


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