libpqxx
pqxx::row Class Reference

Reference to one row in a result. More...

#include <row.hxx>

Inheritance diagram for pqxx::row:

Public Types

using size_type = row_size_type
 
using difference_type = row_difference_type
 
using const_iterator = const_row_iterator
 
using iterator = const_iterator
 
using reference = field
 
using pointer = const_row_iterator
 
using const_reverse_iterator = const_reverse_row_iterator
 
using reverse_iterator = const_reverse_iterator
 

Public Member Functions

 row ()=default
 
 row (result r, size_t i) noexcept
 
 ~row () noexcept=default
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 
size_type size () const noexcept
 
void swap (row &) noexcept
 
size_t rownumber () const noexcept
 Row number, assuming this is a real row and not end()/rend(). More...
 
size_t num () const
 
row slice (size_type Begin, size_type End) const
 
PQXX_PURE bool empty () const noexcept
 
Comparison
PQXX_PURE bool operator== (const row &) const noexcept
 
bool operator!= (const row &rhs) const noexcept
 
Field access
reference front () const noexcept
 
reference back () const noexcept
 
const_reverse_row_iterator rbegin () const
 
const_reverse_row_iterator crbegin () const
 
const_reverse_row_iterator rend () const
 
const_reverse_row_iterator crend () const
 
reference operator[] (size_type) const noexcept
 
reference operator[] (int) const noexcept
 
reference operator[] (const char[]) const
 
reference operator[] (const std::string &) const
 
reference at (size_type) const
 
reference at (int) const
 
reference at (const char[]) const
 
reference at (const std::string &) const
 
Column information
size_type column_number (const std::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 std::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 std::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 std::string &ColName) const
 What column number in its table did this result column come from? More...
 

Protected Attributes

result m_result
 Result set of which this is one row. More...
 
long m_index = 0
 Row number. More...
 
size_type m_begin = 0
 First column in slice. This row ignores lower-numbered columns. More...
 
size_type m_end = 0
 End column in slice. This row only sees lower-numbered columns. More...
 

Friends

class field
 

Detailed Description

Reference to one row in a result.

A row represents one row (also called a row) in a query result set. It also acts as a container mapping column numbers or names to field values (see below):

cout << row["date"].c_str() << ": " << row["name"].c_str() << endl;

The row itself acts like a (non-modifyable) container, complete with its own const_iterator and const_reverse_iterator.

Member Typedef Documentation

◆ const_iterator

◆ const_reverse_iterator

◆ difference_type

◆ iterator

◆ pointer

◆ reference

◆ reverse_iterator

◆ size_type

Constructor & Destructor Documentation

◆ row() [1/2]

pqxx::row::row ( )
default

◆ row() [2/2]

pqxx::row::row ( result  r,
size_t  i 
)
noexcept
Deprecated:
Do not use this constructor. It will become private.

Implementation of the pqxx::result class and support classes.

pqxx::result represents the set of result rows from a database query.

Copyright (c) 2000-2019, Jeroen T. Vermeulen.

See COPYING for copyright license. If you did not receive a file called COPYING with this source code, please notify the distributor of this mistake, or contact the author.

◆ ~row()

pqxx::row::~row ( )
defaultnoexcept

Member Function Documentation

◆ at() [1/4]

pqxx::field pqxx::row::at ( size_type  i) const

◆ at() [2/4]

pqxx::row::reference pqxx::row::at ( int  i) const

◆ at() [3/4]

pqxx::field pqxx::row::at ( const char  f[]) const

Address field by name.

Warning
This is much slower than indexing by number, or iterating.

◆ at() [4/4]

pqxx::row::reference pqxx::row::at ( const std::string &  s) const

Address field by name.

Warning
This is much slower than indexing by number, or iterating.

◆ back()

pqxx::row::reference pqxx::row::back ( ) const
noexcept

◆ begin()

pqxx::row::const_iterator pqxx::row::begin ( ) const
noexcept

References m_begin.

◆ cbegin()

pqxx::row::const_iterator pqxx::row::cbegin ( ) const
noexcept

◆ cend()

pqxx::row::const_iterator pqxx::row::cend ( ) const
noexcept

