Siena Fast Forwarding Documentation (v. 1.13.0)
Public Member Functions | Static Public Member Functions | List of all members
siena::string_t::iterator Class Reference

iterator type for string_t. More...

#include <types.h>

Public Member Functions

 iterator (const iterator &i)
 constructs an iterator which is the copy of the given one.
 
bool operator< (const iterator &i) const
 comparison operator for string iterators More...
 
bool operator<= (const iterator &i) const
 comparison operator for string iterators More...
 
bool operator> (const iterator &i) const
 comparison operator for string iterators More...
 
bool operator>= (const iterator &i) const
 comparison operator for string iterators More...
 
bool operator== (const iterator &i) const
 equality operator for string iterators More...
 
bool operator!= (const iterator &i) const
 inequality operator for string iterators More...
 
iteratoroperator= (const iterator &i)
 assignment operator for string iterators
 
const char & operator* () const
 dereferencing operator for string iterators More...
 
const char & operator[] (int n) const
 dereferencing operator for string iterators More...
 
iteratoroperator+= (int n)
 in-place addition operator for string iterators
 
iterator operator+ (int n) const
 addition operator for string iterators
 
iteratoroperator++ ()
 preincrement operator for string iterators
 
iterator operator++ (int)
 postincrement operator for string iterators
 
iteratoroperator-= (int n)
 in-place subtraction operator for string iterators
 
iterator operator- (int n) const
 subtraction operator for string iterators
 
int operator- (const iterator &i) const
 difference operator for string iterators More...
 
iteratoroperator-- ()
 predecrement operator for string iterators
 
iterator operator-- (int)
 postdecrement operator for string iterators
 
int at_end () const
 return whether the iterator points to the end of the string.
 
int index () const
 get the relative position of the iterator in the string. More...
 
void set_index (int index)
 set the relative position of the iterator in the string. More...
 

Static Public Member Functions

static iterator begin (const string_t &s)
 constructs an iterator pointing to the beginning of the given string.
 
static iterator end (const string_t &s)
 constructs an iterator pointing past the end of the given string.
 

Detailed Description

iterator type for string_t.

an iterator behaves like a pointer, and as such it can be dereferenced, incremented, compared, etc. However, iterators are also specialized for strings and provide a few utility methods, for example to retrieve the distance between an iterator and the start of its corresponding string_t, or to determine whether the end of the string has been reached.

string_ts are immutable strings, so this type implements a const iterator.

Member Function Documentation

int siena::string_t::iterator::index ( ) const
inline

get the relative position of the iterator in the string.

returns how many characters the iterator is far from the beginning of the string.

References siena::string_t::begin.

Referenced by set_index().

bool siena::string_t::iterator::operator!= ( const iterator i) const
inline

inequality operator for string iterators

returns false iff the LHS iterator points at the same place as the RHS.

const char& siena::string_t::iterator::operator* ( ) const
inline

dereferencing operator for string iterators

returns a const lvalue for the character pointed to by the iterator.

int siena::string_t::iterator::operator- ( const iterator i) const
inline

difference operator for string iterators

returns this->index () - i.index () if the two iterators belong to the same string; the result is otherwise undefined.

bool siena::string_t::iterator::operator< ( const iterator i) const
inline

comparison operator for string iterators

returns true if the LHS iterator points earlier than RHS in the same string; the return value is undefined if the iterators do not belong to the same string.

bool siena::string_t::iterator::operator<= ( const iterator i) const
inline

comparison operator for string iterators

returns true if the LHS iterator points no later than RHS in the same string; the return value is undefined if the iterators do not belong to the same string.

bool siena::string_t::iterator::operator== ( const iterator i) const
inline

equality operator for string iterators

returns true iff the LHS iterator points at the same place as the RHS.

bool siena::string_t::iterator::operator> ( const iterator i) const
inline

comparison operator for string iterators

returns true if the LHS iterator points later than RHS in the same string; the return value is undefined if the iterators do not belong to the same string.

bool siena::string_t::iterator::operator>= ( const iterator i) const
inline

comparison operator for string iterators

returns true if the LHS iterator points earlier than RHS in the same string; the return value is undefined if the iterators do not belong to the same string.

const char& siena::string_t::iterator::operator[] ( int  n) const
inline

dereferencing operator for string iterators

returns a const lvalue for the character pointed to by the iterator *this + n.

void siena::string_t::iterator::set_index ( int  index)
inline

set the relative position of the iterator in the string.

moves the iterator index characters past the beginning of the string.

References siena::string_t::begin, and index().