iterator type for string_t
.
More...
#include <types.h>
Public Member Functions | |
iterator (const iterator &i) throw () | |
constructs an iterator which is the copy of the given one. | |
bool | operator< (const iterator &i) const throw () |
comparison operator for string iterators | |
bool | operator<= (const iterator &i) const throw () |
comparison operator for string iterators | |
bool | operator> (const iterator &i) const throw () |
comparison operator for string iterators | |
bool | operator>= (const iterator &i) const throw () |
comparison operator for string iterators | |
bool | operator== (const iterator &i) const throw () |
equality operator for string iterators | |
bool | operator!= (const iterator &i) const throw () |
inequality operator for string iterators | |
iterator & | operator= (const iterator &i) throw () |
assignment operator for string iterators | |
const char & | operator* () const throw () |
dereferencing operator for string iterators | |
const char & | operator[] (int n) const throw () |
dereferencing operator for string iterators | |
iterator & | operator+= (int n) throw () |
in-place addition operator for string iterators | |
iterator | operator+ (int n) const throw () |
addition operator for string iterators | |
iterator & | operator++ () throw () |
preincrement operator for string iterators | |
iterator | operator++ (int) throw () |
postincrement operator for string iterators | |
iterator & | operator-= (int n) throw () |
in-place subtraction operator for string iterators | |
iterator | operator- (int n) const throw () |
subtraction operator for string iterators | |
int | operator- (const iterator &i) const throw () |
difference operator for string iterators | |
iterator & | operator-- () throw () |
predecrement operator for string iterators | |
iterator | operator-- (int) throw () |
postdecrement operator for string iterators | |
int | at_end () const throw () |
return whether the iterator points to the end of the string. | |
int | index () const throw () |
get the relative position of the iterator in the string. | |
void | set_index (int index) throw () |
set the relative position of the iterator in the string. | |
Static Public Member Functions | |
static iterator | begin (const string_t &s) throw () |
constructs an iterator pointing to the beginning of the given string. | |
static iterator | end (const string_t &s) throw () |
constructs an iterator pointing past the end of the given string. |
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_t
s are immutable strings, so this type implements a const
iterator.
int siena::string_t::iterator::index | ( | ) | const throw () [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 throw () [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 throw () [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 throw () [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 throw () [inline] |
bool siena::string_t::iterator::operator<= | ( | const iterator & | i | ) | const throw () [inline] |
bool siena::string_t::iterator::operator== | ( | const iterator & | i | ) | const throw () [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 throw () [inline] |
bool siena::string_t::iterator::operator>= | ( | const iterator & | i | ) | const throw () [inline] |
const char& siena::string_t::iterator::operator[] | ( | int | n | ) | const throw () [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 | ) | throw () [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().