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
67 [[nodiscard]] PQXX_PURE
bool operator==(
row const &)
const noexcept;
70 return not operator==(rhs);
74 [[nodiscard]] const_iterator begin() const noexcept;
75 [[nodiscard]] const_iterator cbegin() const noexcept;
76 [[nodiscard]] const_iterator end() const noexcept;
83 [[nodiscard]]
reference front() const noexcept;
84 [[nodiscard]]
reference back() const noexcept;
103 [[nodiscard]]
size_type size() const noexcept {
return m_end - m_begin; }
106 void swap(
row &) noexcept;
118 [[nodiscard]] size_type column_number(
zview col_name)
const;
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));
147 [[nodiscard]] size_type table_column(size_type)
const;
152 return table_column(column_number(col_name));
170 [[nodiscard]]
row slice(size_type sbegin, size_type send)
const;
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>>();
315 return col() == i.
col();
319 return col() != i.
col();
323 return col() < i.
col();
327 return col() <= i.
col();
331 return col() > i.
col();
335 return col() >= i.
col();
377 [[nodiscard]] PQXX_PURE iterator_type base() const noexcept;
383 using iterator_type::operator->;
384 using iterator_type::operator*;
393 iterator_type::operator=(r);
398 iterator_type::operator--();
404 iterator_type::operator++();
410 iterator_type::operator-=(i);
415 iterator_type::operator+=(i);
432 [[nodiscard]] difference_type
435 return rhs.const_row_iterator::operator-(*this);
446 return iterator_type::operator==(rhs);
451 return !operator==(rhs);
456 return iterator_type::operator>(rhs);
460 return iterator_type::operator>=(rhs);
464 return iterator_type::operator<(rhs);
468 return iterator_type::operator<=(rhs);
486 inline const_row_iterator
500 template<
typename Tuple, std::
size_t index>
501 inline void row::extract_value(Tuple &t)
const
504 field const f{*
this, index};
505 std::get<index>(t) = from_string<field_type>(f);
509 #include "pqxx/internal/compiler-internal-post.hxx"
const_row_iterator operator-(difference_type) const
Definition: row.hxx:487
int result_size_type
Number of rows in a result set.
Definition: types.hxx:18
const_row_iterator(field const &F) noexcept
Definition: row.hxx:265
const_iterator cend() const noexcept
Definition: row.cxx:48
const_reverse_row_iterator operator-(difference_type i)
Definition: row.hxx:428
bool operator==(const_row_iterator const &i) const
Definition: row.hxx:313
bool operator>=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:466
size_type column_number(zview col_name) const
Number of given column (throws exception if it doesn't exist).
Definition: row.cxx:164
bool operator<(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:454
row & operator=(row &&)=default
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
const_reverse_row_iterator crend() const
Definition: row.cxx:84
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:449
bool operator!=(row const &rhs) const noexcept
Definition: row.hxx:68
const_result_iterator operator+(result::difference_type o, const_result_iterator const &i)
Definition: result_iterator.hxx:329
const_iterator begin() const noexcept
Definition: row.cxx:30
const_reverse_row_iterator(const_reverse_row_iterator &&)=default
row_size_type size_type
Definition: row.hxx:259
void check_size(size_type expected) const
Throw usage_error if row size is not expected.
Definition: row.hxx:197
const_row_iterator & operator=(const_row_iterator &&)=default
row & operator=(row const &)=default
PQXX_PURE bool operator==(row const &) const noexcept
Definition: row.cxx:90
const_row_iterator(const_row_iterator &&)=default
const_reverse_row_iterator crbegin() const
Definition: row.cxx:72
row_difference_type difference_type
Definition: row.hxx:260
reference operator[](size_type) const noexcept
Definition: row.cxx:104
pointer operator->() const
Definition: row.hxx:273
PQXX_PURE bool empty() const noexcept
Definition: row.cxx:197
const_iterator end() const noexcept
Definition: row.cxx:42
Internal items for libpqxx' own use. Do not use these yourself.
Definition: composite.hxx:74
size_type table_column(zview col_name) const
What column number in its table did this result column come from?
Definition: row.hxx:150
bool operator>(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:462
const_row_iterator & operator++()
Definition: row.hxx:285
row_size_type column_number(zview name) const
Number of given column (throws exception if it doesn't exist).
Definition: result.cxx:368
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:193
const_row_iterator()=default
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:357
Invalid argument passed to libpqxx, similar to std::invalid_argument.
Definition: except.hxx:172
bool operator!=(const_row_iterator const &i) const
Definition: row.hxx:317
result_size_type size_type
Definition: result_iterator.hxx:42
row_difference_type difference_type
Definition: row.hxx:49
bool operator<=(const_row_iterator const &i) const
Definition: row.hxx:325
size_type table_column(size_type) const
What column number in its table did this result column come from?
Definition: row.cxx:158
oid column_table(zview col_name) const
What table did this column come from?
Definition: row.hxx:134
const_reverse_row_iterator rend() const
Definition: row.cxx:78
bool operator>=(const_row_iterator const &i) const
Definition: row.hxx:333
Reference to a field in a result set.
Definition: field.hxx:34
const_row_iterator & operator-=(difference_type i)
Definition: row.hxx:302
field const value_type
Definition: row.hxx:257
Reference to one row in a result.
Definition: row.hxx:46
difference_type operator-(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:433
bool operator<=(const_reverse_row_iterator const &rhs) const
Definition: row.hxx:458
oid column_type(zview col_name) const
Return a column's type.
Definition: row.hxx:125
result m_result
Result set of which this is one row.
Definition: row.hxx:215
const_row_iterator & operator=(const_row_iterator const &)=default
oid column_table(size_type col_num) const
What table did this column come from?
Definition: row.cxx:152
reference at(size_type) const
Definition: row.cxx:137
const_reverse_row_iterator & operator+=(difference_type i)
Definition: row.hxx:408
field_size_type size_type
Definition: field.hxx:36
row_size_type col() const noexcept
Definition: field.hxx:257
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:254
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:165
std::random_access_iterator_tag iterator_category
Definition: row.hxx:256
int row_difference_type
Difference between row sizes.
Definition: types.hxx:27
void convert(Tuple &t) const
Convert entire row to tuple fields, without checking row size.
Definition: row.hxx:207
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:444
const_reverse_row_iterator & operator-=(difference_type i)
Definition: row.hxx:413
result::size_type idx() const noexcept
Definition: field.hxx:256
const_row_iterator & operator+=(difference_type i)
Definition: row.hxx:297
const_row_iterator(row const &T, row_size_type C) noexcept
Definition: row.hxx:264
field const * pointer
Definition: row.hxx:258
const_reverse_row_iterator(const_reverse_row_iterator const &)=default
row slice(size_type sbegin, size_type send) const
Definition: row.cxx:185
const_iterator cbegin() const noexcept
Definition: row.cxx:36
oid column_type(size_type) const
Return a column's type.
Definition: row.cxx:146
const_reverse_row_iterator operator++()
Definition: row.hxx:396
bool operator<(const_row_iterator const &i) const
Definition: row.hxx:321
const_reverse_row_iterator operator+(difference_type i) const
Definition: row.hxx:424
std::tuple< TYPE... > as() const
Definition: row.hxx:184
reference back() const noexcept
Definition: row.cxx:60
result_size_type size_type
Definition: result.hxx:73
size_type m_begin
First column in slice. This row ignores lower-numbered columns.
Definition: row.hxx:223
const_reverse_row_iterator rbegin() const
Definition: row.cxx:66
PQXX_PURE row_size_type num() const
Definition: field.hxx:92
const_row_iterator operator+(difference_type) const
Definition: row.hxx:474
result::size_type num() const
Definition: row.hxx:156
PQXX_PURE iterator_type base() const noexcept
Definition: row.cxx:220
const_reverse_row_iterator & operator--()
Definition: row.hxx:402
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:24
result const & home() const noexcept
Definition: field.hxx:255
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:38
bool operator>(const_row_iterator const &i) const
Definition: row.hxx:329
const_reverse_row_iterator()=default
const_reverse_row_iterator(super const &rhs) noexcept
Definition: row.hxx:371
const_row_iterator(const_row_iterator const &)=default
row_size_type size_type
Definition: row.hxx:48
Result set containing data returned by a query or command.
Definition: result.hxx:71
void swap(row &) noexcept
Definition: row.cxx:116
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
const_row_iterator & operator--()
Definition: row.hxx:291
reference front() const noexcept
Definition: row.cxx:54