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;
110 return m_end - m_begin;
113 [[deprecated(
"Swap iterators, not rows.")]]
void swap(
row &) noexcept;
129 [[nodiscard]] oid column_type(
size_type)
const;
134 return column_type(column_number(col_name));
138 [[nodiscard]] oid column_table(
size_type col_num)
const;
143 return column_table(column_number(col_name));
159 return table_column(column_number(col_name));
179 [[deprecated(
"Row slicing is going away. File a bug if you need it.")]]
row 183 [[nodiscard, deprecated(
"Row slicing is going away.")]] PQXX_PURE
bool 184 empty()
const noexcept;
189 template<
typename Tuple>
void to(Tuple &t)
const 191 check_size(std::tuple_size_v<Tuple>);
195 template<
typename... TYPE> std::tuple<TYPE...>
as()
const 197 check_size(
sizeof...(TYPE));
198 using seq = std::make_index_sequence<
sizeof...(TYPE)>;
199 return get_tuple<std::tuple<TYPE...>>(seq{});
210 if (size() != expected)
212 "Tried to extract ", expected,
" field(s) from a row of ", size(),
222 using seq = std::make_index_sequence<std::tuple_size_v<TUPLE>>;
223 return get_tuple<TUPLE>(seq{});
228 template<
typename Tuple>
void convert(Tuple &t)
const 230 extract_fields(t, std::make_index_sequence<std::tuple_size_v<Tuple>>{});
252 template<
typename Tuple, std::size_t... indexes>
253 void extract_fields(Tuple &t, std::index_sequence<indexes...>)
const 255 (extract_value<Tuple, indexes>(t), ...);
258 template<
typename Tuple, std::
size_t index>
259 void extract_value(Tuple &t)
const;
262 template<
typename TUPLE, std::size_t... indexes>
263 auto get_tuple(std::index_sequence<indexes...>)
const 265 return std::make_tuple(get_field<TUPLE, indexes>()...);
269 template<
typename TUPLE, std::
size_t index>
auto get_field()
const 271 return (*
this)[index].as<std::tuple_element_t<index, TUPLE>>();
287 #include "pqxx/internal/ignore-deprecated-pre.hxx" 289 #include "pqxx/internal/ignore-deprecated-post.hxx" 291 field{t.m_result, t.m_index, c}
343 [[nodiscard]] constexpr
bool 346 return col() == i.
col();
348 [[nodiscard]] constexpr
bool 351 return col() != i.
col();
353 [[nodiscard]] constexpr
bool 356 return col() < i.
col();
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();
422 using iterator_type::operator->;
423 using iterator_type::operator*;
433 iterator_type::operator=(r);
438 iterator_type::operator--();
445 iterator_type::operator++();
452 iterator_type::operator-=(i);
457 iterator_type::operator+=(i);
479 return rhs.const_row_iterator::operator-(*this);
490 return iterator_type::operator==(rhs);
495 return !operator==(rhs);
498 [[nodiscard]] constexpr
bool 501 return iterator_type::operator>(rhs);
503 [[nodiscard]] constexpr
bool 506 return iterator_type::operator>=(rhs);
508 [[nodiscard]] constexpr
bool 511 return iterator_type::operator<(rhs);
513 [[nodiscard]] constexpr
bool 516 return iterator_type::operator<=(rhs);
527 row{home(), idx(), home().columns()},
542 row{home(), idx(), home().columns()},
553 template<
typename Tuple, std::
size_t index>
554 inline void row::extract_value(Tuple &t)
const 557 field const f{m_result, m_index, index};
558 std::get<index>(t) = from_string<field_type>(f);
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:488
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
const_row_iterator & operator+=(difference_type i) noexcept
Definition: row.hxx:327
const_reverse_row_iterator & operator=(const_reverse_row_iterator const &r) noexcept
Definition: row.hxx:431
const_row_iterator & operator--() noexcept
Definition: row.hxx:321
Reference to one row in a result.
Definition: row.hxx:46
const_row_iterator & operator-=(difference_type i) noexcept
Definition: row.hxx:332
const_reverse_row_iterator & operator+=(difference_type i) noexcept
Definition: row.hxx:450
oid column_table(zview col_name) const
What table did this column come from?
Definition: row.hxx:141
constexpr size_type size() const noexcept
Definition: row.hxx:108
void convert(Tuple &t) const
Convert entire row to tuple fields, without checking row size.
Definition: row.hxx:228
std::tuple< TYPE... > as() const
Definition: row.hxx:195
field const value_type
Definition: row.hxx:281
const_reverse_row_iterator & operator--() noexcept
Definition: row.hxx:443
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:394
constexpr bool operator!=(const_row_iterator const &i) const noexcept
Definition: row.hxx:349
Reference to a field in a result set.
Definition: field.hxx:34
const_row_iterator(row const &t, row_size_type c) noexcept
End a code block started by "ignore-deprecated-pre.hxx".
Definition: row.hxx:290
field const * pointer
Definition: row.hxx:282
int row_difference_type
Difference between row sizes.
Definition: types.hxx:37
field_size_type size_type
Definition: field.hxx:37
void check_size(size_type expected) const
Throw usage_error if row size is not expected.
Definition: row.hxx:208
TUPLE as_tuple() const
Convert to a given tuple of values, don't check sizes.
Definition: row.hxx:220
row_size_type size_type
Definition: row.hxx:49
const_row_iterator operator+(const_row_iterator::difference_type o, const_row_iterator const &i) noexcept
Definition: row.hxx:531
size_type table_column(zview col_name) const
What column number in its table did this result column come from?
Definition: row.hxx:157
const_reverse_row_iterator operator-(difference_type i) noexcept
Definition: row.hxx:472
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:34
std::random_access_iterator_tag iterator_category
Definition: row.hxx:280
row_difference_type difference_type
Definition: row.hxx:284
result m_result
Result set of which this is one row.
Definition: row.hxx:236
constexpr result::size_type rownumber() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:116
const_reverse_row_iterator & operator-=(difference_type i) noexcept
Definition: row.hxx:455
constexpr pointer operator->() const noexcept
Definition: row.hxx:301
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:493
result_size_type size_type
Definition: result.hxx:76
const_row_iterator operator-(difference_type) const noexcept
Definition: row.hxx:538
const_reverse_row_iterator operator+(difference_type i) const noexcept
Definition: row.hxx:467
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:173
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
constexpr bool operator>(const_row_iterator const &i) const noexcept
Definition: row.hxx:364
constexpr row_size_type col() const noexcept
Definition: field.hxx:265
difference_type operator-(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:477
const_row_iterator(field const &F) noexcept
Definition: row.hxx:293
oid column_type(zview col_name) const
Return a column's type.
Definition: row.hxx:132
Result set containing data returned by a query or command.
Definition: result.hxx:73
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:37
Internal items for libpqxx' own use. Do not use these yourself.
Definition: composite.hxx:82
constexpr bool operator>(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:509
constexpr bool operator>=(const_row_iterator const &i) const noexcept
Definition: row.hxx:369
const_row_iterator operator+(difference_type) const noexcept
Definition: row.hxx:523
reference operator*() const noexcept
Definition: row.hxx:302
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:277
const_reverse_row_iterator operator++() noexcept
Definition: row.hxx:436
constexpr result::size_type num() const noexcept
Definition: row.hxx:163
void to(Tuple &t) const
Extract entire row's values into a tuple.
Definition: row.hxx:189
row_difference_type difference_type
Definition: row.hxx:50
const_row_iterator & operator++() noexcept
Definition: row.hxx:314
constexpr bool operator==(const_row_iterator const &i) const noexcept
Definition: row.hxx:344
int result_size_type
Number of rows in a result set.
Definition: types.hxx:28
constexpr bool operator>=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:514