2016-02-27 10:57:29 +01:00
|
|
|
#ifndef _SQSQLITE_COMMON_HPP_
|
|
|
|
#define _SQSQLITE_COMMON_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-03 20:31:00 +02:00
|
|
|
#include "Base/Utility.hpp"
|
2016-02-27 10:57:29 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <sqlite3.h>
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Forward declarations.
|
|
|
|
*/
|
|
|
|
class Connection;
|
|
|
|
class Statement;
|
|
|
|
class Column;
|
|
|
|
class Transaction;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* SOFTWARE INFORMATION
|
|
|
|
*/
|
|
|
|
#define SQSQLITE_NAME "Squirrel SQLite Module"
|
|
|
|
#define SQSQLITE_AUTHOR "Sandu Liviu Catalin (S.L.C)"
|
|
|
|
#define SQSQLITE_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
|
|
|
|
#define SQSQLITE_HOST_NAME "SqModSQLiteHost"
|
|
|
|
#define SQSQLITE_VERSION 001
|
|
|
|
#define SQSQLITE_VERSION_STR "0.0.1"
|
|
|
|
#define SQSQLITE_VERSION_MAJOR 0
|
|
|
|
#define SQSQLITE_VERSION_MINOR 0
|
|
|
|
#define SQSQLITE_VERSION_PATCH 1
|
|
|
|
|
2016-06-15 22:49:25 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Handle validation.
|
|
|
|
*/
|
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
#define VALIDATE_HND(x) (x).Validate(__FILE__, __LINE__)
|
|
|
|
#define VALIDATE_OPENED_HND(x) (x).ValidateOpened(__FILE__, __LINE__)
|
|
|
|
#define VALIDATE_CREATED_HND(x) (x).ValidateCreated(__FILE__, __LINE__)
|
|
|
|
#define VALIDATE_COLUMN_HND(x, i) (x).ValidateColumn((i), __FILE__, __LINE__)
|
|
|
|
#define VALIDATE_PARAMETER_HND(x, i) (x).ValidateParameter((i), __FILE__, __LINE__)
|
|
|
|
#define VALIDATE_ROW_HND(x) (x).ValidateRow(__FILE__, __LINE__)
|
|
|
|
#define GET_VALID_HND(x) (x).GetValid(__FILE__, __LINE__)
|
|
|
|
#define GET_OPENED_HND(x) (x).GetValid(__FILE__, __LINE__)
|
|
|
|
#define GET_CREATED_HND(x) (x).GetCreated(__FILE__, __LINE__)
|
|
|
|
#else
|
|
|
|
#define VALIDATE_HND(x) (x).Validate()
|
|
|
|
#define VALIDATE_OPENED_HND(x) (x).ValidateOpened()
|
|
|
|
#define VALIDATE_CREATED_HND(x) (x).ValidateCreated()
|
|
|
|
#define VALIDATE_COLUMN_HND(x, i) (x).ValidateColumn((i))
|
|
|
|
#define VALIDATE_PARAMETER_HND(x, i) (x).ValidateParameter((i))
|
|
|
|
#define VALIDATE_ROW_HND(x) (x).ValidateRow()
|
|
|
|
#define GET_VALID_HND(x) (x).GetValid()
|
|
|
|
#define GET_OPENED_HND(x) (x).GetValid()
|
|
|
|
#define GET_CREATED_HND(x) (x).GetCreated()
|
|
|
|
#endif // _DEBUG
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Helper macros for architecture differences.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _SQ64
|
|
|
|
#define sqlite3_bind_integer sqlite3_bind_int64
|
|
|
|
#define sqlite3_column_integer sqlite3_column_int64
|
|
|
|
#else
|
|
|
|
#define sqlite3_bind_integer sqlite3_bind_int
|
|
|
|
#define sqlite3_column_integer sqlite3_column_int
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Forward declarations.
|
|
|
|
*/
|
|
|
|
struct ConnHnd;
|
|
|
|
struct StmtHnd;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Common typedefs.
|
|
|
|
*/
|
|
|
|
typedef SharedPtr< ConnHnd > ConnRef;
|
|
|
|
typedef SharedPtr< StmtHnd > StmtRef;
|
|
|
|
|
2016-02-27 10:57:29 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Generate a formatted query.
|
|
|
|
*/
|
|
|
|
CSStr QFmtStr(CSStr str, ...);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Tests if a certain query string is empty.
|
|
|
|
*/
|
|
|
|
bool IsQueryEmpty(CSStr str);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Retrieve the string representation of a certain status code.
|
|
|
|
*/
|
|
|
|
CSStr GetErrStr(Int32 status);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Set a specific heap limit.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
void SetSoftHeapLimit(Int32 limit);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Release the specified amount of memory.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
Int32 ReleaseMemory(Int32 bytes);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Retrieve the current memory usage.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
Object GetMemoryUsage();
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Retrieve the memory high watermark.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
Object GetMemoryHighwaterMark(bool reset);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Retrieve the escaped version of the specified string.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
CSStr EscapeString(CSStr str);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Retrieve the escaped version of the specified string using the supplied format specifier.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
CCStr EscapeStringEx(SQChar spec, CCStr str);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Convert the values from the specified array to a list of column names string.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
CCStr ArrayToQueryColumns(Array & arr);
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-27 16:53:12 +01:00
|
|
|
* Convert the keys from the specified array to a list of column names string.
|
2016-02-27 10:57:29 +01:00
|
|
|
*/
|
|
|
|
CCStr TableToQueryColumns(Table & tbl);
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _SQSQLITE_COMMON_HPP_
|