presage 0.9.1
sqliteDatabaseConnector.h
Go to the documentation of this file.
1
2/******************************************************
3 * Presage, an extensible predictive text entry system
4 * ---------------------------------------------------
5 *
6 * Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 **********(*)*/
23
24
25#ifndef SQLITEDATABASECONNECTOR_H
26#define SQLITEDATABASECONNECTOR_H
27
28#ifdef HAVE_CONFIG_H
29# include "config.h"
30#endif
31
32#if defined(HAVE_SQLITE3_H)
33# include <sqlite3.h>
34#elif defined(HAVE_SQLITE_H)
35# include <sqlite.h>
36#else
37# error "SQLite is required. Please install SQLite."
38#endif
39
40#include "databaseConnector.h"
41#include "../../presageException.h"
42
44 public:
45 SqliteDatabaseConnector(const std::string db,
46 const size_t cardinality,
47 const bool read_write);
48 SqliteDatabaseConnector(const std::string db,
49 const size_t cardinality,
50 const bool read_write,
51 const std::string logger_level);
53
54 virtual void openDatabase();
55 virtual void closeDatabase();
56 virtual NgramTable executeSql(const std::string query) const;
57
59 public:
60 SqliteDatabaseConnectorException(presage_error_code_t code, const std::string& errormsg) throw() : PresageException(code, errormsg) { }
62
63 private:
65
66 };
67
68 protected:
69
70 private:
71 static int callback(void *pArg, int argc, char **argv, char **columnNames);
72
73#if defined(HAVE_SQLITE3_H)
74 sqlite3* db;
75#elif defined(HAVE_SQLITE_H)
76 sqlite* db;
77#endif
78
79};
80
81#endif // SQLITEDATABASECONNECTOR_H
virtual const presage_error_code_t code() const
PresageException(presage_error_code_t code, const std::string &msg)
SqliteDatabaseConnectorException(presage_error_code_t code, const std::string &errormsg)
static int callback(void *pArg, int argc, char **argv, char **columnNames)
SqliteDatabaseConnector(const std::string db, const size_t cardinality, const bool read_write)
virtual NgramTable executeSql(const std::string query) const
std::vector< Ngram > NgramTable
presage_error_code_t
@ PRESAGE_ERROR