Skip to content

Commit 0bc1d06

Browse files
committed
Improved code reuse.
1 parent 5930530 commit 0bc1d06

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

src/Statement.cpp

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -171,91 +171,67 @@ void Statement::bind(const int aIndex)
171171
// Bind an int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
172172
void Statement::bind(const char* apName, const int aValue)
173173
{
174-
const int index = getIndex(apName);
175-
const int ret = sqlite3_bind_int(mStmtPtr, index, aValue);
176-
check(ret);
174+
bind(getIndex(apName), aValue);
177175
}
178176

179177
// Bind a 32bits unsigned int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
180178
void Statement::bind(const char* apName, const unsigned aValue)
181179
{
182-
const int index = getIndex(apName);
183-
const int ret = sqlite3_bind_int64(mStmtPtr, index, aValue);
184-
check(ret);
180+
bind(getIndex(apName), aValue);
185181
}
186182

187183
// Bind a 64bits int value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
188184
void Statement::bind(const char* apName, const long long aValue)
189185
{
190-
const int index = getIndex(apName);
191-
const int ret = sqlite3_bind_int64(mStmtPtr, index, aValue);
192-
check(ret);
186+
bind(getIndex(apName), aValue);
193187
}
194188

195189
// Bind a double (64bits float) value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
196190
void Statement::bind(const char* apName, const double aValue)
197191
{
198-
const int index = getIndex(apName);
199-
const int ret = sqlite3_bind_double(mStmtPtr, index, aValue);
200-
check(ret);
192+
bind(getIndex(apName), aValue);
201193
}
202194

203195
// Bind a string value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
204196
void Statement::bind(const char* apName, const std::string& aValue)
205197
{
206-
const int index = getIndex(apName);
207-
const int ret = sqlite3_bind_text(mStmtPtr, index, aValue.c_str(),
208-
static_cast<int>(aValue.size()), SQLITE_TRANSIENT);
209-
check(ret);
198+
bind(getIndex(apName), aValue);
210199
}
211200

212201
// Bind a text value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
213202
void Statement::bind(const char* apName, const char* apValue)
214203
{
215-
const int index = getIndex(apName);
216-
const int ret = sqlite3_bind_text(mStmtPtr, index, apValue, -1, SQLITE_TRANSIENT);
217-
check(ret);
204+
bind(getIndex(apName), apValue);
218205
}
219206

220207
// Bind a binary blob value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
221208
void Statement::bind(const char* apName, const void* apValue, const int aSize)
222209
{
223-
const int index = getIndex(apName);
224-
const int ret = sqlite3_bind_blob(mStmtPtr, index, apValue, aSize, SQLITE_TRANSIENT);
225-
check(ret);
210+
bind(getIndex(apName), apValue, aSize);
226211
}
227212

228213
// Bind a string value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
229214
void Statement::bindNoCopy(const char* apName, const std::string& aValue)
230215
{
231-
const int index = getIndex(apName);
232-
const int ret = sqlite3_bind_text(mStmtPtr, index, aValue.c_str(),
233-
static_cast<int>(aValue.size()), SQLITE_STATIC);
234-
check(ret);
216+
bindNoCopy(getIndex(apName), aValue);
235217
}
236218

237219
// Bind a text value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
238220
void Statement::bindNoCopy(const char* apName, const char* apValue)
239221
{
240-
const int index = getIndex(apName);
241-
const int ret = sqlite3_bind_text(mStmtPtr, index, apValue, -1, SQLITE_STATIC);
242-
check(ret);
222+
bindNoCopy(getIndex(apName), apValue);
243223
}
244224

245225
// Bind a binary blob value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
246226
void Statement::bindNoCopy(const char* apName, const void* apValue, const int aSize)
247227
{
248-
const int index = getIndex(apName);
249-
const int ret = sqlite3_bind_blob(mStmtPtr, index, apValue, aSize, SQLITE_STATIC);
250-
check(ret);
228+
bindNoCopy(getIndex(apName), apValue, aSize);
251229
}
252230

253231
// Bind a NULL value to a parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
254232
void Statement::bind(const char* apName)
255233
{
256-
const int index = getIndex(apName);
257-
const int ret = sqlite3_bind_null(mStmtPtr, index);
258-
check(ret);
234+
bind(getIndex(apName));
259235
}
260236

261237

0 commit comments

Comments
 (0)