mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Add implicit cast operators to char & short and their unsigned variants
Fix #179 error: conversion from 'SQLite::Column' to 'unsigned char' is ambiguous
This commit is contained in:
parent
2e69a81ccf
commit
35aaf73191
@ -116,7 +116,7 @@ Version 2.2.0 - Sept 19 2017
|
||||
- Fix warnings #134
|
||||
- Deprecated Statement::IsOk() to Statement::HasRow()
|
||||
|
||||
Version 2.3.0
|
||||
Version 2.3.0 - March 3 2019
|
||||
- Update SQLite3 from 3.20.1 to latest 3.27.2 (2019-02-25) #183 #187
|
||||
- Add Statement binding for long int values #147
|
||||
- Allows long int for bind when used with name #148
|
||||
@ -124,6 +124,7 @@ Version 2.3.0
|
||||
- Add comparison with sqlite_orm #141
|
||||
- Fix Statement::bind truncates long integer to 32 bits on x86_64 Linux #155
|
||||
- Add a move constructor to Database #157
|
||||
- Added tests for all MSVC compilers available on AppVeyor #169
|
||||
- Added tests for all MSVC compilers available on AppVeyor (2013, 2015, 2017) #169
|
||||
- Update VariadicBind.h #172
|
||||
- Better CMake compatibility #170
|
||||
- Add implicit cast operator to char and short types
|
@ -166,6 +166,27 @@ public:
|
||||
return getBytes ();
|
||||
}
|
||||
|
||||
/// Inline cast operator to char
|
||||
inline operator char() const
|
||||
{
|
||||
return static_cast<char>(getInt());
|
||||
}
|
||||
/// Inline cast operator to unsigned char
|
||||
inline operator unsigned char() const
|
||||
{
|
||||
return static_cast<unsigned char>(getInt());
|
||||
}
|
||||
/// Inline cast operator to short
|
||||
inline operator short() const
|
||||
{
|
||||
return static_cast<short>(getInt());
|
||||
}
|
||||
/// Inline cast operator to unsigned short
|
||||
inline operator unsigned short() const
|
||||
{
|
||||
return static_cast<unsigned short>(getInt());
|
||||
}
|
||||
|
||||
/// Inline cast operator to int
|
||||
inline operator int() const
|
||||
{
|
||||
|
@ -57,12 +57,16 @@ TEST(Column, basis) {
|
||||
|
||||
// validates every variant of cast operators, and conversions of types
|
||||
{
|
||||
const sqlite3_int64 id1 = query.getColumn(0); // operator int64_t()
|
||||
const int64_t id2 = query.getColumn(0); // operator int64_t()
|
||||
const long long id3 = query.getColumn(0); // operator int64_t()
|
||||
const long id4 = query.getColumn(0); // operator int64_t() or long() depending on compiler/architecture
|
||||
const unsigned int uint1 = query.getColumn(0); // operator uint32_t()
|
||||
const uint32_t uint2 = query.getColumn(0); // operator uint32_t()
|
||||
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 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()
|
||||
const uint32_t uint2 = query.getColumn(0); // operator unsigned int()
|
||||
const unsigned char uint3 = query.getColumn(0); // operator unsigned char()
|
||||
const unsigned short uint4 = query.getColumn(0); // operator unsigned short()
|
||||
const char* ptxt = query.getColumn(1); // operator const char*()
|
||||
const std::string msg = query.getColumn(1); // operator std::string() (or const char* with MSVC)
|
||||
const int integer = query.getColumn(2); // operator int()
|
||||
@ -78,8 +82,12 @@ TEST(Column, basis) {
|
||||
EXPECT_EQ(1, id2);
|
||||
EXPECT_EQ(1, id3);
|
||||
EXPECT_EQ(1, id4);
|
||||
EXPECT_EQ(1, id5);
|
||||
EXPECT_EQ(1, id6);
|
||||
EXPECT_EQ(1U, uint1);
|
||||
EXPECT_EQ(1U, uint2);
|
||||
EXPECT_EQ(1U, uint3);
|
||||
EXPECT_EQ(1U, uint4);
|
||||
EXPECT_STREQ("first", ptxt);
|
||||
EXPECT_EQ("first", msg);
|
||||
EXPECT_EQ(-123, integer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user