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" 43 class PQXX_LIBEXPORT
row 57 row(
row const &) =
default;
58 row &operator=(
row const &) =
default;
59 row &operator=(
row &&) =
default;
65 [[nodiscard]] PQXX_PURE
bool operator==(
row const &)
const noexcept;
68 return not operator==(rhs);
72 [[nodiscard]] const_iterator begin() const noexcept;
73 [[nodiscard]] const_iterator cbegin() const noexcept;
74 [[nodiscard]] const_iterator end() const noexcept;
75 [[nodiscard]] const_iterator cend() const noexcept;
81 [[nodiscard]] reference front() const noexcept;
82 [[nodiscard]] reference back() const noexcept;
89 [[nodiscard]] reference operator[](size_type) const noexcept;
93 [[nodiscard]] reference operator[](
zview col_name) const;
95 reference at(size_type) const;
99 reference at(
zview col_name) const;
101 [[nodiscard]]
size_type size() const noexcept {
return m_end - m_begin; }
104 void swap(
row &) noexcept;
116 [[nodiscard]] size_type column_number(
zview col_name)
const;
120 [[nodiscard]] oid column_type(size_type)
const;
125 return column_type(column_number(col_name));
129 [[nodiscard]] oid column_table(size_type col_num)
const;
134 return column_table(column_number(col_name));
145 [[nodiscard]] size_type table_column(size_type)
const;
150 return table_column(column_number(col_name));
168 [[nodiscard]]
row slice(size_type sbegin, size_type send)
const;
171 [[nodiscard]] PQXX_PURE
bool empty() const noexcept;
176 template<typename Tuple>
void to(Tuple &t)
const 178 check_size(std::tuple_size_v<Tuple>);
190 if (size() != expected)
192 "Tried to extract " +
to_string(expected) +
193 " field(s) from a row of " +
to_string(size()) +
"."};
198 template<
typename Tuple>
void convert(Tuple &t)
const 200 constexpr
auto tup_size{std::tuple_size_v<Tuple>};
201 extract_fields(t, std::make_index_sequence<tup_size>{});
219 template<
typename Tuple, std::size_t... indexes>
220 void extract_fields(Tuple &t, std::index_sequence<indexes...>)
const 222 (extract_value<Tuple, indexes>(t), ...);
225 template<
typename Tuple, std::
size_t index>
226 void extract_value(Tuple &t)
const;
244 const_row_iterator(const_row_iterator
const &) =
default;
245 const_row_iterator(const_row_iterator &&) =
default;
293 return col() == i.
col();
297 return col() != i.
col();
301 return col() < i.
col();
305 return col() <= i.
col();
309 return col() > i.
col();
313 return col() >= i.
col();
327 [[nodiscard]]
inline difference_type
355 [[nodiscard]] PQXX_PURE iterator_type base() const noexcept;
361 using iterator_type::operator->;
362 using iterator_type::operator*;
371 iterator_type::operator=(r);
376 iterator_type::operator--();
382 iterator_type::operator++();
388 iterator_type::operator-=(i);
393 iterator_type::operator+=(i);
410 [[nodiscard]] difference_type
413 return rhs.const_row_iterator::operator-(*this);
424 return iterator_type::operator==(rhs);
429 return !operator==(rhs);
434 return iterator_type::operator>(rhs);
438 return iterator_type::operator>=(rhs);
442 return iterator_type::operator<(rhs);
446 return iterator_type::operator<=(rhs);
464 inline const_row_iterator
478 template<
typename Tuple, std::
size_t index>
479 inline void row::extract_value(Tuple &t)
const 482 field const f{*
this, index};
483 std::get<index>(t) = from_string<field_type>(f);
487 #include "pqxx/internal/compiler-internal-post.hxx" bool operator==(const_row_iterator const &i) const
Definition: row.hxx:291
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:36
bool operator>=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:444
std::random_access_iterator_tag iterator_category
Definition: row.hxx:234
reference operator*() const
Definition: row.hxx:252
size_type table_column(zview col_name) const
What column number in its table did this result column come from?
Definition: row.hxx:148
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:164
const_reverse_row_iterator operator++()
Definition: row.hxx:374
const_reverse_row_iterator operator-(difference_type i)
Definition: row.hxx:406
const_reverse_row_iterator & operator-=(difference_type i)
Definition: row.hxx:391
const_row_iterator & operator--()
Definition: row.hxx:269
void convert(Tuple &t) const
Convert entire row to tuple fields, without checking row size.
Definition: row.hxx:198
PQXX_PURE row_size_type num() const
Definition: field.hxx:92
Reference to a field in a result set.
Definition: field.hxx:33
row_size_type size_type
Definition: row.hxx:46
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:231
oid column_table(zview col_name) const
What table did this column come from?
Definition: row.hxx:132
result const & home() const noexcept
Definition: field.hxx:230
field const * pointer
Definition: row.hxx:236
difference_type operator-(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:411
int row_difference_type
Difference between row sizes.
Definition: types.hxx:27
const_reverse_row_iterator(super const &rhs) noexcept
Definition: row.hxx:349
std::string to_string(field const &value)
Convert a field to a string.
Definition: result.cxx:498
result::size_type idx() const noexcept
Definition: field.hxx:231
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition: util.hxx:120
pointer operator->() const
Definition: row.hxx:251
const_row_iterator & operator-=(difference_type i)
Definition: row.hxx:280
row_difference_type difference_type
Definition: row.hxx:238
row_difference_type difference_type
Definition: row.hxx:47
result::size_type num() const
Definition: row.hxx:154
const_row_iterator & operator++()
Definition: row.hxx:263
const_result_iterator operator+(result::difference_type o, const_result_iterator const &i)
Definition: result_iterator.hxx:329
const_row_iterator(field const &F) noexcept
Definition: row.hxx:243
Private namespace for libpqxx's internal use; do not access.
Definition: composite.hxx:70
row_size_type size_type
Definition: row.hxx:237
const_row_iterator operator+(difference_type) const
Definition: row.hxx:452
const_reverse_row_iterator & operator--()
Definition: row.hxx:380
const_reverse_row_iterator operator+(difference_type i) const
Definition: row.hxx:402
result::size_type rownumber() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:107
bool operator>(const_row_iterator const &i) const
Definition: row.hxx:307
field_size_type size_type
Definition: field.hxx:36
bool operator<=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:436
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:303
int result_size_type
Number of rows in a result set.
Definition: types.hxx:18
result_size_type size_type
Definition: result.hxx:73
bool operator>(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:440
field const value_type
Definition: row.hxx:235
bool operator!=(row const &rhs) const noexcept
Definition: row.hxx:66
const_reverse_row_iterator & operator+=(difference_type i)
Definition: row.hxx:386
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:427
void check_size(size_type expected) const
Throw usage_error if row size is not expected.
Definition: row.hxx:188
Reference to one row in a result.
Definition: row.hxx:43
const_row_iterator operator-(difference_type) const
Definition: row.hxx:465
bool operator<(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:432
bool operator>=(const_row_iterator const &i) const
Definition: row.hxx:311
const_row_iterator(row const &T, row_size_type C) noexcept
Definition: row.hxx:242
const_row_iterator & operator+=(difference_type i)
Definition: row.hxx:275
result m_result
Result set of which this is one row.
Definition: row.hxx:206
oid column_type(zview col_name) const
Return a column's type.
Definition: row.hxx:123
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:334
bool operator<(const_row_iterator const &i) const
Definition: row.hxx:299
row_size_type col() const noexcept
Definition: field.hxx:232
bool operator!=(const_row_iterator const &i) const
Definition: row.hxx:295
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:422
Result set containing data returned by a query or command.
Definition: result.hxx:70