source: main/trunk/greenstone2/common-src/src/lib/sqlitedbclass.h@ 26648

Last change on this file since 26648 was 22067, checked in by ak19, 14 years ago
  1. More changes to makefiles: rm JDBMWrapper.jar and jdbm.jar on clean. 2. DB files (argdb, users, key, history) now not only for gdbm but to work with other db types like jdbm, sqlite and mssql.
File size: 2.5 KB
Line 
1/**********************************************************************
2 *
3 * sqlitedbclass.h --
4 * Copyright (C) 2008 DL Consulting Ltd
5 * Copyright (C) 2010 New Zealand Digital Library Project
6 *
7 * A component of the Greenstone digital library software
8 * from the New Zealand Digital Library Project at the
9 * University of Waikato, New Zealand.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *********************************************************************/
26
27#ifndef SQLITEDBCLASS_H
28#define SQLITEDBCLASS_H
29
30
31#include "sqldbclass.h"
32#include "sqlite3.h"
33
34
35class sqlitedbclass : public sqldbclass
36{
37public:
38 sqlitedbclass(const text_t& gsdlhome);
39 virtual ~sqlitedbclass();
40
41 // returns true if opened
42 bool opendatabase (const text_t &filename, int mode, int num_retrys,
43 bool need_filelock);
44
45 void closedatabase ();
46
47 void deletekey (const text_t &key);
48
49 // returns file extension string
50 text_t getfileextension ();
51
52 // returns true on success
53 bool getkeydata (const text_t& key, text_t &data);
54
55 // returns array of keys
56 text_tarray getkeys ();
57
58
59 // returns array of document OIDs
60 virtual text_tarray get_documents_with_metadata_value (const text_tarray &metadata_element_names,
61 const text_t &metadata_value,
62 const text_t &sort_by_metadata_element_name);
63
64 // returns array of values
65 virtual text_tarray get_metadata_values (const text_tarray &metadata_element_names,
66 const text_t &metadata_value_filter,
67 const text_t &metadata_value_grouping_expression);
68
69 // returns true on success
70 bool setkeydata (const text_t &key, const text_t &data);
71
72protected:
73 text_t openfile;
74 sqlite3* sqlitefile;
75
76 virtual text_t sql_safe (const text_t &value_arg);
77
78 virtual bool sqlexec (const text_t &sql_cmd);
79 virtual bool sqlgetarray (const text_t &sql_cmd, vector<text_tmap> &sql_results);
80 virtual bool sqltableexists (const text_t &table_name);
81
82};
83
84
85#endif
Note: See TracBrowser for help on using the repository browser.