设为首页 加入收藏

TOP

C++使用Sqlite3,使用CppSQLite3的封装(一)
2016-04-27 17:25:21 】 浏览:2626
Tags:使用 Sqlite3 CppSQLite3 封装

使用CppSQLite3后操作Sqlite3更加方便
CppSQLite3.h

////////////////////////////////////////////////////////////////////////////////
// CppSQLite3 - A C++ wrapper around the SQLite3 embedded database library.
//
// Copyright (c) 2004..2007 Rob Groves. All Rights Reserved. rob.groves@btinternet.com
// 
// Permission to use, copy, modify, and distribute this software and its
// documentation for any purpose, without fee, and without a written
// agreement, is hereby granted, provided that the above copyright notice, 
// this paragraph and the following two paragraphs appear in all copies, 
// modifications, and distributions.
//
// IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST
// PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
// EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
// ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO OBLIGATION
// TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
//
// V3.0     03/08/2004  -Initial Version for sqlite3
//
// V3.1     16/09/2004  -Implemented getXXXXField using sqlite3 functions
//                      -Added CppSQLiteDB3::tableExists()
//
// V3.2     01/07/2005  -Fixed execScalar to handle a NULL result
//          12/07/2007  -Added CppSQLiteDB::IsAutoCommitOn()
//                      -Added int64 functions to CppSQLite3Query
//                      -Added Name based parameter binding to CppSQLite3Statement.
////////////////////////////////////////////////////////////////////////////////
#ifndef _CppSQLite3_H_
#define _CppSQLite3_H_

#include "sqlite3.h"
#include 
   
     #include 
    
      #define CPPSQLITE_ERROR 1000 class CppSQLite3Exception { public: CppSQLite3Exception(const int nErrCode, char* szErrMess, bool bDeleteMsg=true); CppSQLite3Exception(const CppSQLite3Exception& e); virtual ~CppSQLite3Exception(); const int errorCode() { return mnErrCode; } const char* errorMessage() { return mpszErrMess; } static const char* errorCodeAsString(int nErrCode); private: int mnErrCode; char* mpszErrMess; }; class CppSQLite3Buffer { public: CppSQLite3Buffer(); ~CppSQLite3Buffer(); const char* format(const char* szFormat, ...); operator const char*() { return mpBuf; } void clear(); private: char* mpBuf; }; class CppSQLite3Binary { public: CppSQLite3Binary(); ~CppSQLite3Binary(); void setBinary(const unsigned char* pBuf, int nLen); void setEncoded(const unsigned char* pBuf); const unsigned char* getEncoded(); const unsigned char* getBinary(); int getBinaryLength(); unsigned char* allocBuffer(int nLen); void clear(); private: unsigned char* mpBuf; int mnBinaryLen; int mnBufferLen; int mnEncodedLen; bool mbEncoded; }; class CppSQLite3Query { public: CppSQLite3Query(); CppSQLite3Query(const CppSQLite3Query& rQuery); CppSQLite3Query(sqlite3* pDB, sqlite3_stmt* pVM, bool bEof, bool bOwnVM=true); CppSQLite3Query& operator=(const CppSQLite3Query& rQuery); virtual ~CppSQLite3Query(); int numFields(); int fieldIndex(const char* szField); const char* fieldName(int nCol); const char* fieldDeclType(int nCol); int fieldDataType(int nCol); const char* fieldValue(i
首页 上一页 1 2 3 4 5 6 7 下一页 尾页 1/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C++11新特性 下一篇c++内存管理

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目