SqliteDb.h
From Giona
(Difference between revisions)
Line 1: | Line 1: | ||
+ | <pre> | ||
+ | #ifndef SQLITEDB_H_ | ||
+ | #define SQLITEDB_H_ | ||
+ | #include <cstring> | ||
+ | #include "sqlite3.h" | ||
+ | #include "Debug.h" | ||
+ | #include "SqliteDBResultSet.h" | ||
+ | |||
+ | |||
+ | |||
+ | class SqliteDb | ||
+ | { | ||
+ | public: | ||
+ | |||
+ | static const int NO_ERROR = 0; | ||
+ | static const int ERROR_NULL_PARAMETER = 1; | ||
+ | static const int ERROR_EMPTY_STRING = 2; | ||
+ | static const int ERROR_CONNECTION_OPEN_YET = 3; | ||
+ | static const int ERROR_DATABASE_NAME_NOT_SET = 4; | ||
+ | static const int ERROR_SQLITE_ERROR = 5; | ||
+ | static const int ERROR_CONNECTION_NOT_OPEN = 6; | ||
+ | static const int ERROR_CANT_CREATE_RESULT_SET = 7; | ||
+ | |||
+ | SqliteDb(); | ||
+ | virtual ~SqliteDb(); | ||
+ | bool isConnected(); | ||
+ | int getLastError(); | ||
+ | bool setDataBaseName(char* dataBaseName); | ||
+ | bool openDataBase(); | ||
+ | bool closeDataBase(); | ||
+ | bool executeSqlCommand(char* sqlCommand); | ||
+ | |||
+ | SqliteDBResultSet* executeQuery(char* query); | ||
+ | |||
+ | private: | ||
+ | bool connected; | ||
+ | sqlite3* db; | ||
+ | int lastError; | ||
+ | char* dataBaseName; | ||
+ | SqliteDBResultSet* rsTmp; | ||
+ | int nRows; | ||
+ | |||
+ | bool compileResultSet(int num_fields, char **p_fields, char **p_col_names); | ||
+ | static int select_callback(void *p_data, int num_fields, char **p_fields, char **p_col_names); | ||
+ | }; | ||
+ | |||
+ | |||
+ | #endif /*SQLITEDB_H_*/ | ||
+ | |||
+ | </pre> | ||
[[Creazione di applicazioni con SQLite | BACK]] | [[Creazione di applicazioni con SQLite | BACK]] |
Revision as of 12:24, 15 December 2007
#ifndef SQLITEDB_H_ #define SQLITEDB_H_ #include <cstring> #include "sqlite3.h" #include "Debug.h" #include "SqliteDBResultSet.h" class SqliteDb { public: static const int NO_ERROR = 0; static const int ERROR_NULL_PARAMETER = 1; static const int ERROR_EMPTY_STRING = 2; static const int ERROR_CONNECTION_OPEN_YET = 3; static const int ERROR_DATABASE_NAME_NOT_SET = 4; static const int ERROR_SQLITE_ERROR = 5; static const int ERROR_CONNECTION_NOT_OPEN = 6; static const int ERROR_CANT_CREATE_RESULT_SET = 7; SqliteDb(); virtual ~SqliteDb(); bool isConnected(); int getLastError(); bool setDataBaseName(char* dataBaseName); bool openDataBase(); bool closeDataBase(); bool executeSqlCommand(char* sqlCommand); SqliteDBResultSet* executeQuery(char* query); private: bool connected; sqlite3* db; int lastError; char* dataBaseName; SqliteDBResultSet* rsTmp; int nRows; bool compileResultSet(int num_fields, char **p_fields, char **p_col_names); static int select_callback(void *p_data, int num_fields, char **p_fields, char **p_col_names); }; #endif /*SQLITEDB_H_*/