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

Result set containing data returned by a query or command. More...

#include <result.hxx>

Inheritance diagram for pqxx::result:
Collaboration diagram for pqxx::result:

Public Types

typedef const_result_iterator const_iterator
 
typedef
const_reverse_result_iterator 
const_reverse_iterator
 
typedef signed long difference_type
 
typedef const_iterator iterator
 
typedef const_iterator pointer
 
typedef tuple reference
 
typedef const_reverse_iterator reverse_iterator
 
typedef unsigned long size_type
 

Public Member Functions

 result () throw ()
 
 result (const result &rhs) throw ()
 
size_type PQXX_PURE affected_rows () const
 If command was INSERT, UPDATE, or DELETE: number of affected rows. More...
 
const tuple at (size_type) const throw (range_error)
 
reference back () const throw ()
 
const_iterator begin () const throw ()
 
size_type capacity () const throw ()
 
void clear () throw ()
 
bool PQXX_PURE empty () const throw ()
 
const_iterator end () const throw ()
 
reference front () const throw ()
 
oid PQXX_PURE inserted_oid () const
 If command was INSERT of 1 row, return oid of inserted row. More...
 
resultoperator= (const result &rhs) throw ()
 
const tuple operator[] (size_type i) const throw ()
 
const PGSTD::string &PQXX_PURE query () const throw ()
 Query that produced this result, if available (empty string otherwise) More...
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
size_type PQXX_PURE size () const throw ()
 
void swap (result &) throw ()
 
Comparisons
bool operator== (const result &) const throw ()
 
bool operator!= (const result &rhs) const throw ()
 
Column information
tuple::size_type PQXX_PURE columns () const throw ()
 Number of columns in result. More...
 
