Skip to content

Commit

Permalink
Removal of removing long APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
SRombauts committed Jul 24, 2022
1 parent c5ac06d commit 45220b7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 34 deletions.
2 changes: 1 addition & 1 deletion include/SQLiteCpp/Assertion.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace SQLite
{
// declaration of the assert handler to define in user code
void assertion_failed(const char* apFile, const long apLine, const char* apFunc,
void assertion_failed(const char* apFile, const int apLine, const char* apFunc,
const char* apExpr, const char* apMsg);

#ifdef _MSC_VER
Expand Down
28 changes: 4 additions & 24 deletions include/SQLiteCpp/Column.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <string>
#include <memory>
#include <climits> // For INT_MAX

// Forward declarations to avoid inclusion of <sqlite3.h> in a header
struct sqlite3_stmt;
Expand Down Expand Up @@ -79,11 +78,11 @@ class Column
#endif

/// Return the integer value of the column.
int getInt() const noexcept;
int32_t getInt() const noexcept;
/// Return the 32bits unsigned integer value of the column (note that SQLite3 does not support unsigned 64bits).
unsigned getUInt() const noexcept;
uint32_t getUInt() const noexcept;
/// Return the 64bits integer value of the column (note that SQLite3 does not support unsigned 64bits).
long long getInt64() const noexcept;
int64_t getInt64() const noexcept;
/// Return the double (64bits float) value of the column
double getDouble() const noexcept;
/**
Expand Down Expand Up @@ -191,27 +190,8 @@ class Column
{
return getUInt();
}
#if (LONG_MAX == INT_MAX) // 4 bytes "long" type means the data model is ILP32 or LLP64 (Win64 Visual C++ and MinGW)
/// Inline cast operator to 32bits long
operator long() const
{
return getInt();
}
/// Inline cast operator to 32bits unsigned long
operator unsigned long() const
{
return getUInt();
}
#else // 8 bytes "long" type means the data model is LP64 (Most Unix-like, Windows when using Cygwin; z/OS)
/// Inline cast operator to 64bits long when the data model of the system is LP64 (Linux 64 bits...)
operator long() const
{
return getInt64();
}
#endif

/// Inline cast operator to 64bits integer
operator long long() const
operator int64_t() const
{
return getInt64();
}
Expand Down
2 changes: 1 addition & 1 deletion include/SQLiteCpp/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class Database
*
* @return Rowid of the most recent successful INSERT into the database, or 0 if there was none.
*/
long long getLastInsertRowid() const noexcept;
int64_t getLastInsertRowid() const noexcept;

/// Get number of rows modified by last INSERT, UPDATE or DELETE statement (not DROP table).
int getChanges() const noexcept;
Expand Down
6 changes: 3 additions & 3 deletions src/Column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ const char* Column::getOriginName() const noexcept
#endif

// Return the integer value of the column specified by its index starting at 0
int Column::getInt() const noexcept
int32_t Column::getInt() const noexcept
{
return sqlite3_column_int(mStmtPtr.get(), mIndex);
}

// Return the unsigned integer value of the column specified by its index starting at 0
unsigned Column::getUInt() const noexcept
uint32_t Column::getUInt() const noexcept
{
return static_cast<unsigned>(getInt64());
}

// Return the 64bits integer value of the column specified by its index starting at 0
long long Column::getInt64() const noexcept
int64_t Column::getInt64() const noexcept
{
return sqlite3_column_int64(mStmtPtr.get(), mIndex);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool Database::tableExists(const char* apTableName)
}

// Get the rowid of the most recent successful INSERT into the database from the current connection.
long long Database::getLastInsertRowid() const noexcept
int64_t Database::getLastInsertRowid() const noexcept
{
return sqlite3_last_insert_rowid(getHandle());
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Column_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ TEST(Column, basis)

// validates every variant of cast operators, and conversions of types
{
const sqlite3_int64 id1 = query.getColumn(0); // operator long long()
const int64_t id2 = query.getColumn(0); // operator long long()
const long long id3 = query.getColumn(0); // operator long long()
const long id4 = query.getColumn(0); // operator long long() or long() depending on compiler/architecture
const sqlite3_int64 id1 = query.getColumn(0); // operator int64_t()
const int64_t id2 = query.getColumn(0); // operator int64_t()
const int64_t id3 = query.getColumn(0); // operator int64_t()
const long id4 = query.getColumn(0); // operator int64_t() or long() depending on compiler/architecture
const char id5 = query.getColumn(0); // operator char()
const short id6 = query.getColumn(0); // operator short()
const unsigned int uint1 = query.getColumn(0); // operator unsigned int()
Expand Down

0 comments on commit 45220b7

Please sign in to comment.