mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-22 20:57:12 +01:00
Cleanup SQLite code.
This commit is contained in:
parent
8ea13de743
commit
05990afedf
@ -21,6 +21,10 @@ SQMODE_DECL_TYPENAME(SQLiteColumnTypename, _SC("SQLiteColumn"))
|
||||
SQMODE_DECL_TYPENAME(SQLiteStatementTypename, _SC("SQLiteStatement"))
|
||||
SQMODE_DECL_TYPENAME(SQLiteTransactionTypename, _SC("SQLiteTransaction"))
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Helper class that represents an integral enumeration value. Used to reduce compilation times.
|
||||
*/
|
||||
@ -367,6 +371,7 @@ static const SEnumElement g_MainEnum[] = {
|
||||
{_SC("WARNING"), SQLITE_WARNING},
|
||||
{_SC("WARNING_AUTOINDEX"), SQLITE_WARNING_AUTOINDEX}
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static inline bool IsDigitsOnly(CSStr str)
|
||||
@ -2864,9 +2869,9 @@ void Register_SQLite(HSQUIRRELVM vm)
|
||||
{
|
||||
Enumeration e(vm);
|
||||
|
||||
for (Uint32 n = 0; n < (sizeof(g_MainEnum) / sizeof(EnumElement)); ++n)
|
||||
for (auto n : g_MainEnum)
|
||||
{
|
||||
e.Const(g_MainEnum[n].Name, g_MainEnum[n].Value);
|
||||
e.Const(n.Name, n.Value);
|
||||
}
|
||||
|
||||
ConstTable(vm).Enum(_SC("SQLiteOpt"), e);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "Library/Chrono/Timestamp.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
@ -86,11 +87,6 @@ Object GetConnectionObj(const ConnRef & conn);
|
||||
*/
|
||||
Object GetStatementObj(const StmtRef & stmt);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Generate a formatted query.
|
||||
*/
|
||||
CSStr QFmtStr(CSStr str, ...);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Tests if a certain query string is empty.
|
||||
*/
|
||||
@ -153,11 +149,11 @@ public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type* Pointer; // Pointer to the managed type.
|
||||
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
||||
typedef const Type* SQ_UNUSED_TYPEDEF(ConstPtr); // Constant pointer to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type& Reference; // Reference to the managed type.
|
||||
typedef const Type& ConstRef; // Constant reference to the managed type.
|
||||
typedef const Type& SQ_UNUSED_TYPEDEF(ConstRef); // Constant reference to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef std::vector< String > QueryList; // Container used to queue queries.
|
||||
@ -268,11 +264,11 @@ public:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type* Pointer; // Pointer to the managed type.
|
||||
typedef const Type* ConstPtr; // Constant pointer to the managed type.
|
||||
typedef const Type* SQ_UNUSED_TYPEDEF(ConstPtr); // Constant pointer to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef Type& Reference; // Reference to the managed type.
|
||||
typedef const Type& ConstRef; // Constant reference to the managed type.
|
||||
typedef const Type& SQ_UNUSED_TYPEDEF(ConstRef); // Constant reference to the managed type.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
typedef std::map< String, int > Indexes; // Container used to identify column indexes.
|
||||
@ -303,7 +299,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
StmtHnd(ConnRef conn);
|
||||
explicit StmtHnd(ConnRef conn);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
@ -947,8 +943,8 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* No parameter constructor.
|
||||
*/
|
||||
Parameter(const StmtRef & stmt)
|
||||
: m_Index(0), m_Handle(stmt)
|
||||
explicit Parameter(StmtRef stmt)
|
||||
: m_Index(0), m_Handle(std::move(stmt))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
@ -956,8 +952,8 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Index constructor.
|
||||
*/
|
||||
Parameter(const StmtRef & stmt, Int32 idx)
|
||||
: m_Index(idx), m_Handle(stmt)
|
||||
Parameter(StmtRef stmt, Int32 idx)
|
||||
: m_Index(idx), m_Handle(std::move(stmt))
|
||||
{
|
||||
SQMOD_VALIDATE_PARAM(*this, m_Index);
|
||||
}
|
||||
@ -974,8 +970,8 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Dynamic constructor.
|
||||
*/
|
||||
Parameter(const StmtRef & stmt, const Object & param)
|
||||
: m_Index(0), m_Handle(stmt)
|
||||
Parameter(StmtRef stmt, const Object & param)
|
||||
: m_Index(0), m_Handle(std::move(stmt))
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
@ -1024,7 +1020,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit conversion to boolean for use in boolean operations.
|
||||
*/
|
||||
operator bool () const
|
||||
operator bool () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||
{
|
||||
return m_Index >= 0;
|
||||
}
|
||||
@ -1355,8 +1351,8 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* No column constructor.
|
||||
*/
|
||||
Column(const StmtRef & stmt)
|
||||
: m_Index(-1), m_Handle(stmt)
|
||||
explicit Column(StmtRef stmt)
|
||||
: m_Index(-1), m_Handle(std::move(stmt))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
@ -1364,8 +1360,8 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Index constructor.
|
||||
*/
|
||||
Column(const StmtRef & stmt, Int32 idx)
|
||||
: m_Index(idx), m_Handle(stmt)
|
||||
Column(StmtRef stmt, Int32 idx)
|
||||
: m_Index(idx), m_Handle(std::move(stmt))
|
||||
{
|
||||
SQMOD_VALIDATE_COLUMN(*this, m_Index);
|
||||
}
|
||||
@ -1382,8 +1378,8 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Dynamic constructor.
|
||||
*/
|
||||
Column(const StmtRef & stmt, const Object & column)
|
||||
: m_Index(-1), m_Handle(stmt)
|
||||
Column(StmtRef stmt, const Object & column)
|
||||
: m_Index(-1), m_Handle(std::move(stmt))
|
||||
{
|
||||
if (!m_Handle)
|
||||
{
|
||||
@ -1432,7 +1428,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit conversion to boolean for use in boolean operations.
|
||||
*/
|
||||
operator bool () const
|
||||
operator bool () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||
{
|
||||
return m_Index >= 0;
|
||||
}
|
||||
@ -1678,8 +1674,8 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Direct handle constructor.
|
||||
*/
|
||||
Statement(const StmtRef & s)
|
||||
: m_Handle(s)
|
||||
explicit Statement(StmtRef s)
|
||||
: m_Handle(std::move(s))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
@ -1723,7 +1719,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit conversion to the raw connection handle.
|
||||
*/
|
||||
operator sqlite3_stmt * ()
|
||||
operator sqlite3_stmt * () // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||
{
|
||||
return m_Handle ? m_Handle->mPtr : nullptr;
|
||||
}
|
||||
@ -1731,7 +1727,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit conversion to the raw connection handle.
|
||||
*/
|
||||
operator sqlite3_stmt * () const
|
||||
operator sqlite3_stmt * () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||
{
|
||||
return m_Handle ? m_Handle->mPtr : nullptr;
|
||||
}
|
||||
@ -2441,12 +2437,12 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct by taking the handle from a connection.
|
||||
*/
|
||||
Transaction(const Connection & db);
|
||||
explicit Transaction(const Connection & db);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct using the direct connection handle.
|
||||
*/
|
||||
Transaction(ConnRef db);
|
||||
explicit Transaction(ConnRef db);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
@ -2481,14 +2477,6 @@ public:
|
||||
return m_Handle ? m_Handle->mName : NullString();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the associated statement handle.
|
||||
*/
|
||||
const ConnRef & GetHandle() const
|
||||
{
|
||||
return m_Handle;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* See whether the managed handle is valid.
|
||||
*/
|
||||
|
@ -409,6 +409,12 @@ SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook);
|
||||
# define SQ_UNUSED_ARG(x) x
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define SQ_UNUSED_TYPEDEF(x) x __attribute__((__unused__))
|
||||
#else
|
||||
# define SQ_UNUSED_TYPEDEF(x) x
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user