1
1
/* *
2
2
* @file RowExecutor.h
3
3
* @ingroup SQLiteCpp
4
- * @brief TODO:
4
+ * @brief Step executor for SQLite prepared Statement Object
5
5
*
6
6
* Copyright (c) 2015 Shibao HONG ([email protected] )
7
7
* Copyright (c) 2015-2021 Sebastien Rombauts ([email protected] )
@@ -45,6 +45,11 @@ class RowExecutor
45
45
// / Type to store columns names and indexes
46
46
using TColumnsMap = std::map<std::string, int , std::less<>>;
47
47
48
+ RowExecutor (const RowExecutor&) = delete ;
49
+ RowExecutor (RowExecutor&&) = default ;
50
+ RowExecutor& operator =(const RowExecutor&) = delete ;
51
+ RowExecutor& operator =(RowExecutor&&) = default ;
52
+
48
53
// / Reset the statement to make it ready for a new execution. Throws an exception on error.
49
54
void reset ();
50
55
@@ -130,17 +135,17 @@ class RowExecutor
130
135
int getChanges () const noexcept ;
131
136
132
137
// / Return the number of columns in the result set returned by the prepared statement
133
- int getColumnCount () const
138
+ int getColumnCount () const noexcept
134
139
{
135
140
return mColumnCount ;
136
141
}
137
142
// / true when a row has been fetched with executeStep()
138
- bool hasRow () const
143
+ bool hasRow () const noexcept
139
144
{
140
145
return mbHasRow;
141
146
}
142
147
// / true when the last executeStep() had no more row to fetch
143
- bool isDone () const
148
+ bool isDone () const noexcept
144
149
{
145
150
return mbDone;
146
151
}
@@ -167,7 +172,10 @@ class RowExecutor
167
172
*
168
173
* @return raw pointer to Statement Object
169
174
*/
170
- TStatementPtr getStatement () const noexcept ;
175
+ TStatementPtr getStatement () const noexcept
176
+ {
177
+ return mpStatement;
178
+ }
171
179
172
180
/* *
173
181
* @brief Return a prepared SQLite Statement Object.
@@ -176,6 +184,19 @@ class RowExecutor
176
184
* @return raw pointer to Prepared Statement Object
177
185
*/
178
186
sqlite3_stmt* getPreparedStatement () const ;
187
+
188
+ /* *
189
+ * @brief Return a prepared SQLite Statement Object.
190
+ *
191
+ * Throw an exception if the statement object was not prepared.
192
+ * @return raw pointer to Prepared Statement Object
193
+ */
194
+ TRowWeakPtr getExecutorWeakPtr () const
195
+ {
196
+ return mpRowExecutor;
197
+ }
198
+
199
+ // //////////////////////////////////////////////////////////////////////////
179
200
180
201
/* *
181
202
* @brief Check if a return code equals SQLITE_OK, else throw a SQLite::Exception with the SQLite error message
@@ -222,9 +243,13 @@ class RowExecutor
222
243
sqlite3* mpSQLite{}; // !< Pointer to SQLite Database Connection Handle
223
244
TStatementPtr mpStatement{}; // !< Shared Pointer to the prepared SQLite Statement Object
224
245
225
- int mColumnCount { 0 }; // !< Number of columns in the result of the prepared statement
226
- bool mbHasRow{ false }; // !< true when a row has been fetched with executeStep()
227
- bool mbDone{ false }; // !< true when the last executeStep() had no more row to fetch
246
+ // / Shared Pointer to this object.
247
+ // / Allows RowIterator to execute next step
248
+ TRowPtr mpRowExecutor{};
249
+
250
+ int mColumnCount = 0 ; // !< Number of columns in the result of the prepared statement
251
+ bool mbHasRow = false ; // !< true when a row has been fetched with executeStep()
252
+ bool mbDone = false ; // !< true when the last executeStep() had no more row to fetch
228
253
229
254
// / Map of columns index by name (mutable so getColumnIndex can be const)
230
255
mutable TColumnsMap mColumnNames {};
0 commit comments