16#if !defined(PQXX_HEADER_PRE)
17# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
26#include "pqxx/except.hxx"
27#include "pqxx/types.hxx"
28#include "pqxx/util.hxx"
29#include "pqxx/zview.hxx"
31#include "pqxx/internal/encodings.hxx"
36PQXX_LIBEXPORT
void clear_result(pq::PGresult
const *)
noexcept;
40namespace pqxx::internal::gate
42class result_connection;
46class result_sql_cursor;
56 std::function<
void(
zview)> notice_handler;
57 std::list<errorhandler *> errorhandlers;
96 using reference = row;
97 using const_iterator = const_result_iterator;
98 using pointer = const_iterator;
99 using iterator = const_iterator;
100 using const_reverse_iterator = const_reverse_result_iterator;
101 using reverse_iterator = const_reverse_iterator;
104 m_data{}, m_query{}, m_encoding{internal::encoding_group::MONOBYTE}
128 [[nodiscard]]
bool operator==(
result const &)
const noexcept;
132 return not operator==(rhs);
143 template<
typename... TYPE>
auto iter()
const;
145 [[nodiscard]] const_reverse_iterator rbegin()
const;
146 [[nodiscard]] const_reverse_iterator crbegin()
const;
147 [[nodiscard]] const_reverse_iterator rend()
const;
148 [[nodiscard]] const_reverse_iterator crend()
const;
150 [[nodiscard]] const_iterator begin() const noexcept;
151 [[nodiscard]] const_iterator cbegin() const noexcept;
152 [[nodiscard]] inline const_iterator end() const noexcept;
153 [[nodiscard]] inline const_iterator cend() const noexcept;
155 [[nodiscard]] reference front() const noexcept;
156 [[nodiscard]] reference back() const noexcept;
158 [[nodiscard]] PQXX_PURE size_type size() const noexcept;
159 [[nodiscard]] PQXX_PURE
bool empty() const noexcept;
160 [[nodiscard]] size_type capacity() const noexcept {
return size(); }
167 void swap(result &)
noexcept;
174 [[nodiscard]] row operator[](size_type i)
const noexcept;
176#if defined(PQXX_HAVE_MULTIDIM)
178 operator[](size_type row_num, row_size_type col_num)
const noexcept;
182 row at(size_type)
const;
185 field at(size_type, row_size_type)
const;
206 [[nodiscard]] PQXX_PURE
row_size_type columns() const noexcept;
212 [[nodiscard]]
char const *column_name(
row_size_type number) const &;
218 [[nodiscard]]
int column_storage(
row_size_type number) const;
231 [[nodiscard]]
int column_type_modifier(
row_size_type number) const noexcept;
237 [[nodiscard]]
oid column_type(
zview col_name)
const
239 return column_type(column_number(col_name));
248 return column_table(column_number(col_name));
257 return table_column(column_number(col_name));
262 [[nodiscard]] PQXX_PURE std::string
const &query() const & noexcept;
268 [[nodiscard]] PQXX_PURE
oid inserted_oid() const;
274 [[nodiscard]] PQXX_PURE size_type affected_rows() const;
315 template<typename CALLABLE> inline
void for_each(CALLABLE &&func) const;
323 auto const sz{size()};
327 if (not m_query or m_query->empty())
329 "Expected ", n,
" row(s) from query, got ", sz,
".")};
332 "Expected ", n,
" row(s) from query '", *m_query,
"', got ", sz,
350 std::optional<row> opt_row()
const;
365 auto const actual{columns()};
369 if (not m_query or m_query->empty())
371 "Expected 1 column from query, got ", actual,
".")};
374 "Expected 1 column from query '", *m_query,
"', got ", actual,
".")};
383 field one_field()
const;
386 using data_pointer = std::shared_ptr<internal::pq::PGresult const>;
392 PQXX_PURE std::shared_ptr<std::string const> query_ptr() const noexcept
398 std::shared_ptr<std::string const> m_query;
405 std::shared_ptr<pqxx::internal::notice_waiters> m_notice_waiters;
407 internal::encoding_group m_encoding;
409 static std::string
const s_empty_string;
411 friend class pqxx::field;
412 PQXX_PURE
char const *
413 get_value(size_type row, row_size_type col)
const noexcept;
414 PQXX_PURE
bool get_is_null(size_type row, row_size_type col)
const noexcept;
416 field_size_type get_length(size_type, row_size_type)
const noexcept;
420 std::shared_ptr<internal::pq::PGresult>
const &rhs,
421 std::shared_ptr<std::string>
const &query,
422 std::shared_ptr<pqxx::internal::notice_waiters>
const &waiters,
423 internal::encoding_group enc);
425 PQXX_PRIVATE
void check_status(std::string_view desc =
""sv)
const;
428 friend class pqxx::internal::gate::result_row;
429 bool operator!() const noexcept {
return m_data.get() ==
nullptr; }
430 operator bool() const noexcept {
return m_data.get() !=
nullptr; }
432 [[noreturn]] PQXX_PRIVATE PQXX_COLD
void
433 throw_sql_error(std::string
const &Err, std::string
const &Query)
const;
434 PQXX_PRIVATE PQXX_PURE
int errorposition()
const;
435 PQXX_PRIVATE std::string status_error()
const;
438 PQXX_PURE
char const *cmd_status() const noexcept;
Definition result-connection.hxx:6
Definition result-creation.hxx:6
Definition result-pipeline.hxx:6
Definition result-sql_cursor.hxx:6
Result set containing data returned by a query or command.
Definition result.hxx:92
row_size_type table_column(zview col_name) const
What column in its table did this column come from?
Definition result.hxx:255
result & operator=(result &&rhs) noexcept=default
Assign one result to another, invaliding the old one.
oid column_table(row_size_type col_num) const
What table did this column come from?
bool operator!=(result const &rhs) const noexcept
Compare two results for inequality.
Definition result.hxx:130
void clear() noexcept
Let go of the result's data.
Definition result.hxx:195
row_size_type table_column(row_size_type col_num) const
What column in its table did this column come from?
result expect_columns(row_size_type cols) const
Expect that result consists of exactly cols columns.
Definition result.hxx:363
oid column_table(zview col_name) const
What table did this column come from?
Definition result.hxx:246
result & operator=(result const &rhs) noexcept=default
Assign one result to another.
result no_rows() const
Expect that result contains no rows. Return result for convenience.
Definition result.hxx:353
Marker-type wrapper: zero-terminated std::string_view.
Definition zview.hxx:38
Query returned an unexpected number of rows.
Definition except.hxx:343
Error in usage of libpqxx library, similar to std::logic_error.
Definition except.hxx:249
Internal items for libpqxx' own use. Do not use these yourself.
Definition encodings.cxx:33
std::string concat(TYPE... item)
Efficiently combine a bunch of items into one big string.
Definition concat.hxx:31
PQXX_LIBEXPORT void clear_result(pq::PGresult const *) noexcept
C++ wrapper for libpq's PQclear.
Definition result.cxx:42
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
unsigned int oid
PostgreSQL database row identifier.
Definition libpq-forward.hxx:33
int result_size_type
Number of rows in a result set.
Definition types.hxx:28
constexpr char array_separator
Element separator between SQL array elements of this type.
Definition strconv.hxx:559
int row_size_type
Number of fields in a row of database data.
Definition types.hxx:34
int result_difference_type
Difference between result sizes.
Definition types.hxx:31
Various callbacks waiting for a notice to come in.
Definition result.hxx:55