Ipelib: ipe::String Class Reference

Ipelib

- Main Page
- Related Pages
- Modules
- Classes

- Class List
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Static Public Member Functions | List of all members
ipe::String Class Reference
Ipe Base

`#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
String & | operator= (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
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::String | ( |  | ) |
| noexcept

Construct an empty string.

Referenced by right(), and ipe::Platform::runLatex().

String::String | ( | const char * | str | ) |
| noexcept

Construct a string by making copy of str.

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

Construct string by making copy of str with given len.

String::String | ( | const String & | rhs | ) |
| noexcept

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

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.

String::~String | ( |  | ) |
| noexcept

Destruct string if reference count has reached zero.

## Member Function Documentation

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

Assignment takes constant time.

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

Construct string by taking ownership of given data.

References data().

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

Return character at index i.

bool ipe::String::empty | ( |  | ) | const
| inlinenoexcept

Is the string empty?

Referenced by ipe::Latex::addPageNumber(), ipe::PdfWriter::createBookmarks(), ipe::Latex::createLatexSource(), ipe::PdfWriter::createPageView(), ipe::PdfWriter::createTrailer(), ipe::Platform::libVersion(), ipe::Attribute::makeColor(), ipe::Attribute::makeDashStyle(), ipe::Attribute::makeScalar(), ipe::Attribute::makeTextSize(), ipe::XmlParser::parseAttributes(), ipe::ImlParser::parseObject(), ipe::ImlParser::parsePage(), ipe::ImlParser::parseStyle(), ipe::Document::runLatex(), ipe::Platform::runLatex(), ipe::Page::saveAsXml(), ipe::Group::saveAsXml(), ipe::Object::saveAttributesAsXml(), and ipe::Repository::toIndex().

const char* ipe::String::data | ( |  | ) | const
| inlinenoexcept

Return read-only pointer to the data.

Referenced by ipe::Bitmap::Bitmap(), ipe::Buffer::Buffer(), ipe::PdfWriter::createPageView(), ipe::PdfWriter::createXmlStream(), ipe::PdfPainter::doDrawSymbol(), ipe::PdfDict::inflate(), ipe::Bitmap::readJpeg(), withData(), and z().

int ipe::String::size | ( |  | ) | const
| inlinenoexcept

Return number of bytes in the string.

Referenced by ipe::Bitmap::Bitmap(), ipe::Buffer::Buffer(), ipe::Latex::createLatexSource(), ipe::PdfWriter::createPageView(), ipe::PdfWriter::createXmlStream(), ipe::PdfPainter::doDrawSymbol(), ipe::CairoPainter::doDrawText(), find(), ipe::Reference::flagsFromName(), ipe::Document::formatFromFilename(), ipe::Lex::getFixed(), getLine(), hasPrefix(), ipe::PdfDict::inflate(), ipe::Platform::latexDirectory(), ipe::Platform::libVersion(), operator<(), operator==(), ipe::XmlParser::parsePCDATA(), ipe::XmlParser::parseToTag(), ipe::Stream::putRaw(), ipe::StringStream::putRaw(), ipe::FileStream::putRaw(), ipe::Stream::putString(), ipe::FileStream::putString(), ipe::Stream::putXmlString(), ipe::Bitmap::readJpeg(), rfind(), right(), ipe::Path::saveAsXml(), ipe::Lex::skipWhitespace(), and ipe::Text::Text().

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

Operator syntax for append.

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

Operator syntax for append.

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

Operator syntax for append.

String ipe::String::substr | ( | int | i,
|  | int | len = `-1`
| ) |  | const
| inlinenoexcept

Create substring.

Referenced by ipe::Latex::createLatexSource(), ipe::Painter::dashStyle(), ipe::Document::fileFormat(), ipe::Reference::flagsFromName(), ipe::Document::formatFromFilename(), ipe::Lex::getFixed(), getLine(), ipe::PdfParser::getObject(), ipe::Document::runLatex(), ipe::Platform::runLatex(), ipe::Path::saveAsXml(), ipe::StyleSheet::saveAsXml(), and ipe::Text::Text().

String ipe::String::left | ( | int | i | ) | const
| inlinenoexcept

Create substring at the left.

Referenced by ipe::Platform::currentDirectory(), ipe::CairoPainter::doDrawText(), ipe::Reference::flagsFromName(), ipe::Platform::latexDirectory(), ipe::Document::runLatex(), and ipe::PdfWriter::~PdfWriter().

String String::right | ( | int | i | ) | const
| noexcept

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
| inlinenoexcept

Operator !=.

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

Operator !=.

int String::find | ( | char | ch | ) | const
| noexcept

Return index of first occurrence of ch.

Return -1 if character does not appear.

References size().

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

int String::rfind | ( | char | ch | ) | const
| noexcept

Return index of last occurrence of ch.

Return -1 if character does not appear.

References size().

Referenced by ipe::Platform::currentDirectory(), and ipe::Reference::flagsFromName().

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

Return index of first occurrence of rhs.

Return -1 if not substring is not present.

References size().

void String::erase | ( |  | ) |
| noexcept

Make string empty.

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

Append rhs to this string.

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

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

Append rhs to this string.

void String::append | ( | char | ch | ) |
| noexcept

Append ch to this string.

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

Does string start with this prefix? (bytewise comparison)

References size().

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

Equality operator (bytewise comparison).

References size().

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

Equality operator (bytewise comparison).

References size().

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

Inequality operator (bytewise comparison).

References size().

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

Concatenate this string with rhs.

References append().

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.

References ipe::Fixed::fromInternal(), and ipe::Fixed::mult().

Referenced by ipe::PdfWriter::createXmlStream().

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

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

References size(), and substr().

Referenced by ipe::Platform::libVersion().

const char * String::z | ( |  | ) | const
| noexcept

Return a C style string with final zero byte.

References data().

Referenced by ipe::PdfResources::collect(), ipe::Platform::currentDirectory(), ipe::CairoPainter::doDrawText(), ipe::Face::Face(), ipe::Platform::fileExists(), ipe::Lex::getFixed(), ipe::Lex::getHexNumber(), ipe::Lex::getInt(), ipe::Platform::latexDirectory(), ipe::Platform::libVersion(), ipe::Platform::listDirectory(), ipe::PageSelector::PageSelector(), ipe::PdfFile::parse(), ipe::QIpe(), ipe::Platform::readFile(), ipe::Document::runLatex(), ipe::Platform::runLatex(), ipe::Platform::toDouble(), ipe::Latex::updateTextObjects(), and ipe::PdfWriter::~PdfWriter().

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

- ipebase.h
- ipebase.cpp