///////////////////////////////////////////////////////////////////////////////
// Name: wxsqlite3.h
// Purpose: wxWidgets wrapper around the SQLite3 embedded database library.
// Author: Ulrich Telle
// Modified by:
// Created: 2005-07-14
// Copyright: (c) Ulrich Telle
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
/// \file wxsqlite3.h Interface of the wxSQLite3 class
#ifndef _WX_SQLITE3_H_
#define _WX_SQLITE3_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "wxsqlite3.h"
#endif
#include <wx/arrstr.h>
#include <wx/datetime.h>
#include <wx/dynarray.h>
#include <wx/buffer.h>
#include <wx/hashmap.h>
#include <wx/regex.h>
#include <wx/string.h>
#include "wx/wxsqlite3def.h"
#include "wx/wxsqlite3_version.h"
/// wxSQLite3 version string
#define wxSQLITE3_VERSION_STRING wxS(WXSQLITE3_VERSION_STRING)
#define WXSQLITE_ERROR 1000
#define WXSQLITE_INTEGER 1
#define WXSQLITE_FLOAT 2
#define WXSQLITE_TEXT 3
#define WXSQLITE_BLOB 4
#define WXSQLITE_NULL 5
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 wxsqlite_int64;
#else
typedef long long int wxsqlite_int64;
#endif
/// Enumeration of transaction types
enum wxSQLite3TransactionType
{
WXSQLITE_TRANSACTION_DEFAULT,
WXSQLITE_TRANSACTION_DEFERRED,
WXSQLITE_TRANSACTION_IMMEDIATE,
WXSQLITE_TRANSACTION_EXCLUSIVE
};
/// Enumeration of SQLite limitation types
enum wxSQLite3LimitType
{
WXSQLITE_LIMIT_LENGTH = 0,
WXSQLITE_LIMIT_SQL_LENGTH = 1,
WXSQLITE_LIMIT_COLUMN = 2,
WXSQLITE_LIMIT_EXPR_DEPTH = 3,
WXSQLITE_LIMIT_COMPOUND_SELECT = 4,
WXSQLITE_LIMIT_VDBE_OP = 5,
WXSQLITE_LIMIT_FUNCTION_ARG = 6,
WXSQLITE_LIMIT_ATTACHED = 7,
WXSQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8,
WXSQLITE_LIMIT_VARIABLE_NUMBER = 9,
WXSQLITE_LIMIT_TRIGGER_DEPTH = 10,
WXSQLITE_LIMIT_WORKER_THREADS = 11
};
/// Enumeration of journal modes
enum wxSQLite3JournalMode
{
WXSQLITE_JOURNALMODE_DELETE = 0, // Commit by deleting journal file
WXSQLITE_JOURNALMODE_PERSIST = 1, // Commit by zeroing journal header
WXSQLITE_JOURNALMODE_OFF = 2, // Journal omitted.
WXSQLITE_JOURNALMODE_TRUNCATE = 3, // Commit by truncating journal
WXSQLITE_JOURNALMODE_MEMORY = 4, // In-memory journal file
WXSQLITE_JOURNALMODE_WAL = 5 // Use write-ahead logging
};
/// Enumeration of statement status counters
enum wxSQLite3StatementStatus
{
WXSQLITE_STMTSTATUS_FULLSCAN_STEP = 1,
WXSQLITE_STMTSTATUS_SORT = 2,
WXSQLITE_STMTSTATUS_AUTOINDEX = 3,
WXSQLITE_STMTSTATUS_VM_STEP = 4
};
#define WXSQLITE_OPEN_READONLY 0x00000001
#define WXSQLITE_OPEN_READWRITE 0x00000002
#define WXSQLITE_OPEN_CREATE 0x00000004
#define WXSQLITE_OPEN_URI 0x00000040
#define WXSQLITE_OPEN_MEMORY 0x00000080
#define WXSQLITE_OPEN_NOMUTEX 0x00008000
#define WXSQLITE_OPEN_FULLMUTEX 0x00010000
#define WXSQLITE_OPEN_SHAREDCACHE 0x00020000
#define WXSQLITE_OPEN_PRIVATECACHE 0x00040000
#define WXSQLITE_CHECKPOINT_PASSIVE 0
#define WXSQLITE_CHECKPOINT_FULL 1
#define WXSQLITE_CHECKPOINT_RESTART 2
#define WXSQLITE_CHECKPOINT_TRUNCATE 3
inline void operator++(wxSQLite3LimitType& value)
{
value = wxSQLite3LimitType(value+1);
}
/// SQL exception
class WXDLLIMPEXP_SQLITE3 wxSQLite3Exception
{
public:
/// Constructor
wxSQLite3Exception(int errorCode, const wxString& errMsg);
/// Copy constructor
wxSQLite3Exception(const wxSQLite3Exception& e);
/// Destructor
virtual ~wxSQLite3Exception();
/// Get error code associated with the exception
int GetErrorCode() const { return (m_errorCode & 0xff); }
/// Get extended error code associated with the exception
int GetExtendedErrorCode() const { return m_errorCode; }
/// Get error message associated with the exception
const wxString GetMessage() const { return m_errorMessage; }
/// Convert error code to error message
static const wxString ErrorCodeAsString(int errorCode);
private:
int m_errorCode; ///< SQLite3 error code associated with this exception
wxString m_errorMessage; ///< SQLite3 error message associated with this exception
};
/// SQL statment buffer for use with SQLite3's printf method
class WXDLLIMPEXP_SQLITE3 wxSQLite3StatementBuffer
{
public:
/// Constructor
wxSQLite3StatementBuffer();
/// Destructor
~wxSQLite3StatementBuffer();
/// Format a SQL statement using SQLite3's printf method
/**
* This method is a variant of the "sprintf()" from the standard C library.
* All of the usual printf formatting options apply. In addition,
* there is a "%q" option. %q works like %s in that it substitutes
* a null-terminated string from the argument list. But %q also
* doubles every '\'' character. %q is designed for use inside a
* string literal. By doubling each '\'' character it escapes that
* character and allows it to be inserted into the string.
*
* For example, so some string variable contains text as follows:
*
* char *zText = "It's a happy day!";
*
* One can use this text in an SQL statement as follows:
*
* wxSQLite3StatementBuffer stmtBuffer;
* stmtBuffer.Format("INSERT INTO table VALUES('%q')", zText);
*
* Because the %q format string is used, the '\'' character in
* zText is escaped and the SQL generated is as follows:
*
* INSERT INTO table1 VALUES('It''s a happy day!')
*
* \param format SQL statement string with formatting options
* \param ... list of statement parameters
* \return const char pointer to the resulting statement buffer
*/
const char* Format(const char* format, ...);
/// Format a SQL statement using SQLite3's printf method
/**
* This method is like method Format but takes a va_list argument
* to pass the statement parameters.
*
* \param format SQL statement string with formatting options
* \param va va_list of statement parameters
* \return const char pointer to the resulting statement buffer
*/
const char* FormatV(const char* format, va_list va);
/// Dereference the internal buffer
/**
* \return const char pointer to the resulting statement buffer
*/
operator const char*() const { return m_buffer; }
/// Clear the internal buffer
void Clear();
private:
char* m_buffer; ///< Internal buffer
};
/// Context for user defined scalar or aggregate functions
/**
* A function context gives user defined scalar or aggregate functions
* access to function arguments and function results. The "Execute" method
* resp. the "Aggregate" and "Finalize" methods receive the current
* function context as an argument.
*/
class WXDLLIMPEXP_SQLITE3 wxSQLite3FunctionContext
{
public:
/// Default destructor
virtual ~wxSQLite3FunctionContext();
/// Get the number of function arguments
/**
* \return the number of arguments the function was called with
*/
int GetArgCount();
/// Get the type of a function argument
/**
* \param argIndex index of the function argument. Indices start with 0.
* \return argument type as one of the values WXSQLITE_INTEGER, WXSQLITE_FLOAT, WXSQLITE_TEXT, WXSQLITE_BLOB, or WXSQLITE_NULL
*/
int GetArgType(int argIndex);
/// Check whether a function argument is a NULL value
/**
* \param argIndex index of the function argument. Indices start with 0.
* \return TRUE if the argument is NULL or the argIndex is out of bounds, FALSE otherwise
*/
bool IsNull(int argIndex);
/// Get a function argument as an integer value
/**
* \param argIndex index of the function argument. Indices start with 0.
* \
没有合适的资源?快使用搜索试试~ 我知道了~
wxWidgets框架中的wxSqlite3
共7个文件
h:5个
lib:2个
需积分: 47 22 下载量 32 浏览量
2017-12-01
23:18:04
上传
评论
收藏 4.31MB ZIP 举报
温馨提示
vs2015下编译的静态库,必须配合wxWidgets使用,运行库必须选择MT或MTD
资源推荐
资源详情
资源评论
收起资源包目录
wx_sqlite.zip (7个子文件)
wx_sqlite
lib
wxsqlite3.lib 7.06MB
wxsqlite3d.lib 5.63MB
include
wx
wxsqlite3dyn.h 25KB
wxsqlite3.h 114KB
wxsqlite3def.h 19KB
wxsqlite3_version.h 526B
wxsqlite3opt.h 2KB
共 7 条
- 1
资源评论
暗黑程序员
- 粉丝: 320
- 资源: 39
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功