libpqxx
The C++ client library for PostgreSQL
field.hxx
Go to the documentation of this file.
1 /* Definitions for the pqxx::field class.
2  *
3  * pqxx::field refers to a field in a query result.
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/field 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_FIELD_HXX
14 #define PQXX_FIELD_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 <optional>
21 
22 #include "pqxx/array.hxx"
23 #include "pqxx/composite.hxx"
25 #include "pqxx/result.hxx"
26 #include "pqxx/strconv.hxx"
27 #include "pqxx/types.hxx"
28 
29 namespace pqxx::internal::gate
30 {
31 class field_ref_const_row_iterator;
32 } // namespace pqxx::internal::gate
33 
34 
35 namespace pqxx
36 {
38 
52 {
53 public:
56 
57  field_ref() noexcept = default;
58  field_ref(field_ref const &) noexcept = default;
59  field_ref(field_ref &&) noexcept = default;
61  result const &res, result_size_type row_num,
62  row_size_type col_num) noexcept :
63  m_result(&res), m_row{row_num}, m_column{col_num}
64  {}
65  ~field_ref() = default;
66 
67  field_ref &operator=(field_ref const &) noexcept = default;
68  field_ref &operator=(field_ref &&) noexcept = default;
69 
70  [[nodiscard]] PQXX_PURE result const &home() const noexcept
71  {
72  return *m_result;
73  }
74  [[nodiscard]] PQXX_PURE result_size_type row_number() const noexcept
75  {
76  return m_row;
77  }
78 
90  [[nodiscard]] PQXX_PURE bool operator==(field_ref const &rhs) const noexcept
91  {
92  return (home() == rhs.home()) and (row_number() == rhs.row_number()) and
93  (column_number() == rhs.column_number());
94  }
95  [[nodiscard]] PQXX_PURE bool operator!=(field_ref const &rhs) const noexcept
96  {
97  return not operator==(rhs);
98  }
100 
106  [[nodiscard]] PQXX_PURE char const *name(sl loc = sl::current()) const &
107  {
108  return home().column_name(column_number(), loc);
109  }
110 
112  [[nodiscard]] PQXX_PURE oid type(sl loc = sl::current()) const;
113 
115  [[nodiscard]] PQXX_PURE oid table(sl = sl::current()) const;
116 
118  [[nodiscard]] PQXX_PURE constexpr row_size_type
119  column_number() const noexcept
120  {
121  return m_column;
122  }
123 
125  [[nodiscard]] PQXX_PURE row_size_type
126  table_column(sl loc = sl::current()) const
127  {
128  return home().table_column(column_number(), loc);
129  }
131 
148 
151  [[nodiscard]] PQXX_PURE std::string_view view() const & noexcept
152  {
153  return zview{c_str(), size()};
154  }
155 
157 
166  [[nodiscard]] PQXX_PURE char const *c_str() const & noexcept;
167 
169  [[nodiscard]] PQXX_PURE bool is_null() const noexcept;
170 
172  [[nodiscard]] PQXX_PURE size_type size() const noexcept;
173 
175 
178  template<typename T>
179  [[nodiscard]] T as(T const &default_value, sl loc = sl::current()) const
180  {
181  if (is_null())
182  return default_value;
183  else
184  return from_string<T>(this->view(), make_context(loc));
185  }
186 
188 
193  template<typename T> [[nodiscard]] T as(sl loc = sl::current()) const
194  {
195  if (is_null())
196  {
197  if constexpr (not has_null<T>())
198  internal::throw_null_conversion(name_type<T>(), loc);
199  else
200  return make_null<T>();
201  }
202  else
203  {
204  return from_string<T>(this->view(), make_context(loc));
205  }
206  }
207 
209 
215  template<typename T> bool to(T &obj, sl loc = sl::current()) const
216  {
217  if (is_null())
218  {
219  return false;
220  }
221  else
222  {
223  from_string(view(), obj, make_context(loc));
224  return true;
225  }
226  }
227 
229  template<typename T>
230  bool to(T &obj, T const &default_value, sl loc = sl::current()) const
231  {
232  bool const null{is_null()};
233  if (null)
234  obj = default_value;
235  else
236  obj = from_string<T>(this->view(), make_context(loc));
237  return not null;
238  }
239 
241 
244  template<typename T, template<typename> typename O = std::optional>
245  constexpr O<T> get() const
246  {
247  return as<O<T>>();
248  }
249 
251  template<typename ELEMENT, auto... ARGS>
252  [[deprecated("Use as<pqxx::array<ELEMENT, ...>>().")]] [[nodiscard]] array<
253  ELEMENT, ARGS...>
254  as_sql_array(sl loc = sl::current()) const
255  {
256  using array_type = array<ELEMENT, ARGS...>;
257 
258  // There's no such thing as a null SQL array.
259  if (is_null())
260  internal::throw_null_conversion(name_type<array_type>(), loc);
261  else
262  return array_type{
263  this->view(),
264  pqxx::internal::gate::result_field_ref{home()}.encoding(), loc};
265  }
267 
268 private:
270 
272  void offset(row_difference_type n) { m_column += n; }
273 
275  [[nodiscard]] conversion_context make_context(sl loc) const
276  {
277  return conversion_context{home().get_encoding_group(), loc};
278  }
279 
281  result const *m_result = nullptr;
282 
284  result_size_type m_row = -1;
285 
287 
291  row_size_type m_column = -1;
292 };
293 } // namespace pqxx
294 
295 
297 
298 
299 namespace pqxx
300 {
302 
309 {
310 public:
312 
313  explicit field(field_ref const &f) :
314  m_home{f.home()}, m_row{f.row_number()}, m_col{f.column_number()}
315  {}
316 
322 
341  [[deprecated(
342  "To compare fields by content, compare their view()s.")]] PQXX_PURE bool
343  operator==(field const &) const noexcept;
344 
346 
348  [[deprecated(
349  "To compare fields by content, compare their view()s.")]] PQXX_PURE bool
350  operator!=(field const &rhs) const noexcept
351  {
353  return not operator==(rhs);
355  }
357 
363  [[nodiscard]] PQXX_PURE char const *name(sl = sl::current()) const &;
364 
366  [[nodiscard]] PQXX_PURE oid type(sl loc = sl::current()) const
367  {
368  return as_field_ref().type(loc);
369  }
370 
372  [[nodiscard]] PQXX_PURE oid table(sl loc = sl::current()) const
373  {
374  return as_field_ref().table(loc);
375  }
376 
378  [[deprecated("Use column_number().")]] [[nodiscard]] row_size_type
379  num() const noexcept
380  {
381  return column_number();
382  }
383 
385  [[nodiscard]] row_size_type table_column(sl = sl::current()) const;
387 
404 
410  [[nodiscard]] PQXX_PURE std::string_view view() const & noexcept
411  {
412  return {c_str(), size()};
413  }
414 
416 
427  [[nodiscard]] PQXX_PURE PQXX_RETURNS_NONNULL char const *
428  c_str() const & noexcept
429  {
430  return as_field_ref().c_str();
431  }
432 
434  [[nodiscard]] PQXX_PURE bool is_null() const noexcept
435  {
436  return as_field_ref().is_null();
437  }
438 
440  [[nodiscard]] PQXX_PURE size_type size() const noexcept
441  {
442  return as_field_ref().size();
443  }
444 
446 
452  template<typename T> bool to(T &obj, sl loc = sl::current()) const
453  {
454  if (is_null())
455  {
456  return false;
457  }
458  else
459  {
460  obj = from_string<T>(view(), make_context(loc));
461  return true;
462  }
463  }
464 
466 
469  template<typename... T> bool composite_to(sl loc, T &...fields) const
470  {
471  if (is_null())
472  {
473  return false;
474  }
475  else
476  {
477  parse_composite(make_context(loc), view(), fields...);
478  return true;
479  }
480  }
481 
483 
493  template<typename... T> bool composite_to(T &...fields) const
494  {
495  return composite_to(sl::current(), fields...);
496  }
497 
499  template<typename T>
500  [[deprecated("Use to() or as().")]] bool operator>>(T &obj) const
501  {
502  return to(obj);
503  }
504 
506 
509  template<typename T>
510  bool to(T &obj, T const &default_value, sl loc = sl::current()) const
511  {
512  return as_field_ref().to<T>(obj, default_value, make_context(loc));
513  }
514 
516 
519  template<typename T>
520  [[nodiscard]] T as(T const &default_value, sl loc = sl::current()) const
521  {
522  return as_field_ref().as<T>(default_value, loc);
523  }
524 
526 
531  template<typename T> [[nodiscard]] T as(sl loc = sl::current()) const
532  {
533  return as_field_ref().as<T>(loc);
534  }
535 
537 
540  template<typename T, template<typename> typename O = std::optional>
541  constexpr O<T> get() const
542  {
543  return as<O<T>>();
544  }
545 
547  template<typename ELEMENT, auto... ARGS>
548  array<ELEMENT, ARGS...> as_sql_array(sl loc = sl::current()) const
549  {
550  return as_field_ref().as_sql_array<ELEMENT, ARGS...>(loc);
551  }
552 
554 
560  [[deprecated(
561  "Avoid pqxx::array_parser. "
562  "Instead, use as_sql_array() to convert to "
563  "pqxx::array.")]] [[nodiscard]] array_parser
564  as_array() const & noexcept
565  {
567  return array_parser{c_str(), m_home.get_encoding_group()};
569  }
571 
573  [[nodiscard]] PQXX_PURE result_size_type row_number() const noexcept
574  {
575  return m_row;
576  }
578  [[nodiscard]] PQXX_PURE row_size_type column_number() const noexcept
579  {
580  return m_col;
581  }
582 
583 private:
588  field(row const &r, row_size_type c) noexcept;
589 
591  field() noexcept = default;
592 
594 
598  [[nodiscard]] field_ref as_field_ref() const noexcept
599  {
600  return field_ref{home(), row_number(), column_number()};
601  }
602 
603  [[nodiscard]] constexpr result const &home() const noexcept
604  {
605  return m_home;
606  }
607 
608  field(result r, result_size_type row_num, row_size_type col_num) noexcept :
609  m_home{std::move(r)}, m_row{row_num}, m_col{col_num}
610  {}
611 
613  [[nodiscard]] conversion_context make_context(sl loc) const
614  {
615  return conversion_context{home().get_encoding_group(), loc};
616  }
617 
618  result m_home;
619  result::size_type m_row = 0;
624  row_size_type m_col = 0;
625 };
626 
627 
628 inline char const *field_ref::c_str() const & noexcept
629 {
630  return pqxx::internal::gate::result_field_ref{home()}.get_value(
632 }
633 
634 inline bool field_ref::is_null() const noexcept
635 {
636  return pqxx::internal::gate::result_field_ref{home()}.get_is_null(
638 }
639 
640 inline field_size_type field_ref::size() const noexcept
641 {
642  return pqxx::internal::gate::result_field_ref{home()}.get_length(
644 }
645 
646 inline oid field_ref::type(sl loc) const
647 {
649  column_number(), loc);
650 }
651 
652 inline oid field_ref::table(sl loc) const
653 {
655  column_number(), loc);
656 }
657 
658 
660 
666 template<> inline bool field::to<zview>(zview &obj, sl) const
667 {
668  bool const null{is_null()};
669  if (not null)
670  obj = zview{c_str(), size()};
671  return not null;
672 }
673 
674 
675 template<>
676 inline bool field::to<zview>(zview &obj, zview const &default_value, sl) const
677 {
678  bool const null{is_null()};
679  if (null)
680  obj = default_value;
681  else
682  obj = zview{c_str(), size()};
683  return not null;
684 }
685 
686 
688 
694 template<> inline zview field_ref::as<zview>(sl loc) const
695 {
696  if (is_null())
698  return zview{c_str(), size()};
699 }
700 
701 
702 template<> inline zview field::as<zview>(zview const &default_value, sl) const
703 {
704  return is_null() ? default_value : zview{c_str(), size()};
705 }
706 
707 
708 template<typename CHAR = char, typename TRAITS = std::char_traits<CHAR>>
709 class field_streambuf final : public std::basic_streambuf<CHAR, TRAITS>
710 {
711 public:
712  using char_type = CHAR;
713  using traits_type = TRAITS;
714  using int_type = typename traits_type::int_type;
715  using pos_type = typename traits_type::pos_type;
716  using off_type = typename traits_type::off_type;
717  using openmode = std::ios::openmode;
718  using seekdir = std::ios::seekdir;
719 
720  explicit field_streambuf(field const &f) : m_field{f} { initialize(); }
721 
722 protected:
723  int sync() override { return traits_type::eof(); }
724 
726  {
727  return traits_type::eof();
728  }
729  pos_type seekpos(pos_type, openmode) override { return traits_type::eof(); }
730  int_type overflow(int_type) override { return traits_type::eof(); }
731  int_type underflow() override { return traits_type::eof(); }
732 
733 private:
734  // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
735  field const &m_field;
736 
737  int_type initialize()
738  {
739  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
740  auto g{static_cast<char_type *>(const_cast<char *>(m_field.c_str()))};
741  this->setg(g, g, g + std::size(m_field));
742  return int_type(std::size(m_field));
743  }
744 };
745 
746 
747 // NOLINTBEGIN(fuchsia-multiple-inheritance)
748 
750 
763 template<typename CHAR = char, typename TRAITS = std::char_traits<CHAR>>
764 class basic_fieldstream final : public std::basic_istream<CHAR, TRAITS>
765 {
766  using super = std::basic_istream<CHAR, TRAITS>;
767 
768 public:
769  using char_type = CHAR;
770  using traits_type = TRAITS;
771  using int_type = typename traits_type::int_type;
772  using pos_type = typename traits_type::pos_type;
773  using off_type = typename traits_type::off_type;
774 
775  [[deprecated("Use field::as<...>() or field::c_str().")]]
776  explicit basic_fieldstream(field const &f) :
777  super{nullptr}, m_buf{f}
778  {
779  super::init(&m_buf);
780  }
781 
782 private:
784 };
785 
786 // NOLINTEND(fuchsia-multiple-inheritance)
787 
788 
791 
792 
794 
817 template<typename CHAR>
818 [[deprecated("To write a pqxx::field, use its view() method.")]] inline std::
819  basic_ostream<CHAR> &
820  operator<<(std::basic_ostream<CHAR> &s, field const &value)
821 {
822  s.write(value.c_str(), std::streamsize(std::size(value)));
823  return s;
824 }
825 
826 
828 
831 template<typename T> inline T from_string(field const &value, ctx c = {})
832 {
833  if (value.is_null())
834  {
835  if constexpr (has_null<T>())
836  return make_null<T>();
837  else
838  internal::throw_null_conversion(name_type<T>(), c.loc);
839  }
840  else
841  {
842  return from_string<T>(value.view(), c);
843  }
844 }
845 
846 
848 
851 template<typename T> inline T from_string(field_ref const &value, ctx c = {})
852 {
853  if (value.is_null())
854  {
855  if constexpr (has_null<T>())
856  return make_null<T>();
857  else
858  internal::throw_null_conversion(name_type<T>(), c.loc);
859  }
860  else
861  {
862  return from_string<T>(value.view(), c);
863  }
864 }
865 
866 
867 // TODO: Can we make this generic across all "always-null" types?
868 // TODO: Do the same for streams.
870 
876 template<>
877 inline std::nullptr_t from_string<std::nullptr_t>(field const &value, ctx c)
878 {
879  if (not value.is_null())
880  throw conversion_error{
881  "Extracting non-null field into nullptr_t variable.", c.loc};
882  return nullptr;
883 }
884 
885 
886 // clang-tidy rule bug:
887 // NOLINTBEGIN(misc-unused-parameters)
888 
890 template<>
891 PQXX_LIBEXPORT inline std::string to_string(field_ref const &value, ctx)
892 {
893  return std::string{value.view()};
894 }
895 
896 // NOLINTEND(misc-unused-parameters)
897 
899 template<> PQXX_LIBEXPORT inline std::string to_string(field const &value, ctx)
900 {
901  return std::string{value.view()};
902 }
903 } // namespace pqxx
904 #endif
Low-level parser for C++ arrays.
Definition: array.hxx:738
An SQL array received from the database.
Definition: array.hxx:57
Input stream that gets its data from a result field.
Definition: field.hxx:765
TRAITS traits_type
Definition: field.hxx:770
basic_fieldstream(field const &f)
Definition: field.hxx:776
typename traits_type::pos_type pos_type
Definition: field.hxx:772
typename traits_type::off_type off_type
Definition: field.hxx:773
typename traits_type::int_type int_type
Definition: field.hxx:771
CHAR char_type
Definition: field.hxx:769
Lightweight reference to a field in a result set.
Definition: field.hxx:52
PQXX_PURE result const & home() const noexcept
Definition: field.hxx:70
array< ELEMENT, ARGS... > as_sql_array(sl loc=sl::current()) const
Read SQL array contents as a pqxx::array.
Definition: field.hxx:254
PQXX_PURE bool operator!=(field_ref const &rhs) const noexcept
Definition: field.hxx:95
PQXX_PURE bool operator==(field_ref const &rhs) const noexcept
Definition: field.hxx:90
constexpr PQXX_PURE row_size_type column_number() const noexcept
Return column number. The first column is 0, the second is 1, etc.
Definition: field.hxx:119
field_ref() noexcept=default
field_ref & operator=(field_ref &&) noexcept=default
T as(sl loc=sl::current()) const
Return value as object of given type, or throw exception if null.
Definition: field.hxx:193
PQXX_PURE oid table(sl=sl::current()) const
What table did this column come from?
Definition: field.hxx:652
~field_ref()=default
PQXX_PURE char const * c_str() const &noexcept
Read as plain C string.
Definition: field.hxx:628
constexpr O< T > get() const
Return value wrapped in some optional type (empty for nulls).
Definition: field.hxx:245
PQXX_PURE row_size_type table_column(sl loc=sl::current()) const
What column number in its originating table did this column come from?
Definition: field.hxx:126
PQXX_PURE bool is_null() const noexcept
Is this field's value null?
Definition: field.hxx:634
bool to(T &obj, T const &default_value, sl loc=sl::current()) const
Read value into obj; or if null, set default value and return false.
Definition: field.hxx:230
PQXX_PURE std::string_view view() const &noexcept
Read as zview, or an empty one if null.
Definition: field.hxx:151
PQXX_PURE result_size_type row_number() const noexcept
Definition: field.hxx:74
bool to(T &obj, sl loc=sl::current()) const
Read value into obj; or if null, leave obj untouched.
Definition: field.hxx:215
PQXX_PURE oid type(sl loc=sl::current()) const
Column type.
Definition: field.hxx:646
field_ref & operator=(field_ref const &) noexcept=default
PQXX_PURE char const * name(sl loc=sl::current()) const &
Column name.
Definition: field.hxx:106
field_size_type size_type
A type for holding the number of bytes in a field.
Definition: field.hxx:55
PQXX_PURE size_type size() const noexcept
Return number of bytes taken up by the field's value.
Definition: field.hxx:640
Definition: field.hxx:710
TRAITS traits_type
Definition: field.hxx:713
typename traits_type::off_type off_type
Definition: field.hxx:716
field_streambuf(field const &f)
Definition: field.hxx:720
std::ios::openmode openmode
Definition: field.hxx:717
typename traits_type::pos_type pos_type
Definition: field.hxx:715
int sync() override
Definition: field.hxx:723
typename traits_type::int_type int_type
Definition: field.hxx:714
int_type underflow() override
Definition: field.hxx:731
pos_type seekoff(off_type, seekdir, openmode) override
Definition: field.hxx:725
int_type overflow(int_type) override
Definition: field.hxx:730
CHAR char_type
Definition: field.hxx:712
std::ios::seekdir seekdir
Definition: field.hxx:718
pos_type seekpos(pos_type, openmode) override
Definition: field.hxx:729
Reference to a field in a result set.
Definition: field.hxx:309
PQXX_PURE PQXX_RETURNS_NONNULL char const * c_str() const &noexcept
Read as plain C string.
Definition: field.hxx:428
PQXX_PURE size_type size() const noexcept
Return number of bytes taken up by the field's value.
Definition: field.hxx:440
T as(sl loc=sl::current()) const
Return value as object of given type, or throw exception if null.
Definition: field.hxx:531
row_size_type num() const noexcept
Return column number. The first column is 0, the second is 1, etc.
Definition: field.hxx:379
array_parser as_array() const &noexcept
Parse the field as an SQL array.
Definition: field.hxx:564
T as(T const &default_value, sl loc=sl::current()) const
Return value as object of given type, or default value if null.
Definition: field.hxx:520
constexpr O< T > get() const
Return value wrapped in some optional type (empty for nulls).
Definition: field.hxx:541
field(field_ref const &f)
Definition: field.hxx:313
PQXX_PURE std::string_view view() const &noexcept
Read as zview (which is also a string_view).
Definition: field.hxx:410
field_size_type size_type
Definition: field.hxx:311
array< ELEMENT, ARGS... > as_sql_array(sl loc=sl::current()) const
Read SQL array contents as a pqxx::array.
Definition: field.hxx:548
PQXX_PURE bool is_null() const noexcept
Is this field's value null?
Definition: field.hxx:434
bool operator>>(T &obj) const
Read value into obj; or leave obj untouched and return false if null.
Definition: field.hxx:500
PQXX_PURE result_size_type row_number() const noexcept
This field's row number within the result.
Definition: field.hxx:573
PQXX_PURE row_size_type column_number() const noexcept
This field's column number within the result.
Definition: field.hxx:578
PQXX_PURE bool operator!=(field const &rhs) const noexcept
Byte-by-byte comparison (all nulls are considered equal)
Definition: field.hxx:350
bool to(T &obj, T const &default_value, sl loc=sl::current()) const
Read value into obj; or if null, use default value and return false.
Definition: field.hxx:510
bool composite_to(sl loc, T &...fields) const
Read field as a composite value, write its components into fields.
Definition: field.hxx:469
PQXX_PURE oid table(sl loc=sl::current()) const
What table did this column come from?
Definition: field.hxx:372
bool composite_to(T &...fields) const
Read field as a composite value, write its components into fields.
Definition: field.hxx:493
bool to(T &obj, sl loc=sl::current()) const
Read value into obj; or if null, leave obj untouched.
Definition: field.hxx:452
constexpr reference home() const noexcept
The home object. The gate class has full "private" access.
Definition: callgate.hxx:65
Definition: field_ref-const_row_iterator.hxx:15
Definition: result-field_ref.hxx:9
Result set containing data returned by a query or command.
Definition: result.hxx:101
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
oid column_type(row_size_type col_num, sl=sl::current()) const
Return column's type, as an OID from the system catalogue.
Definition: result.cxx:449
Reference to one row in a result.
Definition: row.hxx:415
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:55
Value conversion failed, e.g. when converting "Hello" to int.
Definition: except.hxx:612
#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
void throw_null_conversion(std::string const &type, sl loc)
Throw exception for attempt to convert SQL NULL to given type.
Definition: strconv.cxx:142
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
void parse_composite(ctx c, std::string_view text, T &...fields)
Parse a string representation of a value of a composite type.
Definition: composite.hxx:34
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
constexpr TYPE make_null() requires(pqxx
Return a null value of TYPE.
Definition: strconv.hxx:781
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
std::size_t field_size_type
Number of bytes in a field of database data.
Definition: types.hxx:89
constexpr std::string_view name_type() noexcept
Return human-readable name for TYPE.
Definition: types.hxx:277
T from_string(field const &value, ctx c={})
Convert a field's value to type T.
Definition: field.hxx:831
PQXX_LIBEXPORT std::string to_string(field_ref const &value, ctx)
Convert a field_ref to a string.
Definition: field.hxx:891
int result_size_type
Number of rows in a result set.
Definition: types.hxx:77
constexpr bool is_null(TYPE const &value) noexcept
Is value a null?
Definition: strconv.hxx:764
std::basic_ostream< CHAR > & operator<<(std::basic_ostream< CHAR > &s, field const &value)
Write a result field to any type of stream.
Definition: field.hxx:820
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 std::string_view name_type< zview >() noexcept
Definition: zview.hxx:181
constexpr bool operator==(char const lhs[], pqxx::zview rhs) noexcept
Disambiguating comparison operator: leave it to std::string_view.
Definition: zview.hxx:203
Contextual parameters for string conversions implementations.
Definition: strconv.hxx:163