Skip to content

Commit 7a8ac4e

Browse files
committed
Switch from sqlite3_int64 to int64_t
1 parent a2abbf1 commit 7a8ac4e

File tree

11 files changed

+91
-90
lines changed

11 files changed

+91
-90
lines changed

.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<projects>
66
</projects>
77
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
813
<buildCommand>
914
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
1015
<triggers>clean,full,incremental,</triggers>
@@ -75,5 +80,6 @@
7580
<nature>org.eclipse.cdt.core.ccnature</nature>
7681
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
7782
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
83+
<nature>org.python.pydev.pythonNature</nature>
7884
</natures>
7985
</projectDescription>

cpplint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4499,7 +4499,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
44994499
template = required[required_header_unstripped][1]
45004500
if required_header_unstripped.strip('<>"') not in include_state:
45014501
error(filename, required[required_header_unstripped][0],
4502-
'build/include_what_you_use', 4,
4502+
'build/include_what_you_use', 2,
45034503
'Add #include ' + required_header_unstripped + ' for ' + template)
45044504

45054505

include/SQLiteCpp/Column.h

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <SQLiteCpp/Exception.h>
1717

1818
#include <string>
19+
#include <stdint.h>
1920

2021

2122
namespace SQLite
@@ -41,32 +42,32 @@ namespace SQLite
4142
class Column
4243
{
4344
public:
44-
// Make clang happy by explicitly implementing the copy-constructor:
45-
Column(const Column & aOther) :
46-
mStmtPtr(aOther.mStmtPtr),
47-
mIndex(aOther.mIndex)
48-
{
49-
}
50-
5145
/**
5246
* @brief Encapsulation of a Column in a Row of the result.
5347
*
5448
* @param[in] aStmtPtr Shared pointer to the prepared SQLite Statement Object.
5549
* @param[in] aIndex Index of the column in the row of result
5650
*/
5751
Column(Statement::Ptr& aStmtPtr, int aIndex) noexcept; // nothrow
58-
/// @brief Simple destructor
52+
/// Simple destructor
5953
virtual ~Column() noexcept; // nothrow
6054

6155
// default copy constructor and assignment operator are perfectly suited :
6256
// they copy the Statement::Ptr which in turn increments the reference counter.
6357

58+
/// Make clang happy by explicitly implementing the copy-constructor:
59+
Column(const Column & aOther) :
60+
mStmtPtr(aOther.mStmtPtr),
61+
mIndex(aOther.mIndex)
62+
{
63+
}
64+
6465
/**
6566
* @brief Return a pointer to the named assigned to this result column (potentially aliased)
6667
*
6768
* @see getOriginName() to get original column name (not aliased)
6869
*/
69-
const char* getName() const noexcept; // nothrow
70+
const char* getName() const noexcept; // nothrow
7071

7172
#ifdef SQLITE_ENABLE_COLUMN_METADATA
7273
/**
@@ -76,36 +77,36 @@ class Column
7677
* - when building the SQLite library itself (which is the case for the Debian libsqlite3 binary for instance),
7778
* - and also when compiling this wrapper.
7879
*/
79-
const char* getOriginName() const noexcept; // nothrow
80+
const char* getOriginName() const noexcept; // nothrow
8081
#endif
8182

82-
/// @brief Return the integer value of the column.
83-
int getInt() const noexcept; // nothrow
84-
/// @brief Return the 64bits integer value of the column.
85-
sqlite3_int64 getInt64() const noexcept; // nothrow
86-
/// @brief Return the double (64bits float) value of the column.
87-
double getDouble() const noexcept; // nothrow
83+
/// Return the integer value of the column.
84+
int getInt() const noexcept; // nothrow
85+
/// Return the 64bits integer value of the column.
86+
int64_t getInt64() const noexcept; // nothrow
87+
/// Return the double (64bits float) value of the column.
88+
double getDouble() const noexcept; // nothrow
8889
/**
8990
* @brief Return a pointer to the text value (NULL terminated string) of the column.
9091
*
9192
* @warning The value pointed at is only valid while the statement is valid (ie. not finalized),
9293
* thus you must copy it before using it beyond its scope (to a std::string for instance).
9394
*/
94-
const char* getText(const char* apDefaultValue = "") const noexcept; // nothrow
95+
const char* getText(const char* apDefaultValue = "") const noexcept; // nothrow
9596
/**
9697
* @brief Return a pointer to the binary blob value of the column.
9798
*
9899
* @warning The value pointed at is only valid while the statement is valid (ie. not finalized),
99100
* thus you must copy it before using it beyond its scope (to a std::string for instance).
100101
*/
101-
const void* getBlob() const noexcept; // nothrow
102+
const void* getBlob() const noexcept; // nothrow
102103
/**
103104
* @brief Return a std::string for a TEXT or BLOB column.
104105
*
105106
* Note this correctly handles strings that contain null bytes.
106107
*
107108
*/
108-
std::string getString() const noexcept; // nothrow
109+
std::string getString() const noexcept; // nothrow
109110

110111
/**
111112
* @brief Return the type of the value of the column
@@ -117,27 +118,27 @@ class Column
117118
*/
118119
int getType() const noexcept; // nothrow
119120

120-
/// @brief Test if the column is an integer type value (meaningful only before any conversion)
121+
/// Test if the column is an integer type value (meaningful only before any conversion)
121122
inline bool isInteger() const noexcept // nothrow
122123
{
123124
return (SQLITE_INTEGER == getType());
124125
}
125-
/// @brief Test if the column is a floating point type value (meaningful only before any conversion)
126+
/// Test if the column is a floating point type value (meaningful only before any conversion)
126127
inline bool isFloat() const noexcept // nothrow
127128
{
128129
return (SQLITE_FLOAT == getType());
129130
}
130-
/// @brief Test if the column is a text type value (meaningful only before any conversion)
131+
/// Test if the column is a text type value (meaningful only before any conversion)
131132
inline bool isText() const noexcept // nothrow
132133
{
133134
return (SQLITE_TEXT == getType());
134135
}
135-
/// @brief Test if the column is a binary blob type value (meaningful only before any conversion)
136+
/// Test if the column is a binary blob type value (meaningful only before any conversion)
136137
inline bool isBlob() const noexcept // nothrow
137138
{
138139
return (SQLITE_BLOB == getType());
139140
}
140-
/// @brief Test if the column is NULL (meaningful only before any conversion)
141+
/// Test if the column is NULL (meaningful only before any conversion)
141142
inline bool isNull() const noexcept // nothrow
142143
{
143144
return (SQLITE_NULL == getType());
@@ -154,28 +155,42 @@ class Column
154155
*/
155156
int getBytes() const noexcept;
156157

157-
/// @brief Alias returning the number of bytes used by the text (or blob) value of the column
158+
/// Alias returning the number of bytes used by the text (or blob) value of the column
158159
inline int size() const noexcept
159160
{
160161
return getBytes ();
161162
}
162163

163-
/// @brief Inline cast operator to int
164+
/// Inline cast operator to int
164165
inline operator int() const
165166
{
166167
return getInt();
167168
}
168-
/// @brief Inline cast operator to 32bits unsigned integer
169-
inline operator uint32_t() const
169+
#ifndef __x86_64__
170+
/// Inline cast operator to long as 32bits integer for 32bit systems
171+
inline operator long() const
170172
{
171-
return static_cast<uint32_t>(getInt64());
173+
return getInt();
174+
}
175+
#endif // __x86_64__
176+
#if defined(__GNUC__) && !defined(__APPLE__)
177+
/// Inline cast operator to long long for GCC and Clang
178+
inline operator long long() const
179+
{
180+
return getInt64();
172181
}
173-
/// @brief Inline cast operator to 64bits integer
174-
inline operator sqlite3_int64() const
182+
#endif // __GNUC__
183+
/// Inline cast operator to 64bits integer
184+
inline operator int64_t() const
175185
{
176186
return getInt64();
177187
}
178-
/// @brief Inline cast operator to double
188+
/// Inline cast operator to 32bits unsigned integer
189+
inline operator uint32_t() const
190+
{
191+
return static_cast<uint32_t>(getInt64());
192+
}
193+
/// Inline cast operator to double
179194
inline operator double() const
180195
{
181196
return getDouble();
@@ -218,18 +233,7 @@ class Column
218233
}
219234
#endif
220235

221-
// NOTE : the following is required by GCC and Clang to cast a Column result in a long/int64_t
222-
/// @brief Inline cast operator to long as 64bits integer
223-
inline operator long() const
224-
{
225-
#ifdef __x86_64__
226-
return getInt64();
227-
#else
228-
return getInt();
229-
#endif
230-
}
231-
232-
/// @brief Return UTF-8 encoded English language explanation of the most recent error.
236+
/// Return UTF-8 encoded English language explanation of the most recent error.
233237
inline const char* errmsg() const
234238
{
235239
return sqlite3_errmsg(mStmtPtr);

include/SQLiteCpp/Database.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class Database
237237
*
238238
* @return Rowid of the most recent successful INSERT into the database, or 0 if there was none.
239239
*/
240-
inline sqlite3_int64 getLastInsertRowid() const noexcept // nothrow
240+
inline int64_t getLastInsertRowid() const noexcept // nothrow
241241
{
242242
return sqlite3_last_insert_rowid(mpSQLite);
243243
}
@@ -252,25 +252,25 @@ class Database
252252
return sqlite3_total_changes(mpSQLite);
253253
}
254254

255-
/// @brief Return the filename used to open the database.
255+
/// Return the filename used to open the database.
256256
inline const std::string& getFilename() const noexcept // nothrow
257257
{
258258
return mFilename;
259259
}
260260

261-
/// @brief Return the numeric result code for the most recent failed API call (if any).
261+
/// Return the numeric result code for the most recent failed API call (if any).
262262
inline int getErrorCode() const noexcept // nothrow
263263
{
264264
return sqlite3_errcode(mpSQLite);
265265
}
266266

267-
/// @brief Return the extended numeric result code for the most recent failed API call (if any).
267+
/// Return the extended numeric result code for the most recent failed API call (if any).
268268
inline int getExtendedErrorCode() const noexcept // nothrow
269269
{
270270
return sqlite3_extended_errcode(mpSQLite);
271271
}
272272

273-
/// @brief Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
273+
/// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
274274
inline const char* errmsg() const noexcept // nothrow
275275
{
276276
return sqlite3_errmsg(mpSQLite);

include/SQLiteCpp/Statement.h

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ class Statement
6868
*/
6969
Statement(Database& aDatabase, const std::string& aQuery);
7070

71-
/**
72-
* @brief Finalize and unregister the SQL query from the SQLite Database Connection.
73-
*/
71+
/// Finalize and unregister the SQL query from the SQLite Database Connection.
7472
virtual ~Statement() noexcept; // nothrow
7573

76-
/**
77-
* @brief Reset the statement to make it ready for a new execution.
78-
*/
74+
/// Reset the statement to make it ready for a new execution.
7975
void reset();
8076

8177
/**
@@ -110,7 +106,7 @@ class Statement
110106
/**
111107
* @brief Bind a 64bits int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
112108
*/
113-
void bind(const int aIndex, const sqlite3_int64 aValue);
109+
void bind(const int aIndex, const int64_t aValue);
114110
/**
115111
* @brief Bind a 32bits unsigned int value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
116112
*/
@@ -169,7 +165,7 @@ class Statement
169165
/**
170166
* @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
171167
*/
172-
void bind(const char* apName, const sqlite3_int64 aValue);
168+
void bind(const char* apName, const int64_t aValue);
173169
/**
174170
* @brief Bind a 32bits unsigned int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
175171
*/
@@ -232,7 +228,7 @@ class Statement
232228
/**
233229
* @brief Bind a 64bits int value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
234230
*/
235-
inline void bind(const std::string& aName, const sqlite3_int64 aValue)
231+
inline void bind(const std::string& aName, const int64_t aValue)
236232
{
237233
bind(aName.c_str(), aValue);
238234
}
@@ -314,7 +310,6 @@ class Statement
314310
bind(aName.c_str());
315311
}
316312

317-
318313
////////////////////////////////////////////////////////////////////////////
319314

320315
/**
@@ -449,32 +444,32 @@ class Statement
449444

450445
////////////////////////////////////////////////////////////////////////////
451446

452-
/// @brief Return the UTF-8 SQL Query.
447+
/// Return the UTF-8 SQL Query.
453448
inline const std::string& getQuery() const
454449
{
455450
return mQuery;
456451
}
457-
/// @brief Return the number of columns in the result set returned by the prepared statement
452+
/// Return the number of columns in the result set returned by the prepared statement
458453
inline int getColumnCount() const
459454
{
460455
return mColumnCount;
461456
}
462-
/// @brief true when a row has been fetched with executeStep()
457+
/// true when a row has been fetched with executeStep()
463458
inline bool isOk() const
464459
{
465460
return mbOk;
466461
}
467-
/// @brief true when the last executeStep() had no more row to fetch
462+
/// true when the last executeStep() had no more row to fetch
468463
inline bool isDone() const
469464
{
470465
return mbDone;
471466
}
472-
/// @brief Return the numeric result code for the most recent failed API call (if any).
467+
/// Return the numeric result code for the most recent failed API call (if any).
473468
inline int getErrorCode() const noexcept // nothrow
474469
{
475470
return sqlite3_errcode(mStmtPtr);
476471
}
477-
/// @brief Return the extended numeric result code for the most recent failed API call (if any).
472+
/// Return the extended numeric result code for the most recent failed API call (if any).
478473
inline int getExtendedErrorCode() const noexcept // nothrow
479474
{
480475
return sqlite3_extended_errcode(mStmtPtr);
@@ -503,13 +498,13 @@ class Statement
503498
// Decrement the ref counter and finalize the sqlite3_stmt when it reaches 0
504499
~Ptr() noexcept; // nothrow (no virtual destructor needed here)
505500

506-
/// @brief Inline cast operator returning the pointer to SQLite Database Connection Handle
501+
/// Inline cast operator returning the pointer to SQLite Database Connection Handle
507502
inline operator sqlite3*() const
508503
{
509504
return mpSQLite;
510505
}
511506

512-
/// @brief Inline cast operator returning the pointer to SQLite Statement Object
507+
/// Inline cast operator returning the pointer to SQLite Statement Object
513508
inline operator sqlite3_stmt*() const
514509
{
515510
return mpStmt;

src/Backup.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
#include <sqlite3.h>
1717

18-
#include <string>
19-
2018
namespace SQLite
2119
{
2220

0 commit comments

Comments
 (0)