16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/compiler-internal-pre.hxx"
22 #include "pqxx/result.hxx"
23 #include "pqxx/transaction_base.hxx"
110 static difference_type all() noexcept;
125 static difference_type backward_all() noexcept;
135 const std::
string &name() const noexcept {
return m_name; }
140 const std::string &Name,
141 bool embellish_name=
true);
148 #include <pqxx/internal/sql_cursor.hxx>
160 template<cursor_base::updatepolicy up, cursor_base::ownershippolicy op>
170 const std::string &query,
171 const std::string &cname,
180 const std::string adopted_cursor) :
181 m_cur{trans, adopted_cursor, op}
187 void close() noexcept { m_cur.close(); }
209 return internal::stateless_cursor_retrieve(
216 const std::string &
name() const noexcept {
return m_cur.name(); }
219 internal::sql_cursor m_cur;
223 class icursor_iterator;
230 class icursor_iterator_icursorstream;
231 class icursorstream_icursor_iterator;
272 const std::string &query,
273 const std::string &basename,
307 operator bool() const noexcept {
return not m_done; }
337 void set_stride(difference_type stride);
343 friend class internal::gate::icursorstream_icursor_iterator;
350 internal::sql_cursor m_cur;
404 const
result &operator*()
const { refresh();
return m_here; }
413 {
return not operator==(rhs); }
416 {
return rhs < *
this; }
418 {
return not (*
this > rhs); }
420 {
return not (*
this < rhs); }
423 void refresh()
const;
425 friend class internal::gate::icursor_iterator_icursorstream;
427 void fill(
const result &);
431 difference_type m_pos;
436 #include "pqxx/compiler-internal-post.hxx"
PQXX_PURE size_type size() const noexcept
Definition: result.cxx:94
std::input_iterator_tag iterator_category
Definition: cursor.hxx:391
bool operator>=(const icursor_iterator &rhs) const
Definition: cursor.hxx:419
icursorstream & ignore(std::streamsize n=1)
Move given number of rows forward (ignoring stride) without reading data.
Definition: cursor.cxx:133
"Stateless cursor" class: easy API for retrieving parts of result sets
Definition: cursor.hxx:161
difference_type stride() const noexcept
Definition: cursor.hxx:338
cursor_base::size_type size_type
Definition: cursor.hxx:255
const std::string m_name
Definition: cursor.hxx:143
~icursor_iterator() noexcept
Definition: cursor.cxx:229
std::string adorn_name(const std::string &)
Suffix unique number to name to make it unique within session context.
Definition: connection_base.cxx:1380
Private namespace for libpqxx's internal use; do not access.
Definition: connection_base.hxx:43
icursor_iterator & operator+=(difference_type)
Definition: cursor.cxx:255
const std::string & name() const noexcept
Definition: cursor.hxx:216
result_difference_type difference_type
Definition: result.hxx:73
accesspolicy
Cursor access-pattern policy.
Definition: cursor.hxx:50
@ forward_only
Cursor can move forward only.
Definition: cursor.hxx:53
result_size_type size_type
Definition: cursor.hxx:164
icursorstream & operator>>(result &res)
Read new value into given result object; same as get(result &)
Definition: cursor.hxx:324
bool operator<=(const icursor_iterator &rhs) const
Definition: cursor.hxx:417
Result set containing data returned by a query or command.
Definition: result.hxx:69
istream_type::size_type size_type
Definition: cursor.hxx:396
signed long result_difference_type
Difference between result sizes.
Definition: types.hxx:21
Approximate istream_iterator for icursorstream.
Definition: cursor.hxx:388
result_difference_type difference_type
Definition: cursor.hxx:165
const result * operator->() const
Definition: cursor.hxx:405
@ read_only
Cursor can be used to read data but not to write.
Definition: cursor.hxx:65
result_size_type size_type
Definition: result.hxx:72
static difference_type all() noexcept
Special value: read until end.
Definition: cursor.cxx:27
bool operator==(const icursor_iterator &rhs) const
Definition: cursor.cxx:292
Reference to a field in a result set.
Definition: field.hxx:49
PQXX_PURE bool empty() const noexcept
Definition: result.cxx:100
size_type size()
Number of rows in cursor's result set.
Definition: cursor.hxx:193
Simple read-only cursor represented as a stream of results.
Definition: cursor.hxx:252
updatepolicy
Cursor update policy.
Definition: cursor.hxx:62
result_size_type size_type
Definition: cursor.hxx:43
static difference_type backward_all() noexcept
Special value: read backwards from current position back to origin.
Definition: cursor.cxx:35
stateless_cursor(transaction_base &trans, const std::string &query, const std::string &cname, bool hold)
Create cursor.
Definition: cursor.hxx:168
unsigned long result_size_type
Number of rows in a result set.
Definition: types.hxx:18
istream_type::difference_type difference_type
Definition: cursor.hxx:397
icursorstream & get(result &res)
Read new value into given result object; same as operator >>
Definition: cursor.hxx:316
icursor_iterator & operator=(const icursor_iterator &) noexcept
Definition: cursor.cxx:271
result_difference_type difference_type
Definition: cursor.hxx:44
stateless_cursor(transaction_base &trans, const std::string adopted_cursor)
Adopt existing scrolling SQL cursor.
Definition: cursor.hxx:178
Invalid argument passed to libpqxx, similar to std::invalid_argument.
Definition: except.hxx:229
cursor_base::difference_type difference_type
Definition: cursor.hxx:256
@ random_access
Cursor can move back and forth.
Definition: cursor.hxx:55
std::string to_string(const field &Obj)
Convert a field to a string.
Definition: result.cxx:451
bool operator>(const icursor_iterator &rhs) const
Definition: cursor.hxx:415
Common definitions for cursor types.
Definition: cursor.hxx:40
icursorstream(transaction_base &context, const std::string &query, const std::string &basename, difference_type sstride=1)
Set up a read-only, forward-only cursor.
Definition: cursor.cxx:79
@ owned
Destroy SQL cursor when cursor object is closed at end of transaction.
Definition: cursor.hxx:92
connection_base abstract base class; represents a connection to a database.
Definition: connection_base.hxx:139
icursor_iterator & operator++()
Definition: cursor.cxx:246
result retrieve(difference_type begin_pos, difference_type end_pos)
Retrieve rows from begin_pos (inclusive) to end_pos (exclusive)
Definition: cursor.hxx:207
bool operator<(const icursor_iterator &rhs) const
Definition: cursor.cxx:302
ownershippolicy
Cursor destruction policy.
Definition: cursor.hxx:89
static difference_type prior() noexcept
Special value: read backwards, one row only.
Definition: cursor.hxx:120
void close() noexcept
Definition: cursor.hxx:187
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:251
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:136
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
void set_stride(difference_type stride)
Change stride, i.e. the number of rows to fetch per read operation.
Definition: cursor.cxx:117
const char * c_str() const
Read as plain C string.
Definition: field.cxx:62
bool operator!=(const icursor_iterator &rhs) const noexcept
Definition: cursor.hxx:412
icursor_iterator() noexcept
Definition: cursor.cxx:204