tuple::size_type column_number (const char ColName[]) const
 Number of given column (throws exception if it doesn't exist) More...
 
tuple::size_type column_number (const PGSTD::string &Name) const
 Number of given column (throws exception if it doesn't exist) More...
 
const char * column_name (tuple::size_type Number) const
 Name of column with this number (throws exception if it doesn't exist) More...
 
oid column_type (tuple::size_type ColNum) 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 (tuple::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...
 
tuple::size_type table_column (tuple::size_type ColNum) const
 What column in its table did this column come from? More...
 
tuple::size_type table_column (int ColNum) const
 What column in its table did this column come from? More...
 
tuple::size_type table_column (const PGSTD::string &ColName) const
 What column in its table did this column come from? More...
 

Private Types

typedef const internal::result_data content_type
 
typedef internal::PQAlloc
< const internal::result_data,
internal::freemem_result_data
super
 

Private Member Functions

 result (internal::pq::PGresult *rhs, int protocol, const PGSTD::string &Query, int encoding_code)
 
void PQXX_PRIVATE CheckStatus () const
 
const char *PQXX_PURE CmdStatus () const throw ()
 
int PQXX_PRIVATE PQXX_PURE errorposition () const throw ()
 
const internal::result_dataget () const throw ()
 Obtain underlying pointer. More...
 
bool PQXX_PURE GetIsNull (size_type Row, tuple::size_type Col) const
 
field::size_type PQXX_PURE GetLength (size_type, tuple::size_type) const throw ()
 
const char *PQXX_PURE GetValue (size_type Row, tuple::size_type Col) const
 
 operator bool () const throw ()
 
bool operator! () const throw ()
 
const internal::result_dataoperator* () const throw (PGSTD::logic_error)
 Dereference pointer. More...
 
const internal::result_dataoperator-> () const throw (PGSTD::logic_error)
 Dereference pointer. More...
 
void reset () throw ()
 
PGSTD::string PQXX_PRIVATE StatusError () const
 
void swap (PQAlloc &rhs) throw ()
 
void PQXX_PRIVATE PQXX_NORETURN ThrowSQLError (const PGSTD::string &Err, const PGSTD::string &Query) const
 

Private Attributes

pqxx::internal::pq::PGresultm_data
 Shortcut: pointer to result data. More...
 

Static Private Attributes

static const PGSTD::string
PQXX_PRIVATE 
s_empty_string
 

Friends

class pqxx::field
 
class pqxx::internal::gate::result_connection
 
class pqxx::internal::gate::result_creation
 
class pqxx::internal::gate::result_sql_cursor
 

Detailed Description

Result set containing data returned by a query or command.

This behaves as a container (as defined by the C++ standard library) and provides random access const iterators to iterate over its tuples. A tuple can also be accessed by indexing a result R by the tuple's zero-based number:

for (result::size_type i=0; i < R.size(); ++i) Process(R[i]);

Result sets in libpqxx are lightweight, reference-counted wrapper objects (following the Proxy design pattern) that are small and cheap to copy. Think of a result object as a "smart pointer" to an underlying result set.

Warning
The result set that a result object points to is not thread-safe. If you copy a result object, it still refers to the same underlying result set. So never copy, destroy, query, or otherwise access a result while another thread may be copying, destroying, querying, or otherwise accessing the same result set–even if it is doing so through a different result object!

Member Typedef Documentation

typedef signed long pqxx::result::difference_type
typedef unsigned long pqxx::result::size_type

Constructor & Destructor Documentation

pqxx::result::result ( ) throw ()
inline
pqxx::result::result ( const result rhs) throw ()
inline
pqxx::result::result ( internal::pq::PGresult rhs,
int  protocol,
const PGSTD::string &  Query,
int  encoding_code 
)
private

Member Function Documentation

size_type PQXX_PURE pqxx::result::affected_rows ( ) const

If command was INSERT, UPDATE, or DELETE: number of affected rows.

Returns
Number of affected rows if last command was INSERT, UPDATE, or DELETE; zero for all other commands.
const tuple pqxx::result::at ( size_type  ) const throw (range_error)
reference pqxx::result::back ( ) const throw ()
inline
const_iterator pqxx::result::begin ( ) const throw ()
size_type pqxx::result::capacity ( ) const throw ()
inline
void PQXX_PRIVATE pqxx::result::CheckStatus ( ) const
private
void pqxx::result::clear ( ) throw ()
inline

Referenced by pqxx::transaction_base::reactivation_avoidance_clear().

Here is the caller graph for this function:

const char* PQXX_PURE pqxx::result::CmdStatus ( ) const throw ()
private
const char* pqxx::result::column_name ( tuple::size_type  Number) const

Name of column with this number (throws exception if it doesn't exist)

tuple::size_type pqxx::result::column_number ( const char  ColName[]) const

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

tuple::size_type pqxx::result::column_number ( const PGSTD::string &  Name) const
inline

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

References column_number().

Referenced by column_number().

Here is the call graph for this function:

Here is the caller graph for this function:

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

What table did this column come from?

oid pqxx::result::column_table ( int  ColNum) const
inline

What table did this column come from?

References column_table().

Referenced by column_table().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::result::column_table ( const PGSTD::string &  ColName) const
inline

What table did this column come from?

References column_table().

Referenced by column_table().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::result::column_type ( tuple::size_type  ColNum) const

Type of given column.

oid pqxx::result::column_type ( int  ColNum) const
inline

Type of given column.

References column_type().

Referenced by column_type().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::result::column_type ( const PGSTD::string &  ColName) const
inline

Type of given column.

References column_type().

Referenced by column_type().

Here is the call graph for this function:

Here is the caller graph for this function:

oid pqxx::result::column_type ( const char  ColName[]) const
inline

Type of given column.

References column_type().

Referenced by column_type().

Here is the call graph for this function:

Here is the caller graph for this function:

tuple::size_type PQXX_PURE pqxx::result::columns ( ) const throw ()

Number of columns in result.

bool PQXX_PURE pqxx::result::empty ( ) const throw ()
const_result_iterator pqxx::result::end ( ) const throw ()
inline
int PQXX_PRIVATE PQXX_PURE pqxx::result::errorposition ( ) const throw ()
private
reference pqxx::result::front ( ) const throw ()
inline
const internal::result_data * pqxx::internal::PQAlloc< const internal::result_data , DELETER >::get ( ) const throw ()
inlineinherited

Obtain underlying pointer.

Ownership of the pointer's memory remains with the PQAlloc object

bool PQXX_PURE pqxx::result::GetIsNull ( size_type  Row,
tuple::size_type  Col 
) const
private
field::size_type PQXX_PURE pqxx::result::GetLength ( size_type  ,
tuple::size_type   
) const throw ()
private
const char* PQXX_PURE pqxx::result::GetValue ( size_type  Row,
tuple::size_type  Col 
) const
private
oid PQXX_PURE pqxx::result::inserted_oid ( ) const

If command was INSERT of 1 row, return oid of inserted row.

Returns
Identifier of inserted row if exactly one row was inserted, or oid_none otherwise.
pqxx::result::operator bool ( ) const throw ()
inlineprivate
bool pqxx::result::operator! ( ) const throw ()
inlineprivate
bool pqxx::result::operator!= ( const result rhs) const throw ()
inline
const internal::result_data & pqxx::internal::PQAlloc< const internal::result_data , DELETER >::operator* ( ) const throw (PGSTD::logic_error)
inlineinherited

Dereference pointer.

Throws a logic_error if the pointer is null.

const internal::result_data * pqxx::internal::PQAlloc< const internal::result_data , DELETER >::operator-> ( ) const throw (PGSTD::logic_error)
inlineinherited

Dereference pointer.

Throws a logic_error if the pointer is null.

result& pqxx::result::operator= ( const result rhs) throw ()
inline
bool pqxx::result::operator== ( const result ) const throw ()
const tuple pqxx::result::operator[] ( size_type  i) const throw ()
inline
const PGSTD::string& PQXX_PURE pqxx::result::query ( ) const throw ()

Query that produced this result, if available (empty string otherwise)

const_reverse_iterator pqxx::result::rbegin ( ) const
const_reverse_iterator pqxx::result::rend ( ) const
void pqxx::internal::PQAlloc< const internal::result_data , DELETER >::reset ( ) throw ()
inlineinherited
size_type PQXX_PURE pqxx::result::size ( ) const throw ()
PGSTD::string PQXX_PRIVATE pqxx::result::StatusError ( ) const
private
void pqxx::result::swap ( result ) throw ()
void pqxx::internal::PQAlloc< const internal::result_data , DELETER >::swap ( PQAlloc< const internal::result_data, internal::freemem_result_data > &  rhs) throw ()
inlineinherited
tuple::size_type pqxx::result::table_column ( tuple::size_type  ColNum) const

What column in its table did this column come from?

tuple::size_type pqxx::result::table_column ( int  ColNum) const
inline

What column in its table did this column come from?

References table_column().

Referenced by table_column().

Here is the call graph for this function:

Here is the caller graph for this function:

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

What column in its table did this column come from?

References table_column().

Referenced by table_column().

Here is the call graph for this function:

Here is the caller graph for this function:

void PQXX_PRIVATE PQXX_NORETURN pqxx::result::ThrowSQLError ( const PGSTD::string &  Err,
const PGSTD::string &  Query 
) const
private

Friends And Related Function Documentation

friend class pqxx::field
friend

Member Data Documentation

pqxx::internal::pq::PGresult* pqxx::result::m_data
private

Shortcut: pointer to result data.

const PGSTD::string PQXX_PRIVATE pqxx::result::s_empty_string
staticprivate

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