◆ column_number() [1/2]

size_type pqxx::row::column_number ( const std::string &  ColName) const

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

◆ column_number() [2/2]

pqxx::row::size_type pqxx::row::column_number ( const char  ColName[]) const

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

References pqxx::result::column_number().

◆ column_table() [1/3]

pqxx::oid pqxx::row::column_table ( size_type  ColNum) const

What table did this column come from?

◆ column_table() [2/3]

oid pqxx::row::column_table ( int  ColNum) const

What table did this column come from?

◆ column_table() [3/3]

oid pqxx::row::column_table ( const std::string &  ColName) const

What table did this column come from?

◆ column_type() [1/4]

pqxx::oid pqxx::row::column_type ( size_type  ColNum) const

Type of given column.

◆ column_type() [2/4]

oid pqxx::row::column_type ( int  ColNum) const

Type of given column.

◆ column_type() [3/4]

oid pqxx::row::column_type ( const std::string &  ColName) const

Type of given column.

◆ column_type() [4/4]

oid pqxx::row::column_type ( const char  ColName[]) const

Type of given column.

◆ crbegin()

pqxx::row::const_reverse_iterator pqxx::row::crbegin ( ) const

◆ crend()

pqxx::row::const_reverse_iterator pqxx::row::crend ( ) const

◆ empty()

bool pqxx::row::empty ( ) const
noexcept

◆ end()

pqxx::row::const_iterator pqxx::row::end ( ) const
noexcept

◆ front()

◆ num()

size_t pqxx::row::num ( ) const

◆ operator!=()

bool pqxx::row::operator!= ( const row rhs) const
noexcept

◆ operator==()

bool pqxx::row::operator== ( const row rhs) const
noexcept

◆ operator[]() [1/4]

pqxx::row::reference pqxx::row::operator[] ( size_type  i) const
noexcept

◆ operator[]() [2/4]

pqxx::row::reference pqxx::row::operator[] ( int  i) const
noexcept

◆ operator[]() [3/4]

pqxx::row::reference pqxx::row::operator[] ( const char  f[]) const

Address field by name.

Warning
This is much slower than indexing by number, or iterating.

◆ operator[]() [4/4]

pqxx::row::reference pqxx::row::operator[] ( const std::string &  s) const

Address field by name.

Warning
This is much slower than indexing by number, or iterating.

◆ rbegin()

pqxx::row::const_reverse_iterator pqxx::row::rbegin ( ) const

◆ rend()

pqxx::row::const_reverse_iterator pqxx::row::rend ( ) const

◆ rownumber()

size_t pqxx::row::rownumber ( ) const
noexcept

Row number, assuming this is a real row and not end()/rend().

◆ size()

size_type pqxx::row::size ( ) const
noexcept

◆ slice()

pqxx::row pqxx::row::slice ( size_type  Begin,
size_type  End 
) const

Produce a slice of this row, 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 row, 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 rows in mind, be sure to test for that case.

◆ swap()

void pqxx::row::swap ( row rhs)
noexcept

◆ table_column() [1/3]

pqxx::row::size_type pqxx::row::table_column ( size_type  ColNum) const

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

◆ table_column() [2/3]

size_type pqxx::row::table_column ( int  ColNum) const

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

◆ table_column() [3/3]

size_type pqxx::row::table_column ( const std::string &  ColName) const

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

Friends And Related Function Documentation

◆ field

friend class field
friend

Member Data Documentation

◆ m_begin

size_type pqxx::row::m_begin = 0
protected

First column in slice. This row ignores lower-numbered columns.

Referenced by begin().

◆ m_end

size_type pqxx::row::m_end = 0
protected

End column in slice. This row only sees lower-numbered columns.

◆ m_index

long pqxx::row::m_index = 0
protected

Row number.

You'd expect this to be a size_t, but due to the way reverse iterators are related to regular iterators, it must be allowed to underflow to -1.

Referenced by pqxx::const_result_iterator::operator+(), and pqxx::const_result_iterator::operator-().

◆ m_result

result pqxx::row::m_result
protected

Result set of which this is one row.

Referenced by pqxx::const_result_iterator::operator+(), and pqxx::const_result_iterator::operator-().


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