libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx::const_result_iterator Class Reference

Iterator for rows (tuples) in a result. Use as result::const_iterator. More...

#include <result.hxx>

Inheritance diagram for pqxx::const_result_iterator:
Collaboration diagram for pqxx::const_result_iterator:

Public Types

typedef const_tuple_iterator const_iterator
 
typedef
const_reverse_tuple_iterator 
const_reverse_iterator
 
typedef result::difference_type difference_type
 
typedef const_iterator iterator
 
typedef const tuplepointer
 
typedef tuple reference
 
typedef const_reverse_iterator reverse_iterator
 
typedef result::size_type size_type
 

Public Member Functions

 const_result_iterator () throw ()
 
 const_result_iterator (const tuple &t) throw ()
 
const_iterator begin () const throw ()
 
bool PQXX_PURE empty () const throw ()
 
const_iterator end () const throw ()
 
size_t num () const
 
size_t rownumber () const throw ()
 
size_type size () const throw ()
 
tuple slice (size_type Begin, size_type End) const
 Produce a slice of this tuple, containing the given range of columns. More...
 
void swap (tuple &) throw ()
 
Dereferencing operators
pointer operator-> () const
 The iterator "points to" its own tuple, which is also itself. More...
 
reference operator* () const
 
Manipulations
const_result_iterator operator++ (int)
 
const_result_iteratoroperator++ ()
 
const_result_iterator operator-- (int)
 
const_result_iteratoroperator-- ()
 
const_result_iteratoroperator+= (difference_type i)
 
const_result_iteratoroperator-= (difference_type i)
 
Comparisons
bool operator== (const const_result_iterator &i) const
 
bool operator!= (const const_result_iterator &i) const
 
bool operator< (const const_result_iterator &i) const
 
bool operator<= (const const_result_iterator &i) const
 
bool operator> (const const_result_iterator &i) const
 
bool operator>= (const const_result_iterator &i) const
 
Comparison
bool PQXX_PURE operator== (const tuple &) const throw ()
 
bool operator!= (const tuple &rhs) const throw ()
 
Field access
reference front () const throw ()
 
reference back () const throw ()
 
const_reverse_tuple_iterator rbegin () const
 
const_reverse_tuple_iterator rend () const
 
reference operator[] (size_type) const throw ()
 
reference operator[] (int) const throw ()
 
reference operator[] (const char[]) const
 
reference operator[] (const PGSTD::string &) const
 
reference at (size_type) const throw (range_error)
 
reference at (int) const throw (range_error)
 
reference at (const char[]) const
 
reference at (const PGSTD::string &) const
 
