16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
28 template<
typename... T>
class result_iter;
60 row() noexcept = default;
61 row(
row &&) noexcept = default;
62 row(
row const &) noexcept = default;
63 row &operator=(
row const &) noexcept = default;
64 row &operator=(
row &&) noexcept = default;
70 [[nodiscard]]
PQXX_PURE bool operator==(
row const &) const noexcept;
71 [[nodiscard]]
bool operator!=(
row const &rhs) const noexcept
77 [[nodiscard]] const_iterator begin() const noexcept;
78 [[nodiscard]] const_iterator cbegin() const noexcept;
79 [[nodiscard]] const_iterator end() const noexcept;
80 [[nodiscard]] const_iterator cend() const noexcept;
86 [[nodiscard]] reference front() const noexcept;
87 [[nodiscard]] reference back() const noexcept;
94 [[nodiscard]] reference operator[](size_type) const noexcept;
98 [[nodiscard]] reference operator[](
zview col_name) const;
100 reference at(size_type) const;
104 reference at(
zview col_name) const;
108 return m_end - m_begin;
121 [[nodiscard]] size_type column_number(
zview col_name)
const;
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));
150 [[nodiscard]] size_type table_column(size_type)
const;
155 return table_column(column_number(col_name));
173 template<
typename Tuple>
void to(Tuple &t)
const
175 check_size(std::tuple_size_v<Tuple>);
188 template<
typename... TYPE> std::tuple<TYPE...>
as()
const
190 check_size(
sizeof...(TYPE));
191 using seq = std::make_index_sequence<
sizeof...(TYPE)>;
192 return get_tuple<std::tuple<TYPE...>>(seq{});
204 check_size(std::tuple_size_v<TUPLE>);
205 using seq = std::make_index_sequence<std::tuple_size_v<TUPLE>>;
206 return get_tuple<TUPLE>(seq{});
209 [[deprecated(
"Swap iterators, not rows.")]]
void swap(
row &) noexcept;
222 [[deprecated("Row slicing is going away. File a bug if you need it.")]]
row
223 slice(size_type sbegin, size_type send) const;
226 [[nodiscard, deprecated("Row slicing is going away.")]]
PQXX_PURE bool
227 empty() const noexcept;
237 if (size() != expected)
239 "Tried to extract ", expected,
" field(s) from a row of ", size(),
245 template<
typename Tuple>
void convert(Tuple &t)
const
247 extract_fields(t, std::make_index_sequence<std::tuple_size_v<Tuple>>{});
269 template<
typename Tuple, std::size_t... indexes>
270 void extract_fields(Tuple &t, std::index_sequence<indexes...>)
const
272 (extract_value<Tuple, indexes>(t), ...);
275 template<
typename Tuple, std::
size_t index>
276 void extract_value(Tuple &t)
const;
279 template<
typename TUPLE, std::size_t... indexes>
280 auto get_tuple(std::index_sequence<indexes...>)
const
282 return std::make_tuple(get_field<TUPLE, indexes>()...);
286 template<
typename TUPLE, std::
size_t index>
auto get_field()
const
288 return (*
this)[index].as<std::tuple_element_t<index, TUPLE>>();
306 #include "pqxx/internal/ignore-deprecated-post.hxx"
308 field{t.m_result, t.m_index, c}
311 const_row_iterator(const_row_iterator
const &) noexcept = default;
312 const_row_iterator(const_row_iterator &&) noexcept = default;
318 [[nodiscard]] constexpr
pointer operator->() const noexcept {
return this; }
358 [[nodiscard]] constexpr
bool
361 return col() == i.
col();
363 [[nodiscard]] constexpr
bool
366 return col() != i.
col();
368 [[nodiscard]] constexpr
bool
371 return col() < i.
col();
373 [[nodiscard]] constexpr
bool
376 return col() <= i.
col();
378 [[nodiscard]] constexpr
bool
381 return col() > i.
col();
383 [[nodiscard]] constexpr
bool
386 return col() >= i.
col();
395 operator+(difference_type) const noexcept;
401 operator-(difference_type) const noexcept;
402 [[nodiscard]] inline difference_type
405 [[nodiscard]] inline
field operator[](difference_type offset) const noexcept
407 return *(*
this + offset);
436 [[nodiscard]]
PQXX_PURE iterator_type base() const noexcept;
442 using iterator_type::operator->;
443 using iterator_type::operator*;
450 const_reverse_row_iterator &
453 iterator_type::operator=(r);
458 iterator_type::operator--();
464 iterator_type::operator++();
470 iterator_type::operator-=(i);
475 iterator_type::operator+=(i);
494 [[nodiscard]] difference_type
497 return rhs.const_row_iterator::operator-(*this);
501 return *(*
this + offset);
520 [[nodiscard]] constexpr
bool
523 return iterator_type::operator>(rhs);
525 [[nodiscard]] constexpr
bool
528 return iterator_type::operator>=(rhs);
530 [[nodiscard]] constexpr
bool
533 return iterator_type::operator<(rhs);
535 [[nodiscard]] constexpr
bool
538 return iterator_type::operator<=(rhs);
549 row{home(), idx(), home().columns()},
559 inline const_row_iterator
564 row{home(), idx(), home().columns()},
575 template<
typename Tuple, std::
size_t index>
576 inline void row::extract_value(Tuple &t)
const
580 std::get<index>(t) = from_string<field_type>(f);
const_row_iterator operator-(difference_type) const noexcept
Definition: row.hxx:560
constexpr row_size_type col() const noexcept
Definition: field.hxx:292
std::string concat(TYPE...item)
Efficiently combine a bunch of items into one big string.
Definition: concat.hxx:31
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:37
const_reverse_row_iterator operator-(difference_type i) noexcept
Definition: row.hxx:490
constexpr bool operator==(const_row_iterator const &i) const noexcept
Definition: row.hxx:359
const_row_iterator & operator--() noexcept
Definition: row.hxx:336
row_size_type size_type
Definition: row.hxx:51
constexpr bool operator!=(const_row_iterator const &i) const noexcept
Definition: row.hxx:364
const_result_iterator operator+(result::difference_type o, const_result_iterator const &i)
Definition: result_iterator.hxx:356
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:248
constexpr bool operator>(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:531
Internal items for libpqxx' own use. Do not use these yourself.
Definition: encodings.cxx:32
bool operator==(stream_query_end_iterator, stream_query_input_iterator< TYPE... > const &i)
Definition: stream_query_impl.hxx:135
constexpr result::size_type num() const noexcept
Definition: row.hxx:159
field_size_type size_type
Definition: field.hxx:37
const_row_iterator(field const &F) noexcept
Definition: row.hxx:310
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:510
reference operator*() const noexcept
Definition: row.hxx:319
Reference to one row in a result.
Definition: row.hxx:46
const_row_iterator & operator-=(difference_type i) noexcept
Definition: row.hxx:347
row_difference_type difference_type
Definition: row.hxx:301
const_row_iterator(row const &t, row_size_type c) noexcept
End a code block started by "ignore-deprecated-pre.hxx".
Definition: row.hxx:307
const_row_iterator & operator+=(difference_type i) noexcept
Definition: row.hxx:342
TUPLE as_tuple() const
Convert to a given tuple of values,.
Definition: row.hxx:202
constexpr result::size_type rownumber() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:112
const_reverse_row_iterator operator+(difference_type i) const noexcept
Definition: row.hxx:485
const_reverse_row_iterator & operator--() noexcept
Definition: row.hxx:462
void to(Tuple &t) const
Extract entire row's values into a tuple.
Definition: row.hxx:173
const_reverse_row_iterator & operator-=(difference_type i) noexcept
Definition: row.hxx:473
const_reverse_row_iterator operator++() noexcept
Definition: row.hxx:456
const_row_iterator operator+(difference_type) const noexcept
Definition: row.hxx:545
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:46
Result set containing data returned by a query or command.
Definition: result.hxx:91
int result_size_type
Number of rows in a result set.
Definition: types.hxx:40
field const value_type
Definition: row.hxx:298
constexpr bool operator>=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:536
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:515
oid column_type(zview col_name) const
Return a column's type.
Definition: row.hxx:128
difference_type operator-(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:495
constexpr bool operator>(const_row_iterator const &i) const noexcept
Definition: row.hxx:379
oid column_table(zview col_name) const
What table did this column come from?
Definition: row.hxx:137
field operator[](difference_type offset) const noexcept
Definition: row.hxx:499
const_reverse_row_iterator & operator+=(difference_type i) noexcept
Definition: row.hxx:468
result m_result
Result set of which this is one row.
Definition: row.hxx:253
row_difference_type difference_type
Definition: row.hxx:52
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
Reference to a field in a result set.
Definition: field.hxx:34
constexpr bool operator>=(const_row_iterator const &i) const noexcept
Definition: row.hxx:384
unsigned int oid
PostgreSQL database row identifier.
Definition: libpq-forward.hxx:33
int row_difference_type
Difference between row sizes.
Definition: types.hxx:49
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:414
result_size_type size_type
Definition: result.hxx:94
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:294
void convert(Tuple &t) const
Convert entire row to tuple fields, without checking row size.
Definition: row.hxx:245
strip_t< decltype(*std::begin(std::declval< CONTAINER >()))> value_type
The type of a container's elements.
Definition: types.hxx:108
std::tuple< TYPE... > as() const
Extract entire row's values into a tuple.
Definition: row.hxx:188
std::random_access_iterator_tag iterator_category
Definition: row.hxx:297
std::remove_cv_t< std::remove_reference_t< TYPE >> strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition: types.hxx:92
field const * pointer
Definition: row.hxx:299
result::size_type m_index
Row number.
Definition: row.hxx:260
Iterator for looped unpacking of a result.
Definition: result_iter.hxx:26
size_type table_column(zview col_name) const
What column number in its table did this result column come from?
Definition: row.hxx:153