libpqxx
The C++ client library for PostgreSQL
row.hxx
Go to the documentation of this file.
1 /* Definitions for the pqxx::result class and support classes.
2  *
3  * pqxx::result represents the set of result rows from a database query.
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/result instead.
6  *
7  * Copyright (c) 2000-2026, Jeroen T. Vermeulen.
8  *
9  * See COPYING for copyright license. If you did not receive a file called
10  * COPYING with this source code, please notify the distributor of this
11  * mistake, or contact the author.
12  */
13 #ifndef PQXX_ROW_HXX
14 #define PQXX_ROW_HXX
15 
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
18 #endif
19 
20 #include "pqxx/except.hxx"
21 #include "pqxx/field.hxx"
22 #include "pqxx/result.hxx"
23 
24 
25 namespace pqxx::internal
26 {
27 template<typename... T> class result_iter;
28 } // namespace pqxx::internal
29 
30 
31 namespace pqxx::internal::gate
32 {
33 class row_ref_const_result_iterator;
34 class row_ref_result;
35 class row_ref_row;
36 } // namespace pqxx::internal::gate
37 
38 
39 namespace pqxx
40 {
41 class field_ref;
42 
43 
45 
57 {
58 public:
64  using pointer = field_ref const *;
67 
68  row_ref() = default;
69  row_ref(row_ref const &) = default;
70  row_ref(row_ref &&) = default;
71  row_ref(result const &res, result_size_type index) :
72  m_result{&res}, m_index{index}
73  {}
74  ~row_ref() = default;
75 
76  row_ref &operator=(row_ref const &) noexcept = default;
77  row_ref &operator=(row_ref &&) noexcept = default;
78 
102  [[nodiscard]] PQXX_PURE bool operator==(row_ref const &rhs) const noexcept
103  {
104  return rhs.m_result == m_result and rhs.m_index == m_index;
105  }
106  [[nodiscard]] PQXX_PURE bool operator!=(row_ref const &rhs) const noexcept
107  {
108  return not operator==(rhs);
109  }
111 
112  [[nodiscard]] const_iterator cbegin() const noexcept;
113  [[nodiscard]] const_iterator begin() const noexcept;
114  [[nodiscard]] const_iterator end() const noexcept;
115  [[nodiscard]] const_iterator cend() const noexcept;
116 
121  [[nodiscard]] reference front() const noexcept;
122  [[nodiscard]] reference back() const noexcept;
123 
124  [[nodiscard]] const_reverse_row_iterator crbegin() const noexcept;
125  [[nodiscard]] const_reverse_row_iterator rbegin() const noexcept;
126  [[nodiscard]] const_reverse_row_iterator crend() const noexcept;
127  [[nodiscard]] const_reverse_row_iterator rend() const noexcept;
128 
129  [[nodiscard]] PQXX_PURE reference operator[](size_type i) const noexcept
130  {
131  return {home(), row_number(), i};
132  }
133 
134 #if defined(PQXX_HAVE_MULTIDIM)
135  // TODO: There's a proposal to permit a default value for loc.
146  [[nodiscard]] PQXX_PURE reference operator[](zview col_name, sl) const;
147 #endif // PQXX_HAVE_MULTIDIM
148 
158  [[nodiscard]] PQXX_PURE reference operator[](zview col_name) const;
159 
161  [[nodiscard]] reference at(size_type i, sl loc = sl::current()) const
162  {
163  if (m_result == nullptr)
164  throw usage_error{"Indexing uninitialised row.", loc};
165  if (std::cmp_less(i, 0))
166  throw usage_error{"Negative column index.", loc};
167  auto const sz{size()};
168  if (std::cmp_greater_equal(i, sz))
169  throw range_error{
170  std::format(
171  "Column index out of range: {} in a result of {} column(s).", i, sz),
172  loc};
173  return operator[](i);
174  }
175 
177 
183  [[nodiscard]] reference at(zview col_name, sl loc = sl::current()) const
184  {
185  if (m_result == nullptr)
186  throw usage_error{"Indexing uninitialised row.", loc};
187  return operator[](column_number(col_name, loc));
188  }
189 
190  [[nodiscard]] PQXX_PURE size_type size() const noexcept
191  {
192  return home().columns();
193  }
194 
196  [[nodiscard]] PQXX_PURE constexpr result::size_type
197  row_number() const noexcept
198  {
199  return m_index;
200  }
201 
207 
211  [[nodiscard]] size_type
212  column_number(zview col_name, sl = sl::current()) const;
213 
215 
219  [[nodiscard]] oid
220  column_type(size_type col_num, sl loc = sl::current()) const
221  {
222  return home().column_type(col_num, loc);
223  }
224 
226 
230  [[nodiscard]] oid column_type(zview col_name, sl loc = sl::current()) const
231  {
232  return column_type(column_number(col_name, loc), loc);
233  }
234 
236 
240  [[nodiscard]] oid column_table(size_type col_num, sl = sl::current()) const;
241 
243 
247  [[nodiscard]] oid column_table(zview col_name, sl loc = sl::current()) const
248  {
249  return column_table(column_number(col_name, loc), loc);
250  }
251 
253 
260  [[nodiscard]] size_type
261  table_column(size_type col_num, sl loc = sl::current()) const
262  {
263  return home().table_column(col_num, loc);
264  }
265 
267  [[nodiscard]] size_type
268  table_column(zview col_name, sl loc = sl::current()) const
269  {
270  return table_column(column_number(col_name, loc), loc);
271  }
273 
275 
283  template<typename Tuple> void to(Tuple &t, sl loc = sl::current()) const
284  {
285  check_size(std::tuple_size_v<Tuple>, loc);
286  convert(t, loc);
287  }
288 
290 
298  template<typename... TYPE>
299  [[nodiscard]] std::tuple<TYPE...> as(sl loc = sl::current()) const
300  {
301  return as_tuple<std::tuple<TYPE...>>(loc);
302  }
303 
305 
314  template<typename TUPLE>
315  [[nodiscard]] TUPLE as_tuple(sl loc = sl::current()) const
316  requires(requires(TUPLE t) { std::get<0>(t); })
317  {
318  check_size(std::tuple_size_v<TUPLE>, loc);
319  using seq = std::make_index_sequence<std::tuple_size_v<TUPLE>>;
320  return get_tuple<TUPLE>(seq{}, loc);
321  }
322 
324  [[nodiscard]] PQXX_PURE result const &home() const noexcept
325  {
326  return *m_result;
327  }
328 
329 private:
333  void offset(difference_type d) noexcept { m_index += d; }
334 
336  void check_size(size_type expected, sl loc) const
337  {
338  if (size() != expected)
339  throw usage_error{
340  std::format(
341  "Tried to extract {} field(s) from a row of {}.", expected, size()),
342  loc};
343  }
344 
345  template<typename... T> friend class pqxx::internal::result_iter;
347  template<typename Tuple> void convert(Tuple &t, sl loc) const
348  {
349  extract_fields(
350  t, std::make_index_sequence<std::tuple_size_v<Tuple>>{},
351  conversion_context{home().get_encoding_group(), loc});
352  }
353 
355  template<typename Tuple, std::size_t... indexes>
356  void extract_fields(Tuple &t, std::index_sequence<indexes...>, ctx c) const
357  {
358  (extract_value<Tuple, indexes>(t, c), ...);
359  }
360 
361  template<typename Tuple, std::size_t index>
362  void extract_value(Tuple &t, ctx) const;
363 
365  template<typename TUPLE, std::size_t... indexes>
366  [[nodiscard]] auto get_tuple(std::index_sequence<indexes...>, sl) const
367  {
368  return std::make_tuple(get_field<TUPLE, indexes>()...);
369  }
370 
372  template<typename TUPLE, std::size_t index>
373  [[nodiscard]] auto get_field() const
374  {
375  return (*this)[index].as<std::tuple_element_t<index, TUPLE>>();
376  }
377 
379  result const *m_result = nullptr;
380 
382 
386  result::size_type m_index = -1;
387 };
388 } // namespace pqxx
389 
390 
393 
394 
395 namespace pqxx
396 {
398 
414 class PQXX_LIBEXPORT row final
415 {
416 public:
417  // TODO: Set iterator nested types using std::iterator_traits.
426 
427  row() noexcept = default;
428  row(row &&) noexcept = default;
429  row(row const &) noexcept = default;
430  explicit row(row_ref const &ref) :
431  m_result{ref.home()},
432  m_index{ref.row_number()},
433  m_end{std::size(ref)}
434  {}
435  ~row() = default;
436  row &operator=(row const &) noexcept = default;
437  row &operator=(row &&) noexcept = default;
438 
462  [[nodiscard]] PQXX_PURE bool operator==(row const &rhs) const noexcept
463  {
464  return rhs.m_result == m_result and rhs.m_index == m_index;
465  }
466  [[nodiscard]] PQXX_PURE bool operator!=(row const &rhs) const noexcept
467  {
468  return not operator==(rhs);
469  }
471 
478  [[nodiscard]] PQXX_PURE const_iterator begin() const noexcept;
479  [[nodiscard]] PQXX_PURE const_iterator cbegin() const noexcept;
480  [[nodiscard]] PQXX_PURE const_iterator end() const noexcept;
481  [[nodiscard]] PQXX_PURE const_iterator cend() const noexcept;
482  [[nodiscard]] PQXX_PURE const_reverse_row_iterator rbegin() const noexcept;
483  [[nodiscard]] PQXX_PURE const_reverse_row_iterator crbegin() const noexcept;
484  [[nodiscard]] PQXX_PURE const_reverse_row_iterator rend() const noexcept;
485  [[nodiscard]] PQXX_PURE const_reverse_row_iterator crend() const noexcept;
487 
492  [[nodiscard]] field_ref front() const noexcept;
493  [[nodiscard]] field_ref back() const noexcept;
495 
503  [[nodiscard]] PQXX_PURE field_ref operator[](size_type) const noexcept;
504 
505 #if defined(PQXX_HAVE_MULTIDIM)
515  [[nodiscard]] PQXX_PURE field_ref operator[](zview col_name, sl loc) const
516  {
517  // TODO: There's a proposal to permit a default value for loc.
518  // Visual Studio 2022 says it has multi-dimensional indexing, but issues a
519  // bogus warning that this comma is a sequence operator and the first value
520  // is meaningless. If that were true, well, row_ref has no operator[] that
521  // takes just a source_location anyway so the call would have failed.
522  // Clearly the warning is a lie.
523 # if defined(_MSC_VER)
524 # pragma warning(push)
525 # pragma warning(disable : 4548)
526 # endif
527  return as_row_ref()[col_name, loc];
528 # if defined(_MSC_VER)
529 # pragma warning(pop)
530 # endif
531  }
532 #endif
533 
543  [[nodiscard]] PQXX_PURE field_ref operator[](zview col_name) const
544  {
545  return as_row_ref()[col_name];
546  }
547 
549  [[nodiscard]] field_ref at(size_type, sl = sl::current()) const;
550 
554  [[nodiscard]] field_ref at(zview col_name, sl = sl::current()) const;
555 
556  [[nodiscard]] PQXX_PURE constexpr size_type size() const noexcept
557  {
558  return m_end;
559  }
560 
562  [[nodiscard, deprecated("Use row_number().")]] constexpr result::size_type
563  rownumber() const noexcept
564  {
565  return m_index;
566  }
567 
569  [[nodiscard]] PQXX_PURE constexpr result::size_type
570  row_number() const noexcept
571  {
572  return m_index;
573  }
574 
580  [[nodiscard]] size_type
581  column_number(zview col_name, sl loc = sl::current()) const
582  {
583  return as_row_ref().column_number(col_name, loc);
584  }
585 
587  [[nodiscard]] oid
588  column_type(size_type col_num, sl loc = sl::current()) const
589  {
590  return as_row_ref().column_type(col_num, loc);
591  }
592 
594  [[nodiscard]] oid column_type(zview col_name, sl loc = sl::current()) const
595  {
596  return column_type(column_number(col_name, loc), loc);
597  }
598 
600  [[nodiscard]] oid
601  column_table(size_type col_num, sl loc = sl::current()) const
602  {
603  return as_row_ref().column_table(col_num, loc);
604  }
605 
607  [[nodiscard]] oid column_table(zview col_name, sl loc = sl::current()) const
608  {
609  return column_table(column_number(col_name, loc), loc);
610  }
611 
613 
620  [[nodiscard]] size_type
621  table_column(size_type col, sl loc = sl::current()) const
622  {
623  return as_row_ref().table_column(col, loc);
624  }
625 
627  [[nodiscard]] size_type
628  table_column(zview col_name, sl loc = sl::current()) const
629  {
630  return as_row_ref().table_column(col_name, loc);
631  }
633 
634  [[nodiscard]] PQXX_PURE constexpr result::size_type num() const noexcept
635  {
636  return row_number();
637  }
638 
640 
648  template<typename Tuple> void to(Tuple &t, sl loc = sl::current()) const
649  {
650  check_size(std::tuple_size_v<Tuple>, loc);
651  convert(t, loc);
652  }
653 
655 
663  template<typename... TYPE>
664  [[nodiscard]] std::tuple<TYPE...> as(sl loc = sl::current()) const
665  {
666  return as_row_ref().as<TYPE...>(loc);
667  }
668 
670 
679  template<typename TUPLE>
680  [[nodiscard]] TUPLE as_tuple(sl loc = sl::current()) const
681  requires(requires(TUPLE t) { std::get<0>(t); })
682  {
683  return as_row_ref().as_tuple<TUPLE>(loc);
684  }
685 
686  [[deprecated("Swap iterators, not rows.")]] void swap(row &) noexcept;
687 
688 private:
690 
694  [[nodiscard]] row_ref as_row_ref() const noexcept
695  {
696  return {m_result, row_number()};
697  }
698 
699  row(result r, result_size_type index, size_type cols) noexcept;
700 
702  void check_size(size_type expected, sl loc) const
703  {
704  if (size() != expected)
705  throw usage_error{
706  std::format(
707  "Tried to extract {} field(s) from a row of {}.", expected, size()),
708  loc};
709  }
710 
712  [[nodiscard]] result const &home() const { return m_result; }
713 
715  template<typename Tuple> void convert(Tuple &t, sl loc) const
716  {
717  auto ref{as_row_ref()};
718  pqxx::internal::gate::row_ref_row{ref}.extract_fields(
719  t, std::make_index_sequence<std::tuple_size_v<Tuple>>{},
720  conversion_context{home().get_encoding_group(), loc});
721  }
722 
723  // TODO: Define gate.
724  friend class field;
725 
727  result m_result;
728 
730 
734  result::size_type m_index = 0;
735 
737  size_type m_end = 0;
738 };
739 
740 
742 
748 {
749 public:
750  using iterator_category = std::random_access_iterator_tag;
751  using value_type = field_ref const;
752  using pointer = field_ref const *;
756 
757  const_row_iterator() noexcept = default;
758  const_row_iterator(row_ref const &t, row_size_type c) noexcept :
759  m_field{t.home(), t.row_number(), c}
760  {}
761  explicit const_row_iterator(field_ref const &f) noexcept : m_field{f} {}
762  const_row_iterator(const_row_iterator const &) noexcept = default;
763  const_row_iterator(const_row_iterator &&) noexcept = default;
764  ~const_row_iterator() = default;
765 
767  PQXX_PURE [[nodiscard]] size_type col() const noexcept
768  {
769  return m_field.column_number();
770  }
771 
776  [[nodiscard]] PQXX_PURE PQXX_RETURNS_NONNULL constexpr pointer
777  operator->() const noexcept
778  {
779  return &m_field;
780  }
781  [[nodiscard]] PQXX_PURE reference operator*() const noexcept
782  {
783  return m_field;
784  }
786 
791  const_row_iterator &operator=(const_row_iterator const &) noexcept = default;
793 
794  const_row_iterator operator++(int) & noexcept;
795  const_row_iterator &operator++() noexcept
796  {
798  return *this;
799  }
800  const_row_iterator operator--(int) & noexcept;
802  {
804  return *this;
805  }
806 
808  {
810  return *this;
811  }
813  {
815  return *this;
816  }
818 
823  [[nodiscard]] bool operator==(const_row_iterator const &i) const noexcept
824  {
825  return col() == i.col();
826  }
827  [[nodiscard]] bool operator!=(const_row_iterator const &i) const noexcept
828  {
829  return col() != i.col();
830  }
831  [[nodiscard]] bool operator<(const_row_iterator const &i) const noexcept
832  {
833  return col() < i.col();
834  }
835  [[nodiscard]] bool operator<=(const_row_iterator const &i) const noexcept
836  {
837  return col() <= i.col();
838  }
839  [[nodiscard]] bool operator>(const_row_iterator const &i) const noexcept
840  {
841  return col() > i.col();
842  }
843  [[nodiscard]] bool operator>=(const_row_iterator const &i) const noexcept
844  {
845  return col() >= i.col();
846  }
848 
853  [[nodiscard]] inline const_row_iterator
854  operator+(difference_type) const noexcept;
855 
856  friend const_row_iterator
857  operator+(difference_type, const_row_iterator const &) noexcept;
858 
859  [[nodiscard]] inline const_row_iterator
860  operator-(difference_type) const noexcept;
861  [[nodiscard]] inline difference_type
862  operator-(const_row_iterator const &) const noexcept;
863 
864  [[nodiscard]] inline field_ref
865  operator[](difference_type offset) const noexcept
866  {
867  return *(*this + offset);
868  }
870 
871 private:
872  field_ref m_field;
873 };
874 
875 
878  : private const_row_iterator
879 {
880 public:
888 
889  const_reverse_row_iterator() noexcept = default;
891  default;
893 
894  explicit const_reverse_row_iterator(super const &rhs) noexcept :
895  const_row_iterator{rhs}
896  {
897  super::operator--();
898  }
900 
901  [[nodiscard]] PQXX_PURE iterator_type base() const noexcept;
902 
907  using iterator_type::operator->;
908  using iterator_type::operator*;
910 
916  operator=(const_reverse_row_iterator const &r) noexcept = default;
918  operator=(const_reverse_row_iterator &&r) noexcept = default;
919  const_reverse_row_iterator operator++() noexcept
920  {
921  iterator_type::operator--();
922  return *this;
923  }
924  const_reverse_row_iterator operator++(int) & noexcept;
926  {
927  iterator_type::operator++();
928  return *this;
929  }
930  const_reverse_row_iterator operator--(int) &;
932  {
933  iterator_type::operator-=(i);
934  return *this;
935  }
937  {
938  iterator_type::operator+=(i);
939  return *this;
940  }
942 
947  [[nodiscard]] const_reverse_row_iterator
948  operator+(difference_type i) const noexcept
949  {
950  return const_reverse_row_iterator{base() - i};
951  }
952  [[nodiscard]] const_reverse_row_iterator
954  {
955  return const_reverse_row_iterator{base() + i};
956  }
957  [[nodiscard]] difference_type
958  operator-(const_reverse_row_iterator const &rhs) const noexcept
959  {
960  return rhs.const_row_iterator::operator-(*this);
961  }
962  [[nodiscard]] inline field_ref
963  operator[](difference_type offset) const noexcept
964  {
965  return *(*this + offset);
966  }
968 
973  [[nodiscard]] bool
974  operator==(const_reverse_row_iterator const &rhs) const noexcept
975  {
976  return iterator_type::operator==(rhs);
977  }
978  [[nodiscard]] bool
979  operator!=(const_reverse_row_iterator const &rhs) const noexcept
980  {
981  return !operator==(rhs);
982  }
983 
984  [[nodiscard]] bool
985  operator<(const_reverse_row_iterator const &rhs) const noexcept
986  {
987  return iterator_type::operator>(rhs);
988  }
989  [[nodiscard]] bool
990  operator<=(const_reverse_row_iterator const &rhs) const noexcept
991  {
992  return iterator_type::operator>=(rhs);
993  }
994  [[nodiscard]] bool
995  operator>(const_reverse_row_iterator const &rhs) const noexcept
996  {
997  return iterator_type::operator<(rhs);
998  }
999  [[nodiscard]] bool
1000  operator>=(const_reverse_row_iterator const &rhs) const noexcept
1001  {
1002  return iterator_type::operator<=(rhs);
1003  }
1005 };
1006 
1007 
1008 const_row_iterator
1010 {
1011  return {
1012  {m_field.home(), m_field.row_number()},
1013  static_cast<row_size_type>(
1014  static_cast<difference_type>(m_field.column_number()) + o)};
1015 }
1016 
1019 {
1020  return i + o;
1021 }
1022 
1023 inline const_row_iterator
1025 {
1026  return {
1027  {m_field.home(), m_field.row_number()},
1028  static_cast<row_size_type>(
1029  static_cast<difference_type>(m_field.column_number()) - o)};
1030 }
1031 
1034 {
1035  return difference_type(m_field.column_number() - i.m_field.column_number());
1036 }
1037 
1038 
1039 template<typename Tuple, std::size_t index>
1040 inline void row_ref::extract_value(Tuple &t, ctx c) const
1041 {
1042  using field_type = std::remove_cvref_t<decltype(std::get<index>(t))>;
1043  field_ref const f{*m_result, m_index, index};
1044  std::get<index>(t) = from_string<field_type>(f, c);
1045 }
1046 
1047 
1049 {
1050  return {{home(), row_number()}, 0};
1051 }
1052 
1054 {
1055  return cbegin();
1056 }
1057 
1059 {
1060  return {{home(), row_number()}, home().columns()};
1061 }
1062 
1063 inline row_ref::const_iterator row_ref::end() const noexcept
1064 {
1065  return cend();
1066 }
1067 
1069 {
1070  return const_reverse_iterator{end()};
1071 }
1072 
1074 {
1075  return crbegin();
1076 }
1077 
1079 {
1080  return const_reverse_iterator{begin()};
1081 }
1082 
1084 {
1085  return crend();
1086 }
1087 
1088 inline field_ref row_ref::front() const noexcept
1089 {
1090  return {home(), row_number(), 0};
1091 }
1092 
1093 inline field_ref row_ref::back() const noexcept
1094 {
1095  return {home(), row_number(), home().columns() - 1};
1096 }
1097 
1098 inline row_size_type row_ref::column_number(zview col_name, sl loc) const
1099 {
1100  return home().column_number(col_name, loc);
1101 }
1102 
1103 inline oid row_ref::column_table(row_size_type col_num, sl loc) const
1104 {
1105  return home().column_table(col_num, loc);
1106 }
1107 
1108 inline row::const_iterator row::cbegin() const noexcept
1109 {
1110  return as_row_ref().cbegin();
1111 }
1112 
1113 inline row::const_iterator row::begin() const noexcept
1114 {
1115  return cbegin();
1116 }
1117 
1118 inline row::const_iterator row::cend() const noexcept
1119 {
1120  return {{m_result, row_number()}, m_end};
1121 }
1122 
1123 inline row::const_iterator row::end() const noexcept
1124 {
1125  return cend();
1126 }
1127 
1129 {
1130  return const_reverse_iterator{end()};
1131 }
1132 
1134 {
1135  return crbegin();
1136 }
1137 
1139 {
1140  return const_reverse_iterator{begin()};
1141 }
1142 
1144 {
1145  return crend();
1146 }
1147 } // namespace pqxx
1148 #endif
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:879
bool operator!=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:979
const_reverse_row_iterator & operator--() noexcept
Definition: row.hxx:925
const_reverse_row_iterator & operator+=(difference_type i) noexcept
Definition: row.hxx:931
bool operator>(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:995
difference_type operator-(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:958
const_reverse_row_iterator operator+(difference_type i) const noexcept
Definition: row.hxx:948
field_ref operator[](difference_type offset) const noexcept
Definition: row.hxx:963
bool operator==(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:974
const_reverse_row_iterator() noexcept=default
const_reverse_row_iterator operator-(difference_type i) noexcept
Definition: row.hxx:953
bool operator>=(const_reverse_row_iterator const &rhs) const noexcept
Definition: row.hxx:1000
const_reverse_row_iterator & operator-=(difference_type i) noexcept
Definition: row.hxx:936
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:748
field_ref const * pointer
Definition: row.hxx:752
bool operator<=(const_row_iterator const &i) const noexcept
Definition: row.hxx:835
const_row_iterator operator-(difference_type) const noexcept
Definition: row.hxx:1024
PQXX_PURE reference operator*() const noexcept
Definition: row.hxx:781
bool operator>(const_row_iterator const &i) const noexcept
Definition: row.hxx:839
const_row_iterator & operator--() noexcept
Definition: row.hxx:801
bool operator==(const_row_iterator const &i) const noexcept
Definition: row.hxx:823
const_row_iterator & operator-=(difference_type n) noexcept
Definition: row.hxx:812
const_row_iterator & operator+=(difference_type n) noexcept
Definition: row.hxx:807
bool operator!=(const_row_iterator const &i) const noexcept
Definition: row.hxx:827
const_row_iterator(const_row_iterator const &) noexcept=default
std::random_access_iterator_tag iterator_category
Definition: row.hxx:750
const_row_iterator & operator=(const_row_iterator &&) noexcept=default
PQXX_PURE size_type col() const noexcept
Current column number, if the iterator is pointing at a valid field.
Definition: row.hxx:767
field_ref operator[](difference_type offset) const noexcept
Definition: row.hxx:865
const_row_iterator(const_row_iterator &&) noexcept=default
row_size_type size_type
Definition: row.hxx:753
const_row_iterator() noexcept=default
bool operator>=(const_row_iterator const &i) const noexcept
Definition: row.hxx:843
const_row_iterator & operator=(const_row_iterator const &) noexcept=default
row_difference_type difference_type
Definition: row.hxx:754
PQXX_PURE constexpr PQXX_RETURNS_NONNULL pointer operator->() const noexcept
Definition: row.hxx:777
const_row_iterator(field_ref const &f) noexcept
Definition: row.hxx:761
field_ref const value_type
Definition: row.hxx:751
bool operator<(const_row_iterator const &i) const noexcept
Definition: row.hxx:831
const_row_iterator operator+(difference_type) const noexcept
Definition: row.hxx:1009
Lightweight reference to a field in a result set.
Definition: field.hxx:52
Reference to a field in a result set.
Definition: field.hxx:309
Definition: field_ref-const_row_iterator.hxx:15
Definition: row_ref-const_result_iterator.hxx:15
Definition: row_ref-result.hxx:15
Definition: row_ref-row.hxx:9
Iterator for looped unpacking of a result.
Definition: result_iter.hxx:31
Result set containing data returned by a query or command.
Definition: result.hxx:101
PQXX_PURE row_size_type columns() const noexcept
Number of columns in result.
Definition: result.cxx:551
result_size_type size_type
Definition: result.hxx:103
oid column_table(row_size_type col_num, sl=sl::current()) const
What table did this column come from?
Definition: result.cxx:473
row_size_type column_number(zview name, sl=sl::current()) const
Number of given column (throws exception if it doesn't exist).
Definition: result.cxx:462
Lightweight reference to one row in a result.
Definition: row.hxx:57
const_iterator cend() const noexcept
Definition: row.hxx:1058
const_reverse_row_iterator rend() const noexcept
Definition: row.hxx:1083
reference front() const noexcept
Definition: row.hxx:1088
TUPLE as_tuple(sl loc=sl::current()) const requires(requires(TUPLE t)
Convert to a given tuple of values,.
Definition: row.hxx:315
row_ref(result const &res, result_size_type index)
Definition: row.hxx:71
reference at(zview col_name, sl loc=sl::current()) const
Address field by name.
Definition: row.hxx:183
size_type column_number(zview col_name, sl=sl::current()) const
Number of given column (throws exception if it doesn't exist).
Definition: row.hxx:1098
size_type table_column(zview col_name, sl loc=sl::current()) const
What column number in its table did this result column come from?
Definition: row.hxx:268
void to(Tuple &t, sl loc=sl::current()) const
Extract entire row's values into a tuple.
Definition: row.hxx:283
row_ref()=default
row_difference_type difference_type
Definition: row.hxx:60
row_ref & operator=(row_ref const &) noexcept=default
reference back() const noexcept
Definition: row.hxx:1093
constexpr PQXX_PURE result::size_type row_number() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:197
field_ref const * pointer
Definition: row.hxx:64
~row_ref()=default
const_reverse_row_iterator crbegin() const noexcept
Definition: row.hxx:1068
oid column_table(size_type col_num, sl=sl::current()) const
What table did this column come from?
Definition: row.hxx:1103
oid column_type(size_type col_num, sl loc=sl::current()) const
Return a column's type.
Definition: row.hxx:220
reference at(size_type i, sl loc=sl::current()) const
Address a field by number, but check that the number is in range.
Definition: row.hxx:161
const_iterator cbegin() const noexcept
Definition: row.hxx:1048
oid column_table(zview col_name, sl loc=sl::current()) const
What table did this column come from?
Definition: row.hxx:247
PQXX_PURE bool operator!=(row_ref const &rhs) const noexcept
Definition: row.hxx:106
row_ref(row_ref const &)=default
const_reverse_row_iterator rbegin() const noexcept
Definition: row.hxx:1073
const_iterator begin() const noexcept
Definition: row.hxx:1053
std::tuple< TYPE... > as(sl loc=sl::current()) const
Extract entire row's values into a tuple.
Definition: row.hxx:299
size_type table_column(size_type col_num, sl loc=sl::current()) const
What column number in its table did this result column come from?
Definition: row.hxx:261
row_size_type size_type
Definition: row.hxx:59
row_ref & operator=(row_ref &&) noexcept=default
oid column_type(zview col_name, sl loc=sl::current()) const
Return a column's type.
Definition: row.hxx:230
const_reverse_row_iterator crend() const noexcept
Definition: row.hxx:1078
row_ref(row_ref &&)=default
const_iterator end() const noexcept
Definition: row.hxx:1063
std::make_index_sequence< std::tuple_size_v< TUPLE > > seq
Definition: row.hxx:319
PQXX_PURE size_type size() const noexcept
Definition: row.hxx:190
PQXX_PURE result const & home() const noexcept
The result object to which this row_ref refers.
Definition: row.hxx:324
Reference to one row in a result.
Definition: row.hxx:415
oid column_table(size_type col_num, sl loc=sl::current()) const
What table did this column come from?
Definition: row.hxx:601
~row()=default
row_size_type size_type
Definition: row.hxx:418
PQXX_PURE const_reverse_row_iterator rend() const noexcept
Definition: row.hxx:1143
constexpr PQXX_PURE result::size_type num() const noexcept
Definition: row.hxx:634
oid column_type(zview col_name, sl loc=sl::current()) const
Return a column's type.
Definition: row.hxx:594
size_type table_column(zview col_name, sl loc=sl::current()) const
What column number in its table did this result column come from?
Definition: row.hxx:628
constexpr PQXX_PURE size_type size() const noexcept
Definition: row.hxx:556
row_difference_type difference_type
Definition: row.hxx:419
TUPLE as_tuple(sl loc=sl::current()) const requires(requires(TUPLE t)
Convert to a given tuple of values,.
Definition: row.hxx:680
size_type column_number(zview col_name, sl loc=sl::current()) const
Number of given column (throws exception if it doesn't exist).
Definition: row.hxx:581
size_type table_column(size_type col, sl loc=sl::current()) const
What column number in its table did this result column come from?
Definition: row.hxx:621
constexpr PQXX_PURE result::size_type row_number() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:570
PQXX_PURE const_reverse_row_iterator crend() const noexcept
Definition: row.hxx:1138
PQXX_PURE const_reverse_row_iterator crbegin() const noexcept
Definition: row.hxx:1128
oid column_table(zview col_name, sl loc=sl::current()) const
What table did this column come from?
Definition: row.hxx:607
row() noexcept=default
std::tuple< TYPE... > as(sl loc=sl::current()) const
Extract entire row's values into a tuple.
Definition: row.hxx:664
constexpr result::size_type rownumber() const noexcept
Row number, assuming this is a real row and not end()/rend().
Definition: row.hxx:563
PQXX_PURE const_iterator cend() const noexcept
Definition: row.hxx:1118
row & operator=(row const &) noexcept=default
row & operator=(row &&) noexcept=default
PQXX_PURE const_iterator end() const noexcept
Definition: row.hxx:1123
void to(Tuple &t, sl loc=sl::current()) const
Extract entire row's values into a tuple.
Definition: row.hxx:648
PQXX_PURE bool operator!=(row const &rhs) const noexcept
Definition: row.hxx:466
PQXX_PURE const_iterator begin() const noexcept
Definition: row.hxx:1113
PQXX_PURE field_ref operator[](zview col_name) const
Definition: row.hxx:543
oid column_type(size_type col_num, sl loc=sl::current()) const
Return a column's type.
Definition: row.hxx:588
PQXX_PURE const_reverse_row_iterator rbegin() const noexcept
Definition: row.hxx:1133
PQXX_PURE const_iterator cbegin() const noexcept
Definition: row.hxx:1108
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:55
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:651
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:580
#define PQXX_LIBEXPORT
Definition: header-pre.hxx:206
#define PQXX_PURE
Definition: header-pre.hxx:64
#define PQXX_RETURNS_NONNULL
Definition: header-pre.hxx:119
Definition: connection.hxx:94
Private namespace for libpqxx's internal use; do not access.
Definition: connection.cxx:333
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:83
int row_difference_type
Difference between row sizes.
Definition: types.hxx:86
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
const_result_iterator operator+(result::difference_type o, const_result_iterator const &i)
Definition: result_iterator.hxx:321
int result_size_type
Number of rows in a result set.
Definition: types.hxx:77
std::remove_cvref_t< std::ranges::range_value_t< CONTAINER > > value_type
The type of a container's elements.
Definition: types.hxx:138
requires(pqxx::internal::to_buf_7< TYPE > or pqxx::internal::to_buf_8< TYPE >) const eval bool supports_to_buf_8()
Is the libpqxx 8 version of to_buf() supported for TYPE?
Definition: strconv.hxx:417
unsigned int oid
PostgreSQL database row identifier.
Definition: types.hxx:73
conversion_context const & ctx
Convenience alias: const reference to a pqxx::conversion_context.
Definition: strconv.hxx:201
constexpr bool operator==(char const lhs[], pqxx::zview rhs) noexcept
Disambiguating comparison operator: leave it to std::string_view.
Definition: zview.hxx:203
format
Format code: is data text or binary?
Definition: types.hxx:121
Contextual parameters for string conversions implementations.
Definition: strconv.hxx:163