16 #include "pqxx/compiler-public.hxx" 17 #include "pqxx/internal/compiler-internal-pre.hxx" 19 #include "pqxx/except.hxx" 20 #include "pqxx/field.hxx" 21 #include "pqxx/result.hxx" 23 #include "pqxx/internal/concat.hxx" 45 class PQXX_LIBEXPORT
row 59 row(
row const &) =
default;
60 row &operator=(
row const &) =
default;
61 row &operator=(
row &&) =
default;
67 [[nodiscard]] PQXX_PURE
bool operator==(
row const &)
const noexcept;
70 return not operator==(rhs);
83 [[nodiscard]]
reference front()
const noexcept;
84 [[nodiscard]]
reference back()
const noexcept;
105 PQXX_DEPRECATED(
"Swap iterators, not rows.")
106 void swap(
row &) noexcept;
122 [[nodiscard]] oid column_type(
size_type)
const;
127 return column_type(column_number(col_name));
131 [[nodiscard]] oid column_table(
size_type col_num)
const;
136 return column_table(column_number(col_name));
152 return table_column(column_number(col_name));
173 [[nodiscard]] PQXX_PURE
bool empty()
const noexcept;
178 template<
typename Tuple>
void to(Tuple &t)
const 180 check_size(std::tuple_size_v<Tuple>);
184 template<
typename... TYPE> std::tuple<TYPE...>
as()
const 186 check_size(
sizeof...(TYPE));
187 using seq = std::make_index_sequence<
sizeof...(TYPE)>;
188 return get_tuple<std::tuple<TYPE...>>(seq{});
199 if (size() != expected)
201 "Tried to extract ", expected,
" field(s) from a row of ", size(),
207 template<
typename Tuple>
void convert(Tuple &t)
const 209 constexpr
auto tup_size{std::tuple_size_v<Tuple>};
210 extract_fields(t, std::make_index_sequence<tup_size>{});
228 template<
typename Tuple, std::size_t... indexes>
229 void extract_fields(Tuple &t, std::index_sequence<indexes...>)
const 231 (extract_value<Tuple, indexes>(t), ...);
234 template<
typename Tuple, std::
size_t index>
235 void extract_value(Tuple &t)
const;
238 template<
typename TUPLE, std::size_t... indexes>
239 auto get_tuple(std::index_sequence<indexes...>)
const 241 return std::make_tuple(get_field<TUPLE, indexes>()...);
245 template<
typename TUPLE, std::
size_t index>
auto get_field()
const 247 return (*
this)[index].as<std::tuple_element_t<index, TUPLE>>();
263 #include "pqxx/internal/ignore-deprecated-pre.hxx" 266 #include "pqxx/internal/ignore-deprecated-post.hxx" 317 return col() == i.
col();
321 return col() != i.
col();
325 return col() < i.
col();
329 return col() <= i.
col();
333 return col() > i.
col();
337 return col() >= i.
col();
385 using iterator_type::operator->;
386 using iterator_type::operator*;
395 iterator_type::operator=(r);
400 iterator_type::operator--();
406 iterator_type::operator++();
412 iterator_type::operator-=(i);
417 iterator_type::operator+=(i);
437 return rhs.const_row_iterator::operator-(*this);
448 return iterator_type::operator==(rhs);
453 return !operator==(rhs);
458 return iterator_type::operator>(rhs);
462 return iterator_type::operator>=(rhs);
466 return iterator_type::operator<(rhs);
470 return iterator_type::operator<=(rhs);
502 template<
typename Tuple, std::
size_t index>
503 inline void row::extract_value(Tuple &t)
const 506 #include "pqxx/internal/ignore-deprecated-pre.hxx" 507 field const f{*
this, index};
508 #include "pqxx/internal/ignore-deprecated-post.hxx" 509 std::get<index>(t) = from_string<field_type>(f);
513 #include "pqxx/internal/compiler-internal-post.hxx" bool operator<(const_row_iterator const &i) const
Definition: row.hxx:323
bool operator>(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:464
const_reverse_row_iterator & operator+=(difference_type i)
Definition: row.hxx:410
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:253
const_row_iterator operator+(difference_type) const
Definition: row.hxx:476
std::tuple< TYPE... > as() const
Definition: row.hxx:184
row_difference_type difference_type
Definition: row.hxx:260
Internal items for libpqxx' own use. Do not use these yourself.
Definition: composite.hxx:73
bool operator<=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:460
field const value_type
Definition: row.hxx:257
oid column_type(zview col_name) const
Return a column's type.
Definition: row.hxx:125
oid column_table(zview col_name) const
What table did this column come from?
Definition: row.hxx:134
const_reverse_row_iterator & operator--()
Definition: row.hxx:404
result::size_type num() const
Definition: row.hxx:156
field const * pointer
Definition: row.hxx:258
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:164
size_type table_column(zview col_name) const
What column number in its table did this result column come from?
Definition: row.hxx:150
Result set containing data returned by a query or command.
Definition: result.hxx:70
pointer operator->() const
Definition: row.hxx:275
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
const_row_iterator operator-(difference_type) const
Definition: row.hxx:489
void to(Tuple &t) const
Extract entire row's values into a tuple.
Definition: row.hxx:178
const_reverse_row_iterator & operator=(const_reverse_row_iterator const &r)
Definition: row.hxx:393
row_size_type col() const noexcept
Definition: field.hxx:261
const_reverse_row_iterator operator-(difference_type i)
Definition: row.hxx:430
const_reverse_row_iterator(super const &rhs) noexcept
Definition: row.hxx:373
int result_size_type
Number of rows in a result set.
Definition: types.hxx:18
reference operator*() const
Definition: row.hxx:276
bool operator>=(const_row_iterator const &i) const
Definition: row.hxx:335
const_row_iterator & operator-=(difference_type i)
Definition: row.hxx:304
const_row_iterator(row const &T, row_size_type C) noexcept
Definition: row.hxx:265
bool operator!=(row const &rhs) const noexcept
Definition: row.hxx:68
const_row_iterator & operator+=(difference_type i)
Definition: row.hxx:299
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:451
difference_type operator-(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:435
bool operator==(const_row_iterator const &i) const
Definition: row.hxx:315
const_row_iterator & operator--()
Definition: row.hxx:293
result m_result
Result set of which this is one row.
Definition: row.hxx:215
void convert(Tuple &t) const
Convert entire row to tuple fields, without checking row size.
Definition: row.hxx:207
field_size_type size_type
Definition: field.hxx:36
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition: util.hxx:147
PQXX_PURE row_size_type num() const
Return row number. The first row is row 0, the second is row 1, etc.
Definition: field.hxx:96
Reference to one row in a result.
Definition: row.hxx:45
const_reverse_row_iterator & operator-=(difference_type i)
Definition: row.hxx:415
const_row_iterator(field const &F) noexcept
Definition: row.hxx:267
std::random_access_iterator_tag iterator_category
Definition: row.hxx:256
const_row_iterator & operator++()
Definition: row.hxx:287
bool operator<=(const_row_iterator const &i) const
Definition: row.hxx:327
Reference to a field in a result set.
Definition: field.hxx:33
result_size_type size_type
Definition: result.hxx:73
bool operator<(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:456
bool operator!=(const_row_iterator const &i) const
Definition: row.hxx:319
row_difference_type difference_type
Definition: row.hxx:49
const_reverse_row_iterator operator++()
Definition: row.hxx:398
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:24
row_size_type size_type
Definition: row.hxx:48
void check_size(size_type expected) const
Throw usage_error if row size is not expected.
Definition: row.hxx:197
const_reverse_row_iterator operator+(difference_type i) const
Definition: row.hxx:426
bool operator>(const_row_iterator const &i) const
Definition: row.hxx:331
size_type size() const noexcept
Definition: row.hxx:103
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:37
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:358
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:446
int row_difference_type
Difference between row sizes.
Definition: types.hxx:27
const_result_iterator operator+(result::difference_type o, const_result_iterator const &i)
Definition: result_iterator.hxx:357
bool operator>=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:468