libpqxx
The C++ client library for PostgreSQL
sql_cursor.hxx
Go to the documentation of this file.
1 
11 #ifndef PQXX_INTERNAL_SQL_CURSOR_HXX
12 #define PQXX_INTERNAL_SQL_CURSOR_HXX
13 
14 namespace pqxx::internal
15 {
17 
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, sl = sl::current());
38 
39  sql_cursor(
40  transaction_base &t, std::string_view cname,
41  cursor_base::ownership_policy op, sl = sl::current());
42 
43  sql_cursor(sql_cursor const &) = delete;
44  sql_cursor(sql_cursor &&) = delete;
45  ~sql_cursor() noexcept;
46 
47  sql_cursor &operator=(sql_cursor const &) = delete;
48  sql_cursor &operator=(sql_cursor &&) = delete;
49 
50  result fetch(difference_type rows, difference_type &displacement, sl);
52  {
53  difference_type d = 0;
54  return fetch(rows, d, loc);
55  }
56  difference_type
57  move(difference_type rows, difference_type &displacement, sl);
59  {
60  difference_type d = 0;
61  return move(rows, d, loc);
62  }
63 
65 
71  PQXX_INLINE_COV [[nodiscard]] difference_type pos() const noexcept
72  {
73  return m_pos;
74  }
75 
77 
83  PQXX_INLINE_COV [[nodiscard]] difference_type endpos() const noexcept
84  {
85  return m_endpos;
86  }
87 
89  PQXX_INLINE_COV [[nodiscard]] result const &empty_result() const noexcept
90  {
91  return m_empty_result;
92  }
93 
94  void close(sl loc);
95 
96  PQXX_PURE [[nodiscard]] constexpr sl created_loc() const noexcept
97  {
98  return m_created_loc;
99  }
100 
101 private:
102  difference_type adjust(difference_type hoped, difference_type actual);
103  static std::string stridestring(difference_type);
105  void init_empty_result(transaction_base &, sl);
106 
108  connection &m_home;
109 
112  result m_empty_result;
113 
114  result m_cached_current_row;
115 
117  cursor_base::ownership_policy m_ownership;
118 
120  int m_at_end;
121 
123  difference_type m_pos;
124 
126  difference_type m_endpos = -1;
127 
129  sl m_created_loc;
130 };
131 
132 
135  sql_cursor &, result::difference_type size,
137 } // namespace pqxx::internal
138 #endif
Connection to a database.
Definition: connection.hxx:273
Common definitions for cursor types.
Definition: cursor.hxx:42
access_policy
Cursor access-pattern policy.
Definition: cursor.hxx:52
ownership_policy
Cursor destruction policy.
Definition: cursor.hxx:88
update_policy
Cursor update policy.
Definition: cursor.hxx:64
result_difference_type difference_type
Definition: cursor.hxx:45
Cursor with SQL positioning semantics.
Definition: sql_cursor.hxx:32
sql_cursor(sql_cursor const &)=delete
PQXX_INLINE_COV difference_type endpos() const noexcept
End position, or -1 for unknown.
Definition: sql_cursor.hxx:83
constexpr PQXX_PURE sl created_loc() const noexcept
Definition: sql_cursor.hxx:96
sql_cursor(sql_cursor &&)=delete
PQXX_INLINE_COV difference_type move(difference_type rows, sl loc)
Definition: sql_cursor.hxx:58
PQXX_INLINE_COV result const & empty_result() const noexcept
Return zero-row result for this cursor.
Definition: sql_cursor.hxx:89
PQXX_INLINE_COV difference_type pos() const noexcept
Current position, or -1 for unknown.
Definition: sql_cursor.hxx:71
Result set containing data returned by a query or command.
Definition: result.hxx:101
result_difference_type difference_type
Definition: result.hxx:104
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:151
#define PQXX_LIBEXPORT
Definition: header-pre.hxx:206
#define PQXX_PURE
Definition: header-pre.hxx:64
#define PQXX_INLINE_COV
Don't generate out-of-line version of inline function for coverage runs.
Definition: header-pre.hxx:98
Private namespace for libpqxx's internal use; do not access.
Definition: connection.cxx:333
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
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
int result_size_type
Number of rows in a result set.
Definition: types.hxx:77