libpqxx  7.0.7
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 (row &&)=default
 
 row (row const &)=default
 
rowoperator= (row const &)=default
 
rowoperator= (row &&)=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
 
result::size_type rownumber () const noexcept
 Row number, assuming this is a real row and not end()/rend(). More...
 
result::size_type num () const
 
row slice (size_type sbegin, size_type send) const
 
PQXX_PURE bool empty () const noexcept
 
Comparison
PQXX_PURE bool operator== (row const &) const noexcept
 
bool operator!= (row const &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[] (char const []) const
 
reference operator[] (std::string const &s) const
 
reference at (size_type) const
 
reference at (char const []) const
 
reference at (std::string const &s) const
 
Column information
size_type column_number (std::string const &col_name) const
 Number of given column (throws exception if it doesn't exist). More...
 
size_type column_number (char const []) const
 Number of given column (throws exception if it doesn't exist). More...
 
oid column_type (size_type) const
 Return a column's type. More...
 
template<typename STRING >
oid column_type (STRING col_name) const
 Return a column's type. More...
 
oid column_table (size_type col_num) const
 What table did this column come from? More...
 
template<typename STRING >
oid column_table (STRING col_name) 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...
 
template<typename STRING >
size_type table_column (STRING col_name) const
 What column number in its table did this result column come from? More...
 

Protected Member Functions

 row (result const &r, result_size_type i) noexcept
 

Protected Attributes

result m_result
 Result set of which this is one row. More...
 
result::size_type 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 const_row_iterator
 
class result
 
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/4]

pqxx::row::row ( )
default

◆ row() [2/4]

pqxx::row::row ( row &&  )
default

◆ row() [3/4]

pqxx::row::row ( row const &  )
default

◆ row() [4/4]

pqxx::row::row ( result const &  r,
result_size_type  i 
)
protectednoexcept

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

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

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

◆ at() [1/3]

◆ at() [2/3]

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

Address field by name.

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

References column_number(), and m_begin.

◆ at() [3/3]

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

Address field by name.

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

References at().

Referenced by at().

◆ back()

◆ begin()

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

References m_begin.

Referenced by cbegin(), and rend().

◆ cbegin()

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

References begin().

◆ cend()

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

References end().

◆ column_number() [1/2]

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

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

Referenced by at().

◆ column_number() [2/2]

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

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

References pqxx::result::column_name(), pqxx::result::column_number(), m_begin, m_end, and m_result.

◆ column_table() [1/2]

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

What table did this column come from?

References pqxx::result::column_table(), m_begin, and m_result.

◆ column_table() [2/2]

template<typename STRING >
oid pqxx::row::column_table ( STRING  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.

References pqxx::result::column_type(), m_begin, and m_result.

◆ column_type() [2/2]

template<typename STRING >
oid pqxx::row::column_type ( STRING  col_name) const

Return a column's type.

◆ crbegin()

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

References rbegin().

◆ crend()

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

References rend().

◆ empty()

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

References m_begin, and m_end.

◆ end()

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

References m_end.

Referenced by cend(), and rbegin().

◆ front()

◆ num()

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

◆ operator!=()

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

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

References size().

◆ operator[]() [1/3]

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

References m_begin.

Referenced by at().

◆ operator[]() [2/3]

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

Address field by name.

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

References at().

◆ operator[]() [3/3]

reference pqxx::row::operator[] ( std::string const &  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

References end().

Referenced by crbegin().

◆ rend()

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

References begin().

Referenced by crend().

◆ rownumber()

result::size_type pqxx::row::rownumber ( ) const
noexcept

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

Referenced by pqxx::const_reverse_result_iterator::const_reverse_result_iterator(), and pqxx::const_result_iterator::operator*().

◆ size()

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

Referenced by at(), operator==(), and slice().

◆ slice()

pqxx::row pqxx::row::slice ( size_type  sbegin,
size_type  send 
) 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.

References m_begin, and size().

◆ swap()

void pqxx::row::swap ( row rhs)
noexcept
Deprecated:
Do this sort of thing on iterators instead.

References m_begin, m_end, m_index, m_result, and pqxx::result::swap().

Referenced by pqxx::const_result_iterator::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_numa zero-based column number in this result set
Returns
a zero-based column number in originating table

References m_begin, m_result, and pqxx::result::table_column().

◆ table_column() [2/2]

template<typename STRING >
size_type pqxx::row::table_column ( STRING  col_name) const

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

Friends And Related Function Documentation

◆ const_row_iterator

friend class const_row_iterator
friend

◆ field

friend class field
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 at(), begin(), column_number(), column_table(), column_type(), empty(), front(), operator[](), slice(), swap(), and table_column().

◆ m_end

size_type pqxx::row::m_end = 0
protected

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

Referenced by back(), column_number(), empty(), end(), and swap().

◆ 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.

Referenced by pqxx::const_result_iterator::operator!=(), pqxx::const_result_iterator::operator<(), pqxx::const_result_iterator::operator<=(), pqxx::const_result_iterator::operator==(), pqxx::const_result_iterator::operator>(), pqxx::const_result_iterator::operator>=(), and swap().

◆ m_result

result pqxx::row::m_result
protected

Result set of which this is one row.

Referenced by column_number(), column_table(), column_type(), swap(), and table_column().


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