16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
22 #include "pqxx/result.hxx"
23 #include "pqxx/transaction_base.hxx"
107 [[nodiscard]]
static difference_type all() noexcept;
122 [[nodiscard]]
static difference_type backward_all() noexcept;
132 [[nodiscard]] std::
string const &name() const noexcept {
return m_name; }
142 #include <pqxx/internal/sql_cursor.hxx>
154 template<cursor_base::update_policy up, cursor_base::ownership_policy op>
170 m_cur{trans, adopted_cursor, op}
176 void close() noexcept { m_cur.close(); }
184 return internal::obtain_stateless_cursor_size(m_cur);
201 return internal::stateless_cursor_retrieve(
205 [[nodiscard]] std::string
const &
name() const noexcept
211 internal::sql_cursor m_cur;
215 class icursor_iterator;
221 class icursor_iterator_icursorstream;
222 class icursorstream_icursor_iterator;
295 operator bool() const noexcept {
return not m_done; }
329 void set_stride(difference_type stride);
335 friend class internal::gate::icursorstream_icursor_iterator;
342 internal::sql_cursor m_cur;
414 return not operator==(rhs);
423 return not(*
this > rhs);
427 return not(*
this < rhs);
431 void refresh()
const;
433 friend class internal::gate::icursor_iterator_icursorstream;
435 void fill(
result const &);
439 difference_type m_pos;
440 icursor_iterator *m_prev{
nullptr}, *m_next{
nullptr};
444 #include "pqxx/internal/compiler-internal-post.hxx"
PQXX_PURE bool empty() const noexcept
Definition: result.cxx:108
int result_size_type
Number of rows in a result set.
Definition: types.hxx:18
const std::string & name() const noexcept
Definition: cursor.hxx:205
static difference_type backward_all() noexcept
Special value: read backwards from current position back to origin.
Definition: cursor.cxx:32
const std::string m_name
Definition: cursor.hxx:137
Common definitions for cursor types.
Definition: cursor.hxx:40
bool operator<=(icursor_iterator const &rhs) const
Definition: cursor.hxx:421
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
icursor_iterator & operator+=(difference_type)
Definition: cursor.cxx:260
access_policy
Cursor access-pattern policy.
Definition: cursor.hxx:50
result const * pointer
Definition: cursor.hxx:385
const result * operator->() const
Definition: cursor.hxx:401
Definition: connection.hxx:65
std::string to_string(field const &value)
Convert a field to a string.
Definition: result.cxx:478
icursorstream & ignore(std::streamsize n=1)
Move given number of rows forward (ignoring stride) without reading data.
Definition: cursor.cxx:129
size_type size()
Number of rows in cursor's result set.
Definition: cursor.hxx:182
cursor_base::difference_type difference_type
Definition: cursor.hxx:248
cursor_base::size_type size_type
Definition: cursor.hxx:247
result_size_type size_type
Definition: cursor.hxx:158
std::input_iterator_tag iterator_category
Definition: cursor.hxx:383
result retrieve(difference_type begin_pos, difference_type end_pos)
Retrieve rows from begin_pos (inclusive) to end_pos (exclusive)
Definition: cursor.hxx:199
icursor_iterator & operator++()
Definition: cursor.cxx:251
icursorstream(transaction_base &context, std::string_view query, std::string_view basename, difference_type sstride=1)
Set up a read-only, forward-only cursor.
Definition: cursor.cxx:76
icursor_iterator & operator=(icursor_iterator const &) noexcept
Definition: cursor.cxx:277
std::string adorn_name(std::string_view)
Suffix unique number to name to make it unique within session context.
Definition: connection.cxx:976
@ forward_only
Cursor can move forward only.
Definition: cursor.hxx:53
result_difference_type difference_type
Definition: result.hxx:74
bool operator>(icursor_iterator const &rhs) const
Definition: cursor.hxx:417
result_difference_type difference_type
Definition: cursor.hxx:44
Simple read-only cursor represented as a stream of results.
Definition: cursor.hxx:244
istream_type::difference_type difference_type
Definition: cursor.hxx:389
stateless_cursor(transaction_base &trans, std::string_view adopted_cursor)
Adopt existing scrolling SQL cursor.
Definition: cursor.hxx:169
bool operator!=(icursor_iterator const &rhs) const noexcept
Definition: cursor.hxx:412
ownership_policy
Cursor destruction policy.
Definition: cursor.hxx:86
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 size_type size() const noexcept
Definition: result.cxx:100
bool operator>=(icursor_iterator const &rhs) const
Definition: cursor.hxx:425
static difference_type all() noexcept
Special value: read until end.
Definition: cursor.cxx:24
icursorstream & get(result &res)
Read new value into given result object; same as operator >>
Definition: cursor.hxx:304
bool operator<(icursor_iterator const &rhs) const
Definition: cursor.cxx:312
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:97
"Stateless cursor" class: easy API for retrieving parts of result sets
Definition: cursor.hxx:155
~icursor_iterator() noexcept
Definition: cursor.cxx:233
result_size_type size_type
Definition: result.hxx:73
@ read_only
Cursor can be used to read data but not to write.
Definition: cursor.hxx:65
@ owned
Destroy SQL cursor when cursor object is closed at end of transaction.
Definition: cursor.hxx:89
void close() noexcept
Definition: cursor.hxx:176
result_difference_type difference_type
Definition: cursor.hxx:159
icursorstream & operator>>(result &res)
Read new value into given result object; same as get(result &)
Definition: cursor.hxx:316
update_policy
Cursor update policy.
Definition: cursor.hxx:62
result_size_type size_type
Definition: cursor.hxx:43
istream_type::size_type size_type
Definition: cursor.hxx:388
Invalid argument passed to libpqxx, similar to std::invalid_argument.
Definition: except.hxx:171
Connection to a database.
Definition: connection.hxx:135
@ random_access
Cursor can move back and forth.
Definition: cursor.hxx:55
void set_stride(difference_type stride)
Change stride, i.e. the number of rows to fetch per read operation.
Definition: cursor.cxx:110
const char * c_str() const
Read as plain C string.
Definition: field.cxx:62
difference_type stride() const noexcept
Definition: cursor.hxx:330
Reference to a field in a result set.
Definition: field.hxx:32
icursor_iterator() noexcept
Definition: cursor.cxx:208
Approximate istream_iterator for icursorstream.
Definition: cursor.hxx:380
result const & reference
Definition: cursor.hxx:386
stateless_cursor(transaction_base &trans, std::string_view query, std::string_view cname, bool hold)
Create cursor.
Definition: cursor.hxx:162
bool operator==(icursor_iterator const &rhs) const
Definition: cursor.cxx:300
static difference_type prior() noexcept
Special value: read backwards, one row only.
Definition: cursor.hxx:117