16 #if !defined(PQXX_HEADER_PRE) 17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>." 20 #include "pqxx/except.hxx" 21 #include "pqxx/field.hxx" 22 #include "pqxx/result.hxx" 24 #include "pqxx/internal/concat.hxx" 46 class PQXX_LIBEXPORT
row 58 row() noexcept = default;
59 row(
row &&) noexcept = default;
60 row(
row const &) noexcept = default;
61 row &operator=(
row const &) noexcept = default;
62 row &operator=(
row &&) noexcept = default;
68 [[nodiscard]] PQXX_PURE
bool operator==(
row const &) const noexcept;
69 [[nodiscard]]
bool operator!=(
row const &rhs) const noexcept
71 return not operator==(rhs);
84 [[nodiscard]]
reference front()
const noexcept;
85 [[nodiscard]]
reference back()
const noexcept;
106 return m_end - m_begin;
109 [[deprecated(
"Swap iterators, not rows.")]]
void swap(
row &) noexcept;
125 [[nodiscard]] oid column_type(
size_type)
const;
130 return column_type(column_number(col_name));
134 [[nodiscard]] oid column_table(
size_type col_num)
const;
139 return column_table(column_number(col_name));
155 return table_column(column_number(col_name));
175 [[deprecated(
"Row slicing is going away. File a bug if you need it.")]]
row 179 [[nodiscard, deprecated(
"Row slicing is going away.")]] PQXX_PURE
bool 180 empty()
const noexcept;
188 template<
typename Tuple>
void to(Tuple &t)
const 190 check_size(std::tuple_size_v<Tuple>);
200 template<
typename... TYPE> std::tuple<TYPE...>
as()
const 202 check_size(
sizeof...(TYPE));
203 using seq = std::make_index_sequence<
sizeof...(TYPE)>;
204 return get_tuple<std::tuple<TYPE...>>(seq{});
215 if (size() != expected)
217 "Tried to extract ", expected,
" field(s) from a row of ", size(),
227 using seq = std::make_index_sequence<std::tuple_size_v<TUPLE>>;
228 return get_tuple<TUPLE>(seq{});
233 template<
typename Tuple>
void convert(Tuple &t)
const 235 extract_fields(t, std::make_index_sequence<std::tuple_size_v<Tuple>>{});
257 template<
typename Tuple, std::size_t... indexes>
258 void extract_fields(Tuple &t, std::index_sequence<indexes...>)
const 260 (extract_value<Tuple, indexes>(t), ...);
263 template<
typename Tuple, std::
size_t index>
264 void extract_value(Tuple &t)
const;
267 template<
typename TUPLE, std::size_t... indexes>
268 auto get_tuple(std::index_sequence<indexes...>)
const 270 return std::make_tuple(get_field<TUPLE, indexes>()...);
274 template<
typename TUPLE, std::
size_t index>
auto get_field()
const 276 return (*
this)[index].as<std::tuple_element_t<index, TUPLE>>();
292 #include "pqxx/internal/ignore-deprecated-pre.hxx" 294 #include "pqxx/internal/ignore-deprecated-post.hxx" 296 field{t.m_result, t.m_index, c}
346 [[nodiscard]] constexpr
bool 349 return col() == i.
col();
351 [[nodiscard]] constexpr
bool 354 return col() != i.
col();
356 [[nodiscard]] constexpr
bool 359 return col() < i.
col();
361 [[nodiscard]] constexpr
bool 364 return col() <= i.
col();
366 [[nodiscard]] constexpr
bool 369 return col() > i.
col();
371 [[nodiscard]] constexpr
bool 374 return col() >= i.
col();
425 using iterator_type::operator->;
426 using iterator_type::operator*;
436 iterator_type::operator=(r);
441 iterator_type::operator--();
447 iterator_type::operator++();
453 iterator_type::operator-=(i);
458 iterator_type::operator+=(i);
480 return rhs.const_row_iterator::operator-(*this);
491 return iterator_type::operator==(rhs);
496 return !operator==(rhs);
499 [[nodiscard]] constexpr
bool 502 return iterator_type::operator>(rhs);
504 [[nodiscard]] constexpr
bool 507 return iterator_type::operator>=(rhs);
509 [[nodiscard]] constexpr
bool 512 return iterator_type::operator<(rhs);
514 [[nodiscard]] constexpr
bool 517 return iterator_type::operator<=(rhs);
528 row{home(), idx(), home().columns()},
543 row{home(), idx(), home().columns()},
554 template<
typename Tuple, std::
size_t index>
555 inline void row::extract_value(Tuple &t)
const 558 field const f{m_result, m_index, index};
559 std::get<index>(t) = from_string<field_type>(f);
oid column_type(zview col_name) const
Return a column's type.
Definition: row.hxx:128
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:248
constexpr result::size_type rownumber() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:112
constexpr bool operator>=(const_row_iterator const &i) const noexcept
Definition: row.hxx:372
row_difference_type difference_type
Definition: row.hxx:289
constexpr bool operator>(const_row_iterator const &i) const noexcept
Definition: row.hxx:367
constexpr bool operator>=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:515
size_type table_column(zview col_name) const
What column number in its table did this result column come from?
Definition: row.hxx:153
constexpr bool operator==(const_row_iterator const &i) const noexcept
Definition: row.hxx:347
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition: types.hxx:91
reference operator*() const noexcept
Definition: row.hxx:307
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:32
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:37
const_row_iterator & operator+=(difference_type i) noexcept
Definition: row.hxx:330
oid column_table(zview col_name) const
What table did this column come from?
Definition: row.hxx:137
const_row_iterator & operator--() noexcept
Definition: row.hxx:324
const_row_iterator operator+(const_row_iterator::difference_type o, const_row_iterator const &i) noexcept
Definition: row.hxx:532
TUPLE as_tuple() const
Convert to a given tuple of values, don't check sizes.
Definition: row.hxx:225
const_row_iterator(field const &F) noexcept
Definition: row.hxx:298
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:34
const_row_iterator & operator-=(difference_type i) noexcept
Definition: row.hxx:335
Reference to one row in a result.
Definition: row.hxx:46
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:494
const_reverse_row_iterator & operator--() noexcept
Definition: row.hxx:445
void to(Tuple &t) const
Extract entire row's values into a tuple.
Definition: row.hxx:188
constexpr size_type size() const noexcept
Definition: row.hxx:104
int result_size_type
Number of rows in a result set.
Definition: types.hxx:28
constexpr result::size_type num() const noexcept
Definition: row.hxx:159
result m_result
Result set of which this is one row.
Definition: row.hxx:241
const_row_iterator operator+(difference_type) const noexcept
Definition: row.hxx:524
constexpr bool operator!=(const_row_iterator const &i) const noexcept
Definition: row.hxx:352
const_reverse_row_iterator operator-(difference_type i) noexcept
Definition: row.hxx:473
field_size_type size_type
Definition: field.hxx:37
const_reverse_row_iterator operator++() noexcept
Definition: row.hxx:439
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:397
Reference to a field in a result set.
Definition: field.hxx:34
row_size_type size_type
Definition: row.hxx:49
Result set containing data returned by a query or command.
Definition: result.hxx:72
const_row_iterator & operator++() noexcept
Definition: row.hxx:318
const_reverse_row_iterator & operator-=(difference_type i) noexcept
Definition: row.hxx:456
constexpr pointer operator->() const noexcept
Definition: row.hxx:306
const_row_iterator(row const &t, row_size_type c) noexcept
End a code block started by "ignore-deprecated-pre.hxx".
Definition: row.hxx:295
field const * pointer
Definition: row.hxx:287
const_row_iterator operator-(difference_type) const noexcept
Definition: row.hxx:539
row_difference_type difference_type
Definition: row.hxx:50
void convert(Tuple &t) const
Convert entire row to tuple fields, without checking row size.
Definition: row.hxx:233
const_reverse_row_iterator operator+(difference_type i) const noexcept
Definition: row.hxx:468
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:282
int row_difference_type
Difference between row sizes.
Definition: types.hxx:37
std::random_access_iterator_tag iterator_category
Definition: row.hxx:285
result_size_type size_type
Definition: result.hxx:75
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:489
difference_type operator-(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:478
Internal items for libpqxx' own use. Do not use these yourself.
Definition: composite.hxx:83
field const value_type
Definition: row.hxx:286
std::tuple< TYPE... > as() const
Extract entire row's values into a tuple.
Definition: row.hxx:200
void check_size(size_type expected) const
Throw usage_error if row size is not expected.
Definition: row.hxx:213
const_reverse_row_iterator & operator=(const_reverse_row_iterator const &r) noexcept
Definition: row.hxx:434
constexpr row_size_type col() const noexcept
Definition: field.hxx:263
constexpr bool operator>(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:510
const_reverse_row_iterator & operator+=(difference_type i) noexcept
Definition: row.hxx:451