#ifndef CSQLITE3DBPROC_H
#define CSQLITE3DBPROC_H

#ifndef SQLITE_HAS_CODEC
#define SQLITE_HAS_CODEC
#endif


#include <string>
#include "sqlite3.h"



class CSqlite3DBProc
{
public:
    CSqlite3DBProc();
    ~CSqlite3DBProc();
    bool OpenDB(std::string sFile);
    bool CloseBD();
    bool ExcuteSql(std::string sSql);
    bool QuerySql(std::string sSql, sqlite3_stmt** m_stmt);
    bool BeginGetFields(sqlite3_stmt *m_stmt);
    bool Eof();
    bool Next(sqlite3_stmt *m_stmt);
    int GetFields(int nCol, int &nField, sqlite3_stmt *m_stmt);
    __int64 GetFields(int nCol, __int64 &nField, sqlite3_stmt *m_stmt);
    double GetFields(int nCol, double &fField, sqlite3_stmt *m_stmt);
    std::string GetFields(int nCol, std::string &sField, sqlite3_stmt *m_stmt);
    bool EndGetFields(sqlite3_stmt *m_stmt);

    bool BeginTransaction();
    bool CommitTransaction();
    bool RollbakTransaction();
    const std::string ErrMsg();
private:
    sqlite3 *m_pDB;
    bool m_bIsEof;
    static const std::string m_sDBEncode;
    static const int m_nDBEncodeKeyNum;
};


extern std::shared_ptr<CSqlite3DBProc> g_DBProcPtr;
extern std::shared_ptr<CSqlite3DBProc> g_sysDBProcPtr;


#endif // CSQLITE3DBPROC_H
