Skip to content

Commit 4117377

Browse files
committed
Rename RowExecutor to StatementExecutor
1 parent 826a17f commit 4117377

7 files changed

Lines changed: 45 additions & 45 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ set(SQLITECPP_SRC
106106
${PROJECT_SOURCE_DIR}/src/Database.cpp
107107
${PROJECT_SOURCE_DIR}/src/Exception.cpp
108108
${PROJECT_SOURCE_DIR}/src/Row.cpp
109-
${PROJECT_SOURCE_DIR}/src/RowExecutor.cpp
110109
${PROJECT_SOURCE_DIR}/src/Savepoint.cpp
111110
${PROJECT_SOURCE_DIR}/src/Statement.cpp
111+
${PROJECT_SOURCE_DIR}/src/StatementExecutor.cpp
112112
${PROJECT_SOURCE_DIR}/src/Transaction.cpp
113113
)
114114
source_group(src FILES ${SQLITECPP_SRC})
@@ -122,9 +122,9 @@ set(SQLITECPP_INC
122122
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/Database.h
123123
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/Exception.h
124124
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/Row.h
125-
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/RowExecutor.h
126125
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/Savepoint.h
127126
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/Statement.h
127+
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/StatementExecutor.h
128128
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/Transaction.h
129129
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/VariadicBind.h
130130
${PROJECT_SOURCE_DIR}/include/SQLiteCpp/ExecuteMany.h

include/SQLiteCpp/Column.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Column
5555
*
5656
* @throws Exception is thrown in case of error, then the Column object is NOT constructed.
5757
*/
58-
explicit Column(const RowExecutor::TStatementPtr& aStmtPtr, int aIndex);
58+
explicit Column(const StatementExecutor::TStatementPtr& aStmtPtr, int aIndex);
5959

6060
/**
6161
* @brief Return a pointer to the named assigned to this result column (potentially aliased)
@@ -226,7 +226,7 @@ class Column
226226
}
227227

228228
private:
229-
RowExecutor::TStatementPtr mStmtPtr; ///< Shared Pointer to the prepared SQLite Statement Object
229+
StatementExecutor::TStatementPtr mStmtPtr; ///< Shared Pointer to the prepared SQLite Statement Object
230230
int mIndex; ///< Index of the column in the row of result, starting at 0
231231
};
232232

include/SQLiteCpp/Statement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
#pragma once
1212

13-
#include <SQLiteCpp/RowExecutor.h>
13+
#include <SQLiteCpp/StatementExecutor.h>
1414
#include <SQLiteCpp/Exception.h>
1515
#include <SQLiteCpp/Utils.h> // SQLITECPP_PURE_FUNC
1616

@@ -46,7 +46,7 @@ class Column;
4646
* because of the way it shares the underling SQLite precompiled statement
4747
* in a custom shared pointer (See the inner class "Statement::Ptr").
4848
*/
49-
class Statement : public RowExecutor
49+
class Statement : public StatementExecutor
5050
{
5151
public:
5252
/**
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file RowExecutor.h
2+
* @file StatementExecutor.h
33
* @ingroup SQLiteCpp
44
* @brief Step executor for SQLite prepared Statement Object
55
*
@@ -33,15 +33,15 @@ extern const int OK; ///< SQLITE_OK
3333
* inherit this class to create your own Statement executor class.
3434
* Either way you should look at SQLite::Statement documentation
3535
*
36-
* Thread-safety: a RowExecutor object shall not be shared by multiple threads, because :
36+
* Thread-safety: a StatementExecutor object shall not be shared by multiple threads, because :
3737
* 1) in the SQLite "Thread Safe" mode, "SQLite can be safely used by multiple threads
3838
* provided that no single database connection is used simultaneously in two or more threads."
3939
* 2) the SQLite "Serialized" mode is not supported by SQLiteC++,
4040
* because of the way it shares the underling SQLite precompiled statement
4141
* in a custom shared pointer (See the inner class "Statement::Ptr").
4242
* TODO Test Serialized mode after all changes to pointers
4343
*/
44-
class RowExecutor
44+
class StatementExecutor
4545
{
4646
public:
4747
/// Shared pointer to SQLite Prepared Statement Object
@@ -50,19 +50,19 @@ class RowExecutor
5050
/// Weak pointer to SQLite Prepared Statement Object
5151
using TStatementWeakPtr = std::weak_ptr<sqlite3_stmt>;
5252

53-
/// Shared pointer to SQLite RowExecutor
54-
using TRowPtr = std::shared_ptr<RowExecutor>;
53+
/// Shared pointer to SQLite StatementExecutor
54+
using TRowPtr = std::shared_ptr<StatementExecutor>;
5555

56-
/// Weak pointer to SQLite RowExecutor
57-
using TRowWeakPtr = std::weak_ptr<RowExecutor>;
56+
/// Weak pointer to SQLite StatementExecutor
57+
using TRowWeakPtr = std::weak_ptr<StatementExecutor>;
5858

5959
/// Type to store columns names and indexes
6060
using TColumnsMap = std::map<std::string, int, std::less<>>;
6161

62-
RowExecutor(const RowExecutor&) = delete;
63-
RowExecutor(RowExecutor&&) = default;
64-
RowExecutor& operator=(const RowExecutor&) = delete;
65-
RowExecutor& operator=(RowExecutor&&) = default;
62+
StatementExecutor(const StatementExecutor&) = delete;
63+
StatementExecutor(StatementExecutor&&) = default;
64+
StatementExecutor& operator=(const StatementExecutor&) = delete;
65+
StatementExecutor& operator=(StatementExecutor&&) = default;
6666

6767
/// Reset the statement to make it ready for a new execution. Throws an exception on error.
6868
void reset();
@@ -168,7 +168,7 @@ class RowExecutor
168168
/**
169169
* @brief InputIterator for statement steps.
170170
*
171-
* Remember that this iterator is changing state of RowExecutor.
171+
* Remember that this iterator is changing state of StatementExecutor.
172172
*/
173173
class RowIterator
174174
{
@@ -217,7 +217,7 @@ class RowExecutor
217217
void advance() noexcept;
218218

219219
TStatementWeakPtr mpStatement{}; //!< Weak pointer to SQLite Statement Object
220-
TRowWeakPtr mpRow{}; //!< Weak pointer to RowExecutor Object
220+
TRowWeakPtr mpRow{}; //!< Weak pointer to StatementExecutor Object
221221
uint16_t mID{}; //!< Current row number
222222

223223
/// Internal row object storage
@@ -247,9 +247,9 @@ class RowExecutor
247247
* @param[in] apSQLite the SQLite Database Connection
248248
* @param[in] aQuery an UTF-8 encoded query string
249249
*
250-
* @throws Exception is thrown in case of error, then the RowExecutor object is NOT constructed.
250+
* @throws Exception is thrown in case of error, then the StatementExecutor object is NOT constructed.
251251
*/
252-
explicit RowExecutor(sqlite3* apSQLite, const std::string& aQuery);
252+
explicit StatementExecutor(sqlite3* apSQLite, const std::string& aQuery);
253253

254254
/**
255255
* @brief Return a std::shared_ptr with SQLite Statement Object.

src/Column.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const int Null = SQLITE_NULL;
2626

2727

2828
// Encapsulation of a Column in a row of the result pointed by the prepared Statement.
29-
Column::Column(const RowExecutor::TStatementPtr& aStmtPtr, int aIndex) :
29+
Column::Column(const StatementExecutor::TStatementPtr& aStmtPtr, int aIndex) :
3030
mStmtPtr(aStmtPtr),
3131
mIndex(aIndex)
3232
{

src/Statement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace SQLite
2222

2323

2424
Statement::Statement(const Database& aDatabase, const std::string& aQuery) :
25-
RowExecutor(aDatabase.getHandle(), aQuery), mQuery(aQuery)
25+
StatementExecutor(aDatabase.getHandle(), aQuery), mQuery(aQuery)
2626
{}
2727

2828
// Clears away all the bindings of a prepared statement (can be associated with #reset() above).
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file RowExecutor.cpp
2+
* @file StatementExecutor.cpp
33
* @ingroup SQLiteCpp
44
* @brief Step executor for SQLite prepared Statement Object
55
*
@@ -9,7 +9,7 @@
99
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
1010
* or copy at http://opensource.org/licenses/MIT)
1111
*/
12-
#include <SQLiteCpp/RowExecutor.h>
12+
#include <SQLiteCpp/StatementExecutor.h>
1313

1414
#include <SQLiteCpp/Exception.h>
1515

@@ -19,18 +19,18 @@ namespace SQLite
1919
{
2020

2121

22-
RowExecutor::RowExecutor(sqlite3* apSQLite, const std::string& aQuery)
22+
StatementExecutor::StatementExecutor(sqlite3* apSQLite, const std::string& aQuery)
2323
: mpSQLite(apSQLite)
2424
{
2525
prepareStatement(aQuery);
2626
createColumnInfo();
2727

28-
mpRowExecutor.swap(TRowPtr(this, [](const RowExecutor* const) {
28+
mpRowExecutor.swap(TRowPtr(this, [](const StatementExecutor* const) {
2929
// empty destructor to make shared_ptr without ownership
3030
}));
3131
}
3232

33-
void SQLite::RowExecutor::prepareStatement(const std::string& aQuery)
33+
void SQLite::StatementExecutor::prepareStatement(const std::string& aQuery)
3434
{
3535
if (!mpSQLite)
3636
throw SQLite::Exception("Can't create statement without valid database connection");
@@ -49,7 +49,7 @@ namespace SQLite
4949
});
5050
}
5151

52-
void SQLite::RowExecutor::createColumnInfo()
52+
void SQLite::StatementExecutor::createColumnInfo()
5353
{
5454
mColumnCount = sqlite3_column_count(mpStatement.get());
5555

@@ -66,21 +66,21 @@ namespace SQLite
6666
}
6767

6868
// Reset the statement to make it ready for a new execution (see also #clearBindings() bellow)
69-
void RowExecutor::reset()
69+
void StatementExecutor::reset()
7070
{
7171
const int ret = tryReset();
7272
check(ret);
7373
}
7474

75-
int RowExecutor::tryReset() noexcept
75+
int StatementExecutor::tryReset() noexcept
7676
{
7777
mbHasRow = false;
7878
mbDone = false;
7979
return sqlite3_reset(mpStatement.get());
8080
}
8181

8282
// Execute a step of the query to fetch one row of results
83-
bool RowExecutor::executeStep()
83+
bool StatementExecutor::executeStep()
8484
{
8585
const int ret = tryExecuteStep();
8686
if ((SQLITE_ROW != ret) && (SQLITE_DONE != ret)) // on row or no (more) row ready, else it's a problem
@@ -99,7 +99,7 @@ namespace SQLite
9999
}
100100

101101
// Execute a one-step query with no expected result, and return the number of changes.
102-
int RowExecutor::exec()
102+
int StatementExecutor::exec()
103103
{
104104
const int ret = tryExecuteStep();
105105
if (SQLITE_DONE != ret) // the statement has finished executing successfully
@@ -122,7 +122,7 @@ namespace SQLite
122122
return sqlite3_changes(mpSQLite);
123123
}
124124

125-
int RowExecutor::tryExecuteStep() noexcept
125+
int StatementExecutor::tryExecuteStep() noexcept
126126
{
127127
if (mbDone)
128128
{
@@ -143,31 +143,31 @@ namespace SQLite
143143
}
144144

145145
// Get number of rows modified by last INSERT, UPDATE or DELETE statement (not DROP table).
146-
int RowExecutor::getChanges() const noexcept
146+
int StatementExecutor::getChanges() const noexcept
147147
{
148148
return sqlite3_changes(mpSQLite);
149149
}
150150

151151
// Return the numeric result code for the most recent failed API call (if any).
152-
int RowExecutor::getErrorCode() const noexcept
152+
int StatementExecutor::getErrorCode() const noexcept
153153
{
154154
return sqlite3_errcode(mpSQLite);
155155
}
156156

157157
// Return the extended numeric result code for the most recent failed API call (if any).
158-
int RowExecutor::getExtendedErrorCode() const noexcept
158+
int StatementExecutor::getExtendedErrorCode() const noexcept
159159
{
160160
return sqlite3_extended_errcode(mpSQLite);
161161
}
162162

163163
// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
164-
const char* RowExecutor::getErrorMsg() const noexcept
164+
const char* StatementExecutor::getErrorMsg() const noexcept
165165
{
166166
return sqlite3_errmsg(mpSQLite);
167167
}
168168

169169
// Return prepered SQLite statement object or throw
170-
sqlite3_stmt* RowExecutor::getPreparedStatement() const
170+
sqlite3_stmt* StatementExecutor::getPreparedStatement() const
171171
{
172172
sqlite3_stmt* ret = mpStatement.get();
173173
if (ret)
@@ -177,19 +177,19 @@ namespace SQLite
177177
throw SQLite::Exception("Statement was not prepared.");
178178
}
179179

180-
RowExecutor::RowIterator RowExecutor::begin()
180+
StatementExecutor::RowIterator StatementExecutor::begin()
181181
{
182182
reset();
183183
tryExecuteStep();
184-
return RowExecutor::RowIterator(getStatement(), getExecutorWeakPtr(), 0);
184+
return StatementExecutor::RowIterator(getStatement(), getExecutorWeakPtr(), 0);
185185
}
186186

187-
RowExecutor::RowIterator RowExecutor::end()
187+
StatementExecutor::RowIterator StatementExecutor::end()
188188
{
189-
return RowExecutor::RowIterator();
189+
return StatementExecutor::RowIterator();
190190
}
191191

192-
void RowExecutor::RowIterator::advance() noexcept
192+
void StatementExecutor::RowIterator::advance() noexcept
193193
{
194194
if (mpRow.expired())
195195
return;
@@ -204,7 +204,7 @@ namespace SQLite
204204
}
205205
}
206206

207-
bool RowExecutor::RowIterator::operator==(const RowIterator& aIt) const
207+
bool StatementExecutor::RowIterator::operator==(const RowIterator& aIt) const
208208
{
209209
auto left = mpRow.lock();
210210
auto right = aIt.mpRow.lock();

0 commit comments

Comments
 (0)