libpqxx
The C++ client library for PostgreSQL
sql_cursor.hxx
1 
11 #ifndef PQXX_H_SQL_CURSOR
12 #define PQXX_H_SQL_CURSOR
13 
14 namespace pqxx::internal
15 {
17 
31 class PQXX_LIBEXPORT sql_cursor : public cursor_base
32 {
33 public:
34  sql_cursor(
35  transaction_base &t, std::string_view query, std::string_view cname,
37  cursor_base::ownership_policy op, bool hold);
38 
39  sql_cursor(
40  transaction_base &t, std::string_view cname,
42 
43  ~sql_cursor() noexcept { close(); }
44 
45  result fetch(difference_type rows, difference_type &displacement);
46  result fetch(difference_type rows)
47  {
48  difference_type d = 0;
49  return fetch(rows, d);
50  }
51  difference_type move(difference_type rows, difference_type &displacement);
52  difference_type move(difference_type rows)
53  {
54  difference_type d = 0;
55  return move(rows, d);
56  }
57 
59 
65  difference_type pos() const noexcept { return m_pos; }
66 
68 
74  difference_type endpos() const noexcept { return m_endpos; }
75 
77  result const &empty_result() const noexcept { return m_empty_result; }
78 
79  void close() noexcept;
80 
81 private:
82  difference_type adjust(difference_type hoped, difference_type actual);
83  static std::string stridestring(difference_type);
85  void init_empty_result(transaction_base &);
86 
88  connection &m_home;
89 
92  result m_empty_result;
93 
94  result m_cached_current_row;
95 
97  cursor_base::ownership_policy m_ownership;
98 
100  int m_at_end;
101 
103  difference_type m_pos;
104 
106  difference_type m_endpos = -1;
107 };
108 
109 
110 PQXX_LIBEXPORT result_size_type obtain_stateless_cursor_size(sql_cursor &);
111 PQXX_LIBEXPORT result stateless_cursor_retrieve(
112  sql_cursor &, result::difference_type size,
113  result::difference_type begin_pos, result::difference_type end_pos);
114 } // namespace pqxx::internal
115 #endif
Common definitions for cursor types.
Definition: cursor.hxx:41
Internal items for libpqxx' own use. Do not use these yourself.
Definition: encodings.cxx:32
difference_type endpos() const noexcept
End position, or -1 for unknown.
Definition: sql_cursor.hxx:74
result const & empty_result() const noexcept
Return zero-row result for this cursor.
Definition: sql_cursor.hxx:77
Result set containing data returned by a query or command.
Definition: result.hxx:91
int result_size_type
Number of rows in a result set.
Definition: types.hxx:28
Cursor with SQL positioning semantics.
Definition: sql_cursor.hxx:31
Connection to a database.
Definition: connection.hxx:278
difference_type pos() const noexcept
Current position, or -1 for unknown.
Definition: sql_cursor.hxx:65
access_policy
Cursor access-pattern policy.
Definition: cursor.hxx:51
update_policy
Cursor update policy.
Definition: cursor.hxx:63
ownership_policy
Cursor destruction policy.
Definition: cursor.hxx:87
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:150