Skip to content

Commit edf49ee

Browse files
committed
Long size checks replaced with fixed width ints
1 parent ce6dd9b commit edf49ee

File tree

2 files changed

+14
-70
lines changed

2 files changed

+14
-70
lines changed

include/SQLiteCpp/Statement.h

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include <string>
1717
#include <map>
18-
#include <climits> // For INT_MAX
1918

2019
// Forward declarations to avoid inclusion of <sqlite3.h> in a header
2120
struct sqlite3;
@@ -128,34 +127,15 @@ class Statement
128127
/**
129128
* @brief Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
130129
*/
131-
void bind(const int aIndex, const int aValue);
130+
void bind(const int aIndex, const int32_t aValue);
132131
/**
133132
* @brief Bind a 32bits unsigned int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
134133
*/
135-
void bind(const int aIndex, const unsigned aValue);
136-
137-
#if (LONG_MAX == INT_MAX) // 4 bytes "long" type means the data model is ILP32 or LLP64 (Win64 Visual C++ and MinGW)
138-
/**
139-
* @brief Bind a 32bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
140-
*/
141-
void bind(const int aIndex, const long aValue)
142-
{
143-
bind(aIndex, static_cast<int>(aValue));
144-
}
145-
#else // 8 bytes "long" type means the data model is LP64 (Most Unix-like, Windows when using Cygwin; z/OS)
146-
/**
147-
* @brief Bind a 64bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
148-
*/
149-
void bind(const int aIndex, const long aValue)
150-
{
151-
bind(aIndex, static_cast<long long>(aValue));
152-
}
153-
#endif
154-
134+
void bind(const int aIndex, const uint32_t aValue);
155135
/**
156136
* @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
157137
*/
158-
void bind(const int aIndex, const long long aValue);
138+
void bind(const int aIndex, const int64_t aValue);
159139
/**
160140
* @brief Bind a double (64bits float) value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
161141
*/
@@ -210,39 +190,21 @@ class Statement
210190
/**
211191
* @brief Bind an int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
212192
*/
213-
void bind(const char* apName, const int aValue)
193+
void bind(const char* apName, const int32_t aValue)
214194
{
215195
bind(getIndex(apName), aValue);
216196
}
217197
/**
218198
* @brief Bind a 32bits unsigned int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
219199
*/
220-
void bind(const char* apName, const unsigned aValue)
200+
void bind(const char* apName, const uint32_t aValue)
221201
{
222202
bind(getIndex(apName), aValue);
223203
}
224-
225-
#if (LONG_MAX == INT_MAX) // 4 bytes "long" type means the data model is ILP32 or LLP64 (Win64 Visual C++ and MinGW)
226-
/**
227-
* @brief Bind a 32bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
228-
*/
229-
void bind(const char* apName, const long aValue)
230-
{
231-
bind(apName, static_cast<int>(aValue));
232-
}
233-
#else // 8 bytes "long" type means the data model is LP64 (Most Unix-like, Windows when using Cygwin; z/OS)
234-
/**
235-
* @brief Bind a 64bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
236-
*/
237-
void bind(const char* apName, const long aValue)
238-
{
239-
bind(apName, static_cast<long long>(aValue));
240-
}
241-
#endif
242204
/**
243205
* @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
244206
*/
245-
void bind(const char* apName, const long long aValue)
207+
void bind(const char* apName, const int64_t aValue)
246208
{
247209
bind(getIndex(apName), aValue);
248210
}
@@ -325,46 +287,28 @@ class Statement
325287
/**
326288
* @brief Bind an int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
327289
*/
328-
void bind(const std::string& aName, const int aValue)
290+
void bind(const std::string& aName, const int32_t aValue)
329291
{
330292
bind(aName.c_str(), aValue);
331293
}
332294
/**
333295
* @brief Bind a 32bits unsigned int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
334296
*/
335-
void bind(const std::string& aName, const unsigned aValue)
297+
void bind(const std::string& aName, const uint32_t aValue)
336298
{
337299
bind(aName.c_str(), aValue);
338300
}
339-
340-
#if (LONG_MAX == INT_MAX) // 4 bytes "long" type means the data model is ILP32 or LLP64 (Win64 Visual C++ and MinGW)
341-
/**
342-
* @brief Bind a 32bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
343-
*/
344-
void bind(const std::string& aName, const long aValue)
345-
{
346-
bind(aName.c_str(), static_cast<int>(aValue));
347-
}
348-
#else // 8 bytes "long" type means the data model is LP64 (Most Unix-like, Windows when using Cygwin; z/OS)
349-
/**
350-
* @brief Bind a 64bits long value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
351-
*/
352-
void bind(const std::string& aName, const long aValue)
353-
{
354-
bind(aName.c_str(), static_cast<long long>(aValue));
355-
}
356-
#endif
357301
/**
358302
* @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
359303
*/
360-
void bind(const std::string& aName, const long long aValue)
304+
void bind(const std::string& aName, const int64_t aValue)
361305
{
362306
bind(aName.c_str(), aValue);
363307
}
364308
/**
365309
* @brief Bind a double (64bits float) value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
366310
*/
367-
void bind(const std::string& aName, const double aValue)
311+
void bind(const std::string& aName, const double aValue)
368312
{
369313
bind(aName.c_str(), aValue);
370314
}

src/Statement.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ int Statement::getIndex(const char * const apName)
6868
return sqlite3_bind_parameter_index(mStmtPtr, apName);
6969
}
7070

71-
// Bind an int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
72-
void Statement::bind(const int aIndex, const int aValue)
71+
// Bind an 32bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
72+
void Statement::bind(const int aIndex, const int32_t aValue)
7373
{
7474
const int ret = sqlite3_bind_int(mStmtPtr, aIndex, aValue);
7575
check(ret);
7676
}
7777

7878
// Bind a 32bits unsigned int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
79-
void Statement::bind(const int aIndex, const unsigned aValue)
79+
void Statement::bind(const int aIndex, const uint32_t aValue)
8080
{
8181
const int ret = sqlite3_bind_int64(mStmtPtr, aIndex, aValue);
8282
check(ret);
8383
}
8484

8585
// Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement
86-
void Statement::bind(const int aIndex, const long long aValue)
86+
void Statement::bind(const int aIndex, const int64_t aValue)
8787
{
8888
const int ret = sqlite3_bind_int64(mStmtPtr, aIndex, aValue);
8989
check(ret);

0 commit comments

Comments
 (0)