Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

c4_Cursor Class Reference

An iterator for collections of rows (views). More...

List of all members.

Public Member Functions

 c4_Cursor (c4_Sequence &, int)
 Construct a new cursor.
c4_RowRef operator * () const
 Dereference this cursor to "almost" a row.
c4_RowRef operator[] (int) const
 This is the same as *(cursor + offset).
c4_Cursoroperator++ ()
 Pre-increment the cursor.
c4_Cursor operator++ (int)
 Post-increment the cursor.
ref= args=<()> --> c4_Cursoroperator-- ()
 Pre-decrement the cursor.
ref= args=<(int)> --> c4_Cursor operator-- (int)
 Post-decrement the cursor.
c4_Cursoroperator+= (int)
 Advance by a given offset.
c4_Cursoroperator-= (int)
 Back up by a given offset.
c4_Cursor operator- (int) const
 Subtract a specified offset.
int operator- (c4_Cursor) const
 Return the distance between two cursors.

Public Attributes

c4_Sequence_seq
 Pointer to the sequence.
int _index
 Current index into the sequence.

Friends

c4_Cursor operator+ (c4_Cursor, int)
 Add specified offset.
c4_Cursor operator+ (int, c4_Cursor)
 Add specified offset to cursor.
bool operator== (c4_Cursor, c4_Cursor)
 Return true if both cursors are equal.
bool operator!= (c4_Cursor, c4_Cursor)
 Return true if both cursors are not equal.
bool operator< (c4_Cursor, c4_Cursor)
 True if first cursor is less than second cursor.
bool operator> (c4_Cursor, c4_Cursor)
 True if first cursor is greater than second cursor.
bool operator<= (c4_Cursor, c4_Cursor)
 True if first cursor is less or equal to second cursor.
bool operator>= (c4_Cursor, c4_Cursor)
 True if first cursor is greater or equal to second cursor.
bool operator== (const c4_RowRef &, const c4_RowRef &)
 Return true if the contents of both rows are equal.
bool operator!= (const c4_RowRef &, const c4_RowRef &)
 Return true if the contents of both rows are not equal.
bool operator< (const c4_RowRef &, const c4_RowRef &)
 True if first row is less than second row.
bool operator> (const c4_RowRef &, const c4_RowRef &)
 True if first row is greater than second row.
bool operator<= (const c4_RowRef &, const c4_RowRef &)
 True if first row is less or equal to second row.
bool operator>= (const c4_RowRef &, const c4_RowRef &)
 True if first row is greater or equal to second row.


Detailed Description

An iterator for collections of rows (views).

Cursor objects can be used to point to specific entries in a view. A cursor acts very much like a pointer to a row in a view, and is returned when taking the address of a c4_RowRef. Dereferencing a cursor leads to the original row reference again. You can construct a cursor for a c4_Row, but since such rows are not part of a collection, incrementing or decrementing these cursors is meaningless (and wrong).

The usual range of pointer operations can be applied to these objects: pre/post-increment and decrement, adding or subtracting integer offsets, as well as the full range of comparison operators. If two cursors point to entries in the same view, their difference can be calculated.

As with regular pointers, care must be taken to avoid running off of either end of a view (the debug build includes assertions to check this).


Constructor & Destructor Documentation

c4_Cursor::c4_Cursor c4_Sequence seq_,
int  index_
[inline]
 

Construct a new cursor.

Cursor cannot be created without an underlying view, but you could define a global "nullView" object and then initialize the cursor with "&nullView[0]". This works because cursors need not point to a valid row.


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

Metakit C++ API Reference - https://www.equi4.com/metakit.html - extracted with Doxygen