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;
107 void swap(
row &) noexcept;
123 [[nodiscard]] oid column_type(
size_type)
const;
128 return column_type(column_number(col_name));
132 [[nodiscard]] oid column_table(
size_type col_num)
const;
137 return column_table(column_number(col_name));
153 return table_column(column_number(col_name));
174 [[nodiscard]] PQXX_PURE
bool empty()
const noexcept;
179 template<
typename Tuple>
void to(Tuple &t)
const 181 check_size(std::tuple_size_v<Tuple>);
185 template<
typename... TYPE> std::tuple<TYPE...>
as()
const 187 check_size(
sizeof...(TYPE));
188 using seq = std::make_index_sequence<
sizeof...(TYPE)>;
189 return get_tuple<std::tuple<TYPE...>>(seq{});
200 if (size() != expected)
202 "Tried to extract ", expected,
" field(s) from a row of ", size(),
208 template<
typename Tuple>
void convert(Tuple &t)
const 210 constexpr
auto tup_size{std::tuple_size_v<Tuple>};
211 extract_fields(t, std::make_index_sequence<tup_size>{});
229 template<
typename Tuple, std::size_t... indexes>
230 void extract_fields(Tuple &t, std::index_sequence<indexes...>)
const 232 (extract_value<Tuple, indexes>(t), ...);
235 template<
typename Tuple, std::
size_t index>
236 void extract_value(Tuple &t)
const;
239 template<
typename TUPLE, std::size_t... indexes>
240 auto get_tuple(std::index_sequence<indexes...>)
const 242 return std::make_tuple(get_field<TUPLE, indexes>()...);
246 template<
typename TUPLE, std::
size_t index>
auto get_field()
const 248 return (*
this)[index].as<std::tuple_element_t<index, TUPLE>>();
316 return col() == i.
col();
320 return col() != i.
col();
324 return col() < i.
col();
328 return col() <= i.
col();
332 return col() > i.
col();
336 return col() >= i.
col();
384 using iterator_type::operator->;
385 using iterator_type::operator*;
394 iterator_type::operator=(r);
399 iterator_type::operator--();
405 iterator_type::operator++();
411 iterator_type::operator-=(i);
416 iterator_type::operator+=(i);
436 return rhs.const_row_iterator::operator-(*this);
447 return iterator_type::operator==(rhs);
452 return !operator==(rhs);
457 return iterator_type::operator>(rhs);
461 return iterator_type::operator>=(rhs);
465 return iterator_type::operator<(rhs);
469 return iterator_type::operator<=(rhs);
501 template<
typename Tuple, std::
size_t index>
502 inline void row::extract_value(Tuple &t)
const 505 field const f{*
this, index};
506 std::get<index>(t) = from_string<field_type>(f);
510 #include "pqxx/internal/compiler-internal-post.hxx" bool operator!=(const_row_iterator const &i) const
Definition: row.hxx:318
const_row_iterator(row const &T, row_size_type C) noexcept
Definition: row.hxx:265
bool operator<(const_row_iterator const &i) const
Definition: row.hxx:322
const_row_iterator & operator-=(difference_type i)
Definition: row.hxx:303
const_reverse_row_iterator & operator+=(difference_type i)
Definition: row.hxx:409
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
bool operator>=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:467
int result_size_type
Number of rows in a result set.
Definition: types.hxx:18
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:357
bool operator>=(const_row_iterator const &i) const
Definition: row.hxx:334
result_size_type size_type
Definition: result.hxx:73
int row_difference_type
Difference between row sizes.
Definition: types.hxx:27
std::random_access_iterator_tag iterator_category
Definition: row.hxx:257
result m_result
Result set of which this is one row.
Definition: row.hxx:216
const_row_iterator operator-(difference_type) const
Definition: row.hxx:488
const_row_iterator operator+(difference_type) const
Definition: row.hxx:475
bool operator<=(const_row_iterator const &i) const
Definition: row.hxx:326
result::size_type num() const
Definition: row.hxx:157
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:254
const_reverse_row_iterator operator+(difference_type i) const
Definition: row.hxx:425
std::tuple< TYPE... > as() const
Definition: row.hxx:185
bool operator!=(row const &rhs) const noexcept
Definition: row.hxx:68
void convert(Tuple &t) const
Convert entire row to tuple fields, without checking row size.
Definition: row.hxx:208
bool operator==(const_row_iterator const &i) const
Definition: row.hxx:314
difference_type operator-(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:434
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:445
Reference to a field in a result set.
Definition: field.hxx:33
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:164
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:37
bool operator>(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:463
Reference to one row in a result.
Definition: row.hxx:45
const_reverse_row_iterator & operator--()
Definition: row.hxx:403
const_reverse_row_iterator(super const &rhs) noexcept
Definition: row.hxx:372
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:450
row_size_type size_type
Definition: row.hxx:48
Result set containing data returned by a query or command.
Definition: result.hxx:70
const_reverse_row_iterator operator-(difference_type i)
Definition: row.hxx:429
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition: util.hxx:143
reference operator*() const
Definition: row.hxx:275
void check_size(size_type expected) const
Throw usage_error if row size is not expected.
Definition: row.hxx:198
row_size_type col() const noexcept
Definition: field.hxx:261
const_result_iterator operator+(result::difference_type o, const_result_iterator const &i)
Definition: result_iterator.hxx:342
pointer operator->() const
Definition: row.hxx:274
field const * pointer
Definition: row.hxx:259
result::size_type rownumber() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:110
const_row_iterator & operator--()
Definition: row.hxx:292
const_row_iterator & operator+=(difference_type i)
Definition: row.hxx:298
Internal items for libpqxx' own use. Do not use these yourself.
Definition: composite.hxx:73
size_type table_column(zview col_name) const
What column number in its table did this result column come from?
Definition: row.hxx:151
const_row_iterator & operator++()
Definition: row.hxx:286
const_reverse_row_iterator operator++()
Definition: row.hxx:397
size_type size() const noexcept
Definition: row.hxx:103
oid column_type(zview col_name) const
Return a column's type.
Definition: row.hxx:126
row_difference_type difference_type
Definition: row.hxx:49
const_reverse_row_iterator & operator-=(difference_type i)
Definition: row.hxx:414
bool operator<(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:455
oid column_table(zview col_name) const
What table did this column come from?
Definition: row.hxx:135
const_row_iterator(field const &F) noexcept
Definition: row.hxx:266
field const value_type
Definition: row.hxx:258
bool operator<=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:459
field_size_type size_type
Definition: field.hxx:36
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
const_reverse_row_iterator & operator=(const_reverse_row_iterator const &r)
Definition: row.hxx:392
void to(Tuple &t) const
Extract entire row's values into a tuple.
Definition: row.hxx:179
row_difference_type difference_type
Definition: row.hxx:261
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:24
bool operator>(const_row_iterator const &i) const
Definition: row.hxx:330