13 #ifndef PQXX_CURSOR_HXX
14 #define PQXX_CURSOR_HXX
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
118 return (std::numeric_limits<int>::max)() - 1;
139 return (std::numeric_limits<int>::min)() + 1;
150 [[nodiscard]] constexpr std::string
const &
name() const noexcept
159 connection &, std::string_view Name,
bool embellish_name =
true,
160 sl loc = sl::current());
166 return m_created_loc;
176 "This will become private. Use name() instead.")]] std::string
const
180 [[deprecated(
"This will become private. Use created_loc() instead.")]]
sl
203 template<cursor_base::update_policy up, cursor_base::ownership_policy op>
221 bool hold,
sl loc = sl::current()) :
222 m_cur{tx, query, cname,
cursor_base::random_access,
235 sl loc = sl::current()) :
236 m_cur{tx, adopted_cursor, op}
286 [[nodiscard]] constexpr std::string
const &
name() const noexcept
296 class icursor_iterator;
302 class icursor_iterator_icursorstream;
303 class icursorstream_icursor_iterator;
380 constexpr
operator bool() const & noexcept {
return not m_done; }
395 res = fetchblock(loc);
422 void set_stride(difference_type stride,
sl = sl::current()) &;
431 return m_cur.created_loc();
503 refresh(created_loc());
508 refresh(created_loc());
528 return not(*
this > rhs);
532 return not(*
this < rhs);
536 void refresh(
sl)
const;
540 void fill(
result const &);
549 [[nodiscard]]
PQXX_PURE sl created_loc(
sl loc = sl::current()) const noexcept
551 return (m_stream ==
nullptr) ? loc : m_stream->created_loc();
563 best_location(icursor_iterator
const &other,
sl loc = sl::current())
const
565 if (m_stream !=
nullptr)
566 return created_loc();
568 return other.created_loc(loc);
571 icursorstream *m_stream{
nullptr};
573 difference_type m_pos;
575 icursor_iterator *m_prev{
nullptr}, *m_next{
nullptr};
Connection to a database.
Definition: connection.hxx:273
Common definitions for cursor types.
Definition: cursor.hxx:42
cursor_base & operator=(cursor_base const &)=delete
cursor_base(cursor_base &&)=delete
result_size_type size_type
Definition: cursor.hxx:44
constexpr std::string const & name() const noexcept
Name of underlying SQL cursor.
Definition: cursor.hxx:150
static constexpr difference_type next() noexcept
Special value: read one row only.
Definition: cursor.hxx:124
cursor_base(cursor_base const &)=delete
static constexpr difference_type all() noexcept
Special value: read until end.
Definition: cursor.hxx:116
static constexpr difference_type prior() noexcept
Special value: read backwards, one row only.
Definition: cursor.hxx:129
cursor_base & operator=(cursor_base &&)=delete
access_policy
Cursor access-pattern policy.
Definition: cursor.hxx:52
@ forward_only
Cursor can move forward only.
Definition: cursor.hxx:54
ownership_policy
Cursor destruction policy.
Definition: cursor.hxx:88
@ owned
Destroy SQL cursor when cursor object is closed at end of transaction.
Definition: cursor.hxx:90
update_policy
Cursor update policy.
Definition: cursor.hxx:64
@ read_only
Cursor can be used to read data but not to write.
Definition: cursor.hxx:66
result_difference_type difference_type
Definition: cursor.hxx:45
sl m_created_loc
The std::source_location for where this cursor was created.
Definition: cursor.hxx:181
sl created_loc() const
The std::source_location for where this cursor was created.
Definition: cursor.hxx:163
std::string const m_name
Definition: cursor.hxx:177
static constexpr difference_type backward_all() noexcept
Special value: read backwards from current position back to origin.
Definition: cursor.hxx:137
Reference to a field in a result set.
Definition: field.hxx:309
Approximate istream_iterator for icursorstream.
Definition: cursor.hxx:483
bool operator!=(icursor_iterator const &rhs) const noexcept
Definition: cursor.hxx:517
result const * pointer
Definition: cursor.hxx:487
bool operator>=(icursor_iterator const &rhs) const
Definition: cursor.hxx:530
bool operator>(icursor_iterator const &rhs) const
Definition: cursor.hxx:522
PQXX_RETURNS_NONNULL result const * operator->() const noexcept
Definition: cursor.hxx:506
result const & reference
Definition: cursor.hxx:488
istream_type::difference_type difference_type
Definition: cursor.hxx:491
std::input_iterator_tag iterator_category
Definition: cursor.hxx:485
bool operator<=(icursor_iterator const &rhs) const
Definition: cursor.hxx:526
istream_type::size_type size_type
Definition: cursor.hxx:490
Simple read-only cursor represented as a stream of results.
Definition: cursor.hxx:326
PQXX_PURE sl created_loc() const noexcept
The `std::source_location for where this stream was created.
Definition: cursor.hxx:429
cursor_base::size_type size_type
Definition: cursor.hxx:328
icursorstream & operator>>(result &res)
Read new value into given result object; same as get(result&).
Definition: cursor.hxx:407
cursor_base::difference_type difference_type
Definition: cursor.hxx:329
icursorstream & get(result &res, sl loc=sl::current())
Read new value into given result object; same as operator >>.
Definition: cursor.hxx:393
constexpr difference_type stride() const noexcept
Definition: cursor.hxx:423
Definition: icursor_iterator-icursorstream.hxx:10
Definition: icursorstream-icursor_iterator.hxx:10
Cursor with SQL positioning semantics.
Definition: sql_cursor.hxx:32
difference_type move(difference_type rows, difference_type &displacement, sl)
Definition: sql_cursor.cxx:286
void close(sl loc)
Definition: sql_cursor.cxx:194
Result set containing data returned by a query or command.
Definition: result.hxx:101
result_difference_type difference_type
Definition: result.hxx:104
"Stateless cursor" class: easy API for retrieving parts of result sets
Definition: cursor.hxx:205
void close(sl loc=sl::current())
Close this cursor.
Definition: cursor.hxx:255
result retrieve(difference_type begin_pos, difference_type end_pos, sl loc=sl::current())
Retrieve rows from begin_pos (inclusive) to end_pos (exclusive)
Definition: cursor.hxx:278
stateless_cursor & operator=(stateless_cursor const &)=delete
~stateless_cursor()=default
stateless_cursor(stateless_cursor const &)=delete
stateless_cursor(transaction_base &tx, std::string_view adopted_cursor, sl loc=sl::current())
Adopt an existing scrolling SQL cursor.
Definition: cursor.hxx:233
stateless_cursor(stateless_cursor &&)=default
size_type size(sl loc=sl::current())
Number of rows in cursor's result set.
Definition: cursor.hxx:261
result_size_type size_type
Definition: cursor.hxx:207
result_difference_type difference_type
Definition: cursor.hxx:208
constexpr std::string const & name() const noexcept
Return this cursor's name.
Definition: cursor.hxx:286
stateless_cursor(transaction_base &tx, std::string_view query, std::string_view cname, bool hold, sl loc=sl::current())
Create cursor.
Definition: cursor.hxx:219
stateless_cursor & operator=(stateless_cursor &&)=default
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:151
Definition: connection.hxx:94
PQXX_LIBEXPORT result_size_type obtain_stateless_cursor_size(sql_cursor &, sl)
Definition: cursor.cxx:36
PQXX_LIBEXPORT result stateless_cursor_retrieve(sql_cursor &, result::difference_type size, result::difference_type begin_pos, result::difference_type end_pos, sl)
Definition: cursor.cxx:44
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
int result_difference_type
Difference between result sizes.
Definition: types.hxx:80
int result_size_type
Number of rows in a result set.
Definition: types.hxx:77
constexpr bool operator==(char const lhs[], pqxx::zview rhs) noexcept
Disambiguating comparison operator: leave it to std::string_view.
Definition: zview.hxx:203