pqxx::row Class Reference

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

`#include <row.hxx>`

## 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 () noexcept=default
| row (row &&) noexcept=default
| row (row const &) noexcept=default
row & | operator= (row const &) noexcept=default
row & | operator= (row &&) noexcept=default
Comparison
PQXX_PURE bool | operator== (row const &) const noexcept
bool | operator!= (row const &rhs) const noexcept
const_iterator | begin () const noexcept
const_iterator | cbegin () const noexcept
const_iterator | end () const noexcept
const_iterator | cend () const noexcept
Field access
reference | front () const noexcept
reference | back () const noexcept
const_reverse_row_iterator | rbegin () const noexcept
const_reverse_row_iterator | crbegin () const noexcept
const_reverse_row_iterator | rend () const noexcept
const_reverse_row_iterator | crend () const noexcept
reference | operator[] (size_type) const noexcept
reference | operator[] (zview col_name) const
reference | at (size_type) const
reference | at (zview col_name) const
constexpr size_type | size () const noexcept
void | swap (row &) noexcept
constexpr result::size_type | rownumber () const noexcept
| Row number, assuming this is a real row and not end()/rend().

## Column information

class | const_row_iterator
class | result
template<typename... T>
class | pqxx::internal::result_iter
class | field
result | m_result
| Result set of which this is one row.
result::size_type | m_index = 0
| Row number.
size_type | m_begin = 0
| First column in slice. This row ignores lower-numbered columns.
size_type | m_end = 0
| End column in slice. This row only sees lower-numbered columns.
size_type | column_number (zview col_name) const
| Number of given column (throws exception if it doesn't exist).
oid | column_type (size_type) const
| Return a column's type.
oid | column_type (zview col_name) const
| Return a column's type.
oid | column_table (size_type col_num) const
| What table did this column come from?
oid | column_table (zview col_name) const
| What table did this column come from?
size_type | table_column (size_type) const
| What column number in its table did this result column come from?
size_type | table_column (zview col_name) const
| What column number in its table did this result column come from?
constexpr result::size_type | num () const noexcept
row | slice (size_type sbegin, size_type send) const
PQXX_PURE bool | empty () const noexcept
| Is this a row without fields? Can only happen to a slice.
template<typename Tuple >
void | to (Tuple &t) const
| Extract entire row's values into a tuple.
template<typename... TYPE>
std::tuple< TYPE... > | as () const
| Extract entire row's values into a tuple.
| row (result const &r, result_size_type index, size_type cols) noexcept
void | check_size (size_type expected) const
| Throw usage_error if row size is not `expected`.
template<typename TUPLE >
TUPLE | as_tuple () const
| Convert to a given tuple of values, don't check sizes.
template<typename Tuple >
void | convert (Tuple &t) const
| Convert entire row to tuple fields, without checking row size.

## 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;
pqxx::row
Reference to one row in a result.
Definition row.hxx:47

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

## Member Typedef Documentation

## const_iterator

using pqxx::row::const_iterator = const_row_iterator

## const_reverse_iterator

using pqxx::row::const_reverse_iterator = const_reverse_row_iterator

## difference_type

using pqxx::row::difference_type = row_difference_type

## iterator

using pqxx::row::iterator = const_iterator

## pointer

using pqxx::row::pointer = const_row_iterator

## reference

using pqxx::row::reference = field

## reverse_iterator

using pqxx::row::reverse_iterator = const_reverse_iterator

## size_type

using pqxx::row::size_type = row_size_type

## Constructor & Destructor Documentation

## row() [1/4]

pqxx::row::row | ( |  | ) |

default noexcept

## row() [2/4]

pqxx::row::row | ( | row && |  | ) |

default noexcept

## row() [3/4]

pqxx::row::row | ( | row const & |  | ) |

default noexcept

## row() [4/4]

pqxx::row::row | ( | result const & | r,
|  | result_size_type | index,
|  | size_type | cols
| ) |  |

protected noexcept

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

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

Copyright (c) 2000-2023, 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.

## Member Function Documentation

## as()

template<typename... TYPE>

std::tuple< TYPE... > pqxx::row::as | ( |  | ) | const

Extract entire row's values into a tuple.

Converts to the types of the tuple's respective fields.

Exceptions

  usage_error | If the number of columns in the `row` does not match the number of fields in `t`.

## as_tuple()

template<typename TUPLE >

TUPLE pqxx::row::as_tuple | ( |  | ) | const

protected

Convert to a given tuple of values, don't check sizes.

We need this for cases where we have a full tuple of field types, but not a parameter pack.

## at() [1/2]

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

## at() [2/2]

pqxx::field pqxx::row::at | ( | zview | col_name | ) | 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

## check_size()

void pqxx::row::check_size | ( | size_type | expected | ) | const

protected

Throw usage_error if row size is not `expected`.

## column_number()

pqxx::row::size_type pqxx::row::column_number | ( | zview | col_name | ) | const

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

References pqxx::result::column_number().

## column_table() [1/2]

pqxx::oid pqxx::row::column_table | ( | size_type | col_num | ) | const

What table did this column come from?

## column_table() [2/2]

oid pqxx::row::column_table | ( | zview | col_name | ) | const

What table did this column come from?

## column_type() [1/2]

pqxx::oid pqxx::row::column_type | ( | size_type | col_num | ) | const

Return a column's type.

## column_type() [2/2]

oid pqxx::row::column_type | ( | zview | col_name | ) | const

Return a column's type.

## convert()

template<typename Tuple >

void pqxx::row::convert | ( | Tuple & | t | ) | const

protected

Convert entire row to tuple fields, without checking row size.

## crbegin()

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

noexcept

## crend()

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

noexcept

## empty()

bool PQXX_COLD pqxx::row::empty | ( |  | ) | const

noexcept

Is this a row without fields? Can only happen to a slice.

## end()

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

noexcept

## front()

pqxx::row::reference pqxx::row::front | ( |  | ) | const

noexcept

Referenced by pqxx::transaction_base::exec1(), pqxx::transaction_base::exec1(), pqxx::transaction_base::exec_params1(), and pqxx::transaction_base::exec_prepared1().

## num()

constexpr result::size_type pqxx::row::num | ( |  | ) | const

constexpr noexcept

## operator!=()

bool pqxx::row::operator!= | ( | row const & | rhs | ) | const

noexcept

## operator=() [1/2]

row & pqxx::row::operator= | ( | row && |  | ) |

default noexcept

## operator=() [2/2]

row & pqxx::row::operator= | ( | row const & |  | ) |

default noexcept

## operator==()

bool pqxx::row::operator== | ( | row const & | rhs | ) | const

noexcept

## operator[]() [1/2]

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

noexcept

## operator[]() [2/2]

pqxx::row::reference pqxx::row::operator[] | ( | zview | col_name | ) | 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

noexcept

## rend()

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

noexcept

## rownumber()

constexpr result::size_type pqxx::row::rownumber | ( |  | ) | const

constexpr noexcept

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

## size()

constexpr size_type pqxx::row::size | ( |  | ) | const

constexpr noexcept

## slice()

pqxx::row PQXX_COLD pqxx::row::slice | ( | size_type | sbegin,
|  | size_type | send
| ) |  | const

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

Deprecated:
  I haven't heard of anyone caring about row slicing at all in at least the last 15 years. Yet it adds complexity, so unless anyone files a bug explaining why they really need this feature, I'm going to remove it. Even if they do, the feature may need an update.

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.

References m_begin.

## swap()

void pqxx::row::swap | ( | row & | rhs | ) |

noexcept

Referenced by pqxx::result::swap().

## table_column() [1/2]

pqxx::row::size_type pqxx::row::table_column | ( | size_type | col_num | ) | 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

  col_num | a zero-based column number in this result set

Returns
  a zero-based column number in originating table

## table_column() [2/2]

size_type pqxx::row::table_column | ( | zview | col_name | ) | const

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

## to()

template<typename Tuple >

void pqxx::row::to | ( | Tuple & | t | ) | const

Extract entire row's values into a tuple.

Converts to the types of the tuple's respective fields.

Exceptions

  usage_error | If the number of columns in the `row` does not match the number of fields in `t`.

## Friends And Related Symbol Documentation

## const_row_iterator

friend class const_row_iterator

friend

## field

friend class field

friend

## pqxx::internal::result_iter

template<typename... T>

friend class pqxx::internal::result_iter

friend

## result

friend class result

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(), and slice().

## m_end

size_type pqxx::row::m_end = 0

protected

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

## m_index

result::size_type pqxx::row::m_index = 0

protected

Row number.

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

## m_result

result pqxx::row::m_result

protected

Result set of which this is one row.

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

- row.hxx
- row.cxx