mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-06 10:46:03 -04:00
Removal of removing long APIs
This commit is contained in:
parent
c5ac06dfba
commit
3d149cc62f
@ -26,7 +26,7 @@
|
|||||||
namespace SQLite
|
namespace SQLite
|
||||||
{
|
{
|
||||||
// declaration of the assert handler to define in user code
|
// 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);
|
const char* apExpr, const char* apMsg);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <climits> // For INT_MAX
|
|
||||||
|
|
||||||
// Forward declarations to avoid inclusion of <sqlite3.h> in a header
|
// Forward declarations to avoid inclusion of <sqlite3.h> in a header
|
||||||
struct sqlite3_stmt;
|
struct sqlite3_stmt;
|
||||||
@ -79,11 +78,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Return the integer value of the column.
|
/// 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).
|
/// 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).
|
/// 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
|
/// Return the double (64bits float) value of the column
|
||||||
double getDouble() const noexcept;
|
double getDouble() const noexcept;
|
||||||
/**
|
/**
|
||||||
@ -160,62 +159,39 @@ public:
|
|||||||
return getBytes ();
|
return getBytes ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inline cast operator to char
|
/// Inline cast operators to basic types
|
||||||
operator char() const
|
operator char() const
|
||||||
{
|
{
|
||||||
return static_cast<char>(getInt());
|
return static_cast<char>(getInt());
|
||||||
}
|
}
|
||||||
/// Inline cast operator to unsigned char
|
operator int8_t() const
|
||||||
operator unsigned char() const
|
|
||||||
{
|
{
|
||||||
return static_cast<unsigned char>(getInt());
|
return static_cast<int8_t>(getInt());
|
||||||
}
|
}
|
||||||
/// Inline cast operator to short
|
operator uint8_t() const
|
||||||
operator short() const
|
|
||||||
{
|
{
|
||||||
return static_cast<short>(getInt());
|
return static_cast<uint8_t>(getInt());
|
||||||
}
|
}
|
||||||
/// Inline cast operator to unsigned short
|
operator int16_t() const
|
||||||
operator unsigned short() const
|
|
||||||
{
|
{
|
||||||
return static_cast<unsigned short>(getInt());
|
return static_cast<int16_t>(getInt());
|
||||||
}
|
}
|
||||||
|
operator uint16_t() const
|
||||||
/// Inline cast operator to int
|
{
|
||||||
operator int() const
|
return static_cast<uint16_t>(getInt());
|
||||||
|
}
|
||||||
|
operator int32_t() const
|
||||||
{
|
{
|
||||||
return getInt();
|
return getInt();
|
||||||
}
|
}
|
||||||
/// Inline cast operator to 32bits unsigned integer
|
operator uint32_t() const
|
||||||
operator unsigned int() const
|
|
||||||
{
|
{
|
||||||
return getUInt();
|
return getUInt();
|
||||||
}
|
}
|
||||||
#if (LONG_MAX == INT_MAX) // 4 bytes "long" type means the data model is ILP32 or LLP64 (Win64 Visual C++ and MinGW)
|
operator int64_t() const
|
||||||
/// 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();
|
return getInt64();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Inline cast operator to 64bits integer
|
|
||||||
operator long long() const
|
|
||||||
{
|
|
||||||
return getInt64();
|
|
||||||
}
|
|
||||||
/// Inline cast operator to double
|
|
||||||
operator double() const
|
operator double() const
|
||||||
{
|
{
|
||||||
return getDouble();
|
return getDouble();
|
||||||
|
@ -429,7 +429,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return Rowid of the most recent successful INSERT into the database, or 0 if there was none.
|
* @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).
|
/// Get number of rows modified by last INSERT, UPDATE or DELETE statement (not DROP table).
|
||||||
int getChanges() const noexcept;
|
int getChanges() const noexcept;
|
||||||
|
@ -51,19 +51,19 @@ const char* Column::getOriginName() const noexcept
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Return the integer value of the column specified by its index starting at 0
|
// 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 sqlite3_column_int(mStmtPtr.get(), mIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the unsigned integer value of the column specified by its index starting at 0
|
// 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 static_cast<unsigned>(getInt64());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the 64bits integer value of the column specified by its index starting at 0
|
// 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);
|
return sqlite3_column_int64(mStmtPtr.get(), mIndex);
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// 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());
|
return sqlite3_last_insert_rowid(getHandle());
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
#include <SQLiteCpp/Statement.h>
|
#include <SQLiteCpp/Statement.h>
|
||||||
#include <SQLiteCpp/Column.h>
|
#include <SQLiteCpp/Column.h>
|
||||||
|
|
||||||
#include <sqlite3.h> // for sqlite3_int64
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -59,12 +57,13 @@ TEST(Column, basis)
|
|||||||
|
|
||||||
// validates every variant of cast operators, and conversions of types
|
// validates every variant of cast operators, and conversions of types
|
||||||
{
|
{
|
||||||
const sqlite3_int64 id1 = query.getColumn(0); // operator long long()
|
const int64_t id1 = query.getColumn(0); // operator int64_t()
|
||||||
const int64_t id2 = query.getColumn(0); // operator long long()
|
const int32_t id2 = query.getColumn(0); // operator int32_t()
|
||||||
const long long id3 = query.getColumn(0); // operator long long()
|
const int id3 = query.getColumn(0); // operator int32_t()
|
||||||
const long id4 = query.getColumn(0); // operator long long() or long() depending on compiler/architecture
|
const int16_t id4 = query.getColumn(0); // operator int32_t()
|
||||||
const char id5 = query.getColumn(0); // operator char()
|
const short id5 = query.getColumn(0); // operator int32_t()
|
||||||
const short id6 = query.getColumn(0); // operator short()
|
const int8_t id6 = query.getColumn(0); // operator int32_t()
|
||||||
|
const char id7 = query.getColumn(0); // operator int32_t()
|
||||||
const unsigned int uint1 = query.getColumn(0); // operator unsigned int()
|
const unsigned int uint1 = query.getColumn(0); // operator unsigned int()
|
||||||
const uint32_t uint2 = query.getColumn(0); // operator unsigned int()
|
const uint32_t uint2 = query.getColumn(0); // operator unsigned int()
|
||||||
const unsigned char uint3 = query.getColumn(0); // operator unsigned char()
|
const unsigned char uint3 = query.getColumn(0); // operator unsigned char()
|
||||||
@ -83,9 +82,6 @@ TEST(Column, basis)
|
|||||||
EXPECT_EQ(1, id1);
|
EXPECT_EQ(1, id1);
|
||||||
EXPECT_EQ(1, id2);
|
EXPECT_EQ(1, id2);
|
||||||
EXPECT_EQ(1, id3);
|
EXPECT_EQ(1, id3);
|
||||||
EXPECT_EQ(1, id4);
|
|
||||||
EXPECT_EQ(1, id5);
|
|
||||||
EXPECT_EQ(1, id6);
|
|
||||||
EXPECT_EQ(1U, uint1);
|
EXPECT_EQ(1U, uint1);
|
||||||
EXPECT_EQ(1U, uint2);
|
EXPECT_EQ(1U, uint2);
|
||||||
EXPECT_EQ(1U, uint3);
|
EXPECT_EQ(1U, uint3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user