16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
23 #include "pqxx/except.hxx"
24 #include "pqxx/types.hxx"
25 #include "pqxx/util.hxx"
26 #include "pqxx/zview.hxx"
28 #include "pqxx/internal/encodings.hxx"
39 class result_connection;
40 class result_creation;
41 class result_pipeline;
43 class result_sql_cursor;
83 m_data(make_data_pointer()),
85 m_encoding(internal::encoding_group::MONOBYTE)
95 [[nodiscard]]
bool operator==(
result const &)
const noexcept;
98 return not operator==(rhs);
102 [[nodiscard]] const_reverse_iterator rbegin()
const;
103 [[nodiscard]] const_reverse_iterator crbegin()
const;
104 [[nodiscard]] const_reverse_iterator rend()
const;
105 [[nodiscard]] const_reverse_iterator crend()
const;
107 [[nodiscard]] const_iterator begin() const noexcept;
108 [[nodiscard]] const_iterator cbegin() const noexcept;
109 [[nodiscard]] inline const_iterator end() const noexcept;
110 [[nodiscard]] inline const_iterator cend() const noexcept;
112 [[nodiscard]] reference front() const noexcept;
113 [[nodiscard]] reference back() const noexcept;
115 [[nodiscard]] PQXX_PURE size_type size() const noexcept;
116 [[nodiscard]] PQXX_PURE
bool empty() const noexcept;
117 [[nodiscard]]
size_type capacity() const noexcept {
return size(); }
119 void swap(
result &) noexcept;
121 [[nodiscard]]
row operator[](size_type i)
const noexcept;
122 row at(size_type)
const;
134 [[nodiscard]] PQXX_PURE
row_size_type columns() const noexcept;
143 return column_number(name.c_str());
149 return column_number(name.
c_str());
153 [[nodiscard]]
char const *column_name(
row_size_type number)
const;
159 template<
typename STRING>[[nodiscard]] oid
column_type(STRING col_name)
const
161 return column_type(column_number(col_name));
168 template<
typename STRING>
171 return column_table(column_number(col_name));
178 template<
typename STRING>
181 return table_column(column_number(col_name));
186 [[nodiscard]] PQXX_PURE std::string
const &query() const noexcept;
192 [[nodiscard]] PQXX_PURE oid inserted_oid() const;
199 [[nodiscard]] PQXX_PURE size_type affected_rows() const;
203 using data_pointer = std::shared_ptr<internal::pq::PGresult const>;
210 make_data_pointer(internal::pq::PGresult const *res =
nullptr)
215 friend class pqxx::internal::gate::result_pipeline;
216 PQXX_PURE std::shared_ptr<std::string> query_ptr() const noexcept
222 std::shared_ptr<std::string> m_query;
224 internal::encoding_group m_encoding;
226 static std::string
const s_empty_string;
234 friend class pqxx::internal::gate::result_creation;
236 internal::pq::PGresult *rhs, std::shared_ptr<std::string> query,
237 internal::encoding_group enc);
239 PQXX_PRIVATE
void check_status()
const;
241 friend class pqxx::internal::gate::result_connection;
242 friend class pqxx::internal::gate::result_row;
243 bool operator!() const noexcept {
return m_data.get() ==
nullptr; }
244 operator bool() const noexcept {
return m_data.get() !=
nullptr; }
246 [[noreturn]] PQXX_PRIVATE
void
247 ThrowSQLError(std::string
const &Err, std::string
const &Query)
const;
248 PQXX_PRIVATE PQXX_PURE
int errorposition()
const;
249 PQXX_PRIVATE std::string StatusError()
const;
251 friend class pqxx::internal::gate::result_sql_cursor;
252 PQXX_PURE
char const *cmd_status() const noexcept;
256 #include "pqxx/internal/compiler-internal-post.hxx"
Reference to one row in a result.
Definition: row.hxx:38
PQXX_PURE bool empty() const noexcept
Definition: result.cxx:108
row_size_type column_number(zview name) const
Number of given column (throws exception if it doesn't exist).
Definition: result.hxx:147
row_size_type table_column(STRING col_name) const
What column in its table did this column come from?
Definition: result.hxx:179
int result_size_type
Number of rows in a result set.
Definition: types.hxx:18
void swap(result &) noexcept
Definition: result.cxx:126
const_reverse_iterator rend() const
Definition: result.cxx:76
oid column_type(STRING col_name) const
Return column's type, as an OID from the system catalogue.
Definition: result.hxx:159
void clear_result(pq::PGresult const *)
C++ wrapper for libpq's PQclear.
Definition: result.cxx:35
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
constexpr const char * c_str() const noexcept
Either a null pointer, or a zero-terminated text buffer.
Definition: zview.hxx:41
Definition: connection.hxx:65
std::string to_string(field const &value)
Convert a field to a string.
Definition: result.cxx:478
oid column_table(STRING col_name) const
What table did this column come from?
Definition: result.hxx:169
oid column_table(row_size_type col_num) const
What table did this column come from?
Definition: result.cxx:361
PQXX_DECLARE_ENUM_CONVERSION(pqxx::internal::encoding_group)
bool operator!=(result const &rhs) const noexcept
Definition: result.hxx:96
const_reverse_result_iterator & operator--()
Definition: result_iterator.hxx:243
size_t field_size_type
Number of bytes in a field of database data.
Definition: types.hxx:30
const_iterator begin() const noexcept
Definition: result.cxx:88
Private namespace for libpqxx's internal use; do not access.
Definition: connection.hxx:59
Reverse iterator for result. Use as result::const_reverse_iterator.
Definition: result_iterator.hxx:174
row_size_type col() const noexcept
Definition: field.hxx:215
PQXX_PURE oid inserted_oid() const
If command was INSERT of 1 row, return oid of inserted row.
Definition: result.cxx:301
result_difference_type difference_type
Definition: result.hxx:74
bool operator==(result const &) const noexcept
Definition: result.cxx:50
Result set containing data returned by a query or command.
Definition: result.hxx:70
int result_difference_type
Difference between result sizes.
Definition: types.hxx:21
PQXX_PURE row_size_type columns() const noexcept
Number of columns in result.
Definition: result.cxx:427
size_type size() const noexcept
Return number of bytes taken up by the field's value.
Definition: field.cxx:74
field_size_type size_type
Definition: field.hxx:35
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:192
PQXX_PURE size_type size() const noexcept
Definition: result.cxx:100
row_size_type size_type
Definition: row.hxx:41
const_reverse_result_iterator & operator++()
Definition: result_iterator.hxx:237
reference back() const noexcept
Definition: result.cxx:120
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:32
result_size_type size_type
Definition: result.hxx:73
row operator[](size_type i) const noexcept
Definition: result.cxx:133
PQXX_PURE const_result_iterator base() const noexcept
Definition: result.cxx:452
row_size_type column_number(char const col_name[]) const
Number of given column (throws exception if it doesn't exist).
Definition: result.cxx:349
const_reverse_iterator rbegin() const
Definition: result.cxx:64
PQXX_PURE size_type affected_rows() const
Definition: result.cxx:310
row at(size_type) const
Definition: result.cxx:139
const_result_iterator & operator--()
Definition: result_iterator.hxx:103
reference front() const noexcept
Definition: result.cxx:114
result() noexcept
Definition: result.hxx:82
Invalid argument passed to libpqxx, similar to std::invalid_argument.
Definition: except.hxx:171
const_iterator cbegin() const noexcept
Definition: result.cxx:94
const char * c_str() const
Read as plain C string.
Definition: field.cxx:62
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:24
Reference to a field in a result set.
Definition: field.hxx:32
const_result_iterator & operator++()
Definition: result_iterator.hxx:97
Iterator for rows in a result. Use as result::const_iterator.
Definition: result_iterator.hxx:35
constexpr oid oid_none
The "null" oid.
Definition: util.hxx:180
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:164
void clear() noexcept
Definition: result.hxx:124
PQXX_PURE const std::string & query() const noexcept
Query that produced this result, if available (empty string otherwise)
Definition: result.cxx:295
oid column_type(row_size_type col_num) const
Return column's type, as an OID from the system catalogue.
Definition: result.cxx:339
const_reverse_iterator crend() const
Definition: result.cxx:82
const_reverse_iterator crbegin() const
Definition: result.cxx:70
row_size_type table_column(row_size_type col_num) const
What column in its table did this column come from?
Definition: result.cxx:377
const char * column_name(row_size_type number) const
Name of column with this number (throws exception if it doesn't exist)
Definition: result.cxx:413