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"
36 PQXX_LIBEXPORT
void clear_result(pq::PGresult
const *) noexcept;
40 namespace
pqxx::internal::gate
42 class result_connection;
43 class result_creation;
44 class result_pipeline;
46 class result_sql_cursor;
56 std::function<void(zview)> notice_handler;
57 std::list<errorhandler *> errorhandlers;
104 m_data{}, m_query{}, m_encoding{internal::encoding_group::MONOBYTE}
114 result &operator=(
result const &rhs) noexcept =
default;
127 [[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;
179 #endif // PQXX_HAVE_MULTIDIM
182 row at(size_type)
const;
205 [[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 ", cols,
" column(s) from query, got ", actual,
".")};
374 "Expected ", cols,
" column(s) from query '", *m_query,
"', got ",
384 field one_field()
const;
387 using data_pointer = std::shared_ptr<internal::pq::PGresult const>;
393 PQXX_PURE std::shared_ptr<std::string const> query_ptr() const noexcept
399 std::shared_ptr<std::string const> m_query;
406 std::shared_ptr<pqxx::internal::notice_waiters> m_notice_waiters;
408 internal::encoding_group m_encoding;
410 static std::string
const s_empty_string;
413 PQXX_PURE
char const *
415 PQXX_PURE
bool get_is_null(size_type row,
row_size_type col)
const noexcept;
419 friend class
pqxx::internal::gate::result_creation;
421 std::shared_ptr<internal::pq::PGresult> const &rhs,
422 std::shared_ptr<std::
string> const &query,
423 std::shared_ptr<
pqxx::internal::notice_waiters> const &waiters,
424 internal::encoding_group enc);
426 PQXX_PRIVATE
void check_status(std::string_view desc = ""sv) const;
428 friend class
pqxx::internal::gate::result_connection;
429 friend class
pqxx::internal::gate::result_row;
430 bool operator!() const noexcept {
return m_data.get() ==
nullptr; }
431 operator bool() const noexcept {
return m_data.get() !=
nullptr; }
433 [[noreturn]] PQXX_PRIVATE PQXX_COLD
void
434 throw_sql_error(std::string
const &Err, std::string
const &Query)
const;
435 PQXX_PRIVATE PQXX_PURE
int errorposition()
const;
436 PQXX_PRIVATE std::string status_error()
const;
439 PQXX_PURE
char const *cmd_status() const noexcept;
std::string concat(TYPE...item)
Efficiently combine a bunch of items into one big string.
Definition: concat.hxx:31
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:37
bool operator!=(result const &rhs) const noexcept
Compare two results for inequality.
Definition: result.hxx:130
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:248
row_size_type table_column(zview col_name) const
What column in its table did this column come from?
Definition: result.hxx:255
Internal items for libpqxx' own use. Do not use these yourself.
Definition: encodings.cxx:32
result expect_columns(row_size_type cols) const
Expect that result consists of exactly cols columns.
Definition: result.hxx:363
Reference to one row in a result.
Definition: row.hxx:46
oid column_table(zview col_name) const
What table did this column come from?
Definition: result.hxx:246
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:34
Result set containing data returned by a query or command.
Definition: result.hxx:91
Various callbacks waiting for a notice to come in.
Definition: result.hxx:54
int result_size_type
Number of rows in a result set.
Definition: types.hxx:28
PQXX_LIBEXPORT void clear_result(pq::PGresult const *) noexcept
C++ wrapper for libpq's PQclear.
Definition: result.cxx:42
int result_difference_type
Difference between result sizes.
Definition: types.hxx:31
Query returned an unexpected number of rows.
Definition: except.hxx:342
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
Reference to a field in a result set.
Definition: field.hxx:34
unsigned int oid
PostgreSQL database row identifier.
Definition: libpq-forward.hxx:33
Iterator for rows in a result. Use as result::const_iterator.
Definition: result_iterator.hxx:32
std::size_t field_size_type
Number of bytes in a field of database data.
Definition: types.hxx:40
Definition: result-sql_cursor.hxx:5
result no_rows() const
Expect that result contains no rows. Return result for convenience.
Definition: result.hxx:353
Reverse iterator for result. Use as result::const_reverse_iterator.
Definition: result_iterator.hxx:194
void clear() noexcept
Let go of the result's data.
Definition: result.hxx:195
Definition: result-pipeline.hxx:5