Column information
size_type column_number (const PGSTD::string &ColName) const
 Number of given column (throws exception if it doesn't exist) More...
 
size_type column_number (const char[]) const
 Number of given column (throws exception if it doesn't exist) More...
 
oid column_type (size_type) const
 Type of given column. More...
 
oid column_type (int ColNum) const
 Type of given column. More...
 
oid column_type (const PGSTD::string &ColName) const
 Type of given column. More...
 
oid column_type (const char ColName[]) const
 Type of given column. More...
 
oid column_table (size_type ColNum) const
 What table did this column come from? More...
 
oid column_table (int ColNum) const
 What table did this column come from? More...
 
oid column_table (const PGSTD::string &ColName) const
 What table did this column come from? More...
 
size_type table_column (size_type) const
 What column number in its table did this result column come from? More...
 
size_type table_column (int ColNum) const
 What column number in its table did this result column come from? More...
 
size_type table_column (const PGSTD::string &ColName) const
 What column number in its table did this result column come from? More...
 

Protected Attributes

size_type m_Begin
 
size_type m_End
 
const resultm_Home
 
size_t m_Index
 

Private Member Functions

 const_result_iterator (const pqxx::result *r, result::size_type i) throw ()
 

Friends

class pqxx::result
 

Arithmetic operators

const_result_iterator operator+ (difference_type, const_result_iterator)
 
const_result_iterator operator+ (difference_type) const
 
const_result_iterator operator- (difference_type) const
 
difference_type operator- (const_result_iterator) const
 

Detailed Description

Iterator for rows (tuples) in a result. Use as result::const_iterator.

A result, once obtained, cannot be modified. Therefore there is no plain iterator type for result. However its const_iterator type can be used to inspect its tuples without changing them.

Member Typedef Documentation

Constructor & Destructor Documentation

pqxx::const_result_iterator::const_result_iterator ( ) throw ()
inline
pqxx::const_result_iterator::const_result_iterator ( const tuple t) throw ()
inline
pqxx::const_result_iterator::const_result_iterator ( const pqxx::result r,
result::size_type  i 
) throw ()
inlineprivate

Member Function Documentation

reference pqxx::tuple::at ( size_type  ) const throw (range_error)
inherited
reference pqxx::tuple::at ( int  ) const throw (range_error)
inherited
reference pqxx::tuple::at ( const char  []) const
inherited
reference pqxx::tuple::at ( const PGSTD::string &  ) const
inherited
reference pqxx::tuple::back ( ) const throw ()
inherited
const_iterator pqxx::tuple::begin ( ) const throw ()
inherited
size_type pqxx::tuple::column_number ( const PGSTD::string &  ColName) const
inlineinherited

Number of given column (throws exception if it doesn't exist)

References pqxx::tuple::column_number().

Referenced by pqxx::tuple::column_number().

Here is the call graph for this function:

Here is the caller graph for this function:

size_type pqxx::tuple::column_number ( const char  []) const
inherited

Number of given column (throws exception if it doesn't exist)

oid pqxx::tuple::column_table ( size_type  ColNum) const
inherited

What table did this column come from?

oid pqxx::tuple::column_table ( int  ColNum) const
inlineinherited

What table did this column come from?

References pqxx::tuple::column_table().

Referenced by pqxx::tuple::column_table().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::tuple::column_table ( const PGSTD::string &  ColName) const
inlineinherited

What table did this column come from?

References pqxx::tuple::column_table().

Referenced by pqxx::tuple::column_table().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::tuple::column_type ( size_type  ) const
inherited

Type of given column.

oid pqxx::tuple::column_type ( int  ColNum) const
inlineinherited

Type of given column.

References pqxx::tuple::column_type().

Referenced by pqxx::tuple::column_type().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::tuple::column_type ( const PGSTD::string &  ColName) const
inlineinherited

Type of given column.

References pqxx::tuple::column_type().

Referenced by pqxx::tuple::column_type().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::tuple::column_type ( const char  ColName[]) const
inlineinherited

Type of given column.

References pqxx::tuple::column_type().

Referenced by pqxx::tuple::column_type().

Here is the call graph for this function:

Here is the caller graph for this function:

bool PQXX_PURE pqxx::tuple::empty ( ) const throw ()
inherited
const_iterator pqxx::tuple::end ( ) const throw ()
inherited
reference pqxx::tuple::front ( ) const throw ()
inherited
size_t pqxx::tuple::num ( ) const
inlineinherited

Referenced by operator-().

Here is the caller graph for this function:

bool pqxx::tuple::operator!= ( const tuple rhs) const throw ()
inlineinherited
bool pqxx::const_result_iterator::operator!= ( const const_result_iterator i) const
inline
reference pqxx::const_result_iterator::operator* ( ) const
inline
const_result_iterator pqxx::const_result_iterator::operator+ ( result::difference_type  o) const
inline
const_result_iterator pqxx::const_result_iterator::operator++ ( int  )
const_result_iterator& pqxx::const_result_iterator::operator++ ( )
inline
const_result_iterator& pqxx::const_result_iterator::operator+= ( difference_type  i)
inline
const_result_iterator pqxx::const_result_iterator::operator- ( result::difference_type  o) const
inline
result::difference_type pqxx::const_result_iterator::operator- ( const_result_iterator  i) const
inline

References pqxx::tuple::num().

Here is the call graph for this function:

const_result_iterator pqxx::const_result_iterator::operator-- ( int  )
const_result_iterator& pqxx::const_result_iterator::operator-- ( )
inline
const_result_iterator& pqxx::const_result_iterator::operator-= ( difference_type  i)
inline
pointer pqxx::const_result_iterator::operator-> ( ) const
inline

The iterator "points to" its own tuple, which is also itself.

This allows a result to be addressed as a two-dimensional container without going through the intermediate step of dereferencing the iterator. I hope this works out to be similar to C pointer/array semantics in useful cases.

IIRC Alex Stepanov, the inventor of the STL, once remarked that having this as standard behaviour for pointers would be useful in some algorithms. So even if this makes me look foolish, I would seem to be in distinguished company.

bool pqxx::const_result_iterator::operator< ( const const_result_iterator i) const
inline
bool pqxx::const_result_iterator::operator<= ( const const_result_iterator i) const
inline
bool PQXX_PURE pqxx::tuple::operator== ( const tuple ) const throw ()
inherited
bool pqxx::const_result_iterator::operator== ( const const_result_iterator i) const
inline
bool pqxx::const_result_iterator::operator> ( const const_result_iterator i) const
inline
bool pqxx::const_result_iterator::operator>= ( const const_result_iterator i) const
inline
reference pqxx::tuple::operator[] ( size_type  ) const throw ()
inherited
reference pqxx::tuple::operator[] ( int  ) const throw ()
inherited
reference pqxx::tuple::operator[] ( const char  []) const
inherited
reference pqxx::tuple::operator[] ( const PGSTD::string &  ) const
inherited
const_reverse_tuple_iterator pqxx::tuple::rbegin ( ) const
inherited
const_reverse_tuple_iterator pqxx::tuple::rend ( ) const
inherited
size_t pqxx::tuple::rownumber ( ) const throw ()
inlineinherited
size_type pqxx::tuple::size ( ) const throw ()
inlineinherited
tuple pqxx::tuple::slice ( size_type  Begin,
size_type  End 
) const
inherited

Produce a slice of this tuple, containing the given range of columns.

The slice runs from the range's starting column to the range's end column, exclusive. It looks just like a normal result tuple, except slices can be empty.

Warning
Slicing is a relatively new feature, and not all software may be prepared to deal with empty slices. If there is any chance that your program might be creating empty slices and passing them to code that may not be designed with the possibility of empty tuples in mind, be sure to test for that case.
void pqxx::tuple::swap ( tuple ) throw ()
inherited
size_type pqxx::tuple::table_column ( size_type  ) const
inherited

What column number in its table did this result column come from?

A meaningful answer can be given only if the column in question comes directly from a column in a table. If the column is computed in any other way, a logic_error will be thrown.

Parameters
ColNuma zero-based column number in this result set
Returns
a zero-based column number in originating table

Requires libpq from PostgreSQL 7.4 or better, as well as a server version of at least 7.4.

size_type pqxx::tuple::table_column ( int  ColNum) const
inlineinherited

What column number in its table did this result column come from?

References pqxx::tuple::table_column().

Referenced by pqxx::tuple::table_column().

Here is the call graph for this function:

Here is the caller graph for this function:

size_type pqxx::tuple::table_column ( const PGSTD::string &  ColName) const
inlineinherited

What column number in its table did this result column come from?

References pqxx::tuple::table_column().

Referenced by pqxx::tuple::table_column().

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class pqxx::result
friend

Member Data Documentation

size_type pqxx::tuple::m_Begin
protectedinherited
size_type pqxx::tuple::m_End
protectedinherited
const result* pqxx::tuple::m_Home
protectedinherited
size_t pqxx::tuple::m_Index
protectedinherited

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