[15599] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
[15640] | 3 | * sqlitedbclass.h --
|
---|
[15599] | 4 | * Copyright (C) 2008 DL Consulting Ltd
|
---|
[22043] | 5 | * Copyright (C) 2010 New Zealand Digital Library Project
|
---|
[15599] | 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 |
|
---|
[15640] | 27 | #ifndef SQLITEDBCLASS_H
|
---|
| 28 | #define SQLITEDBCLASS_H
|
---|
[15599] | 29 |
|
---|
| 30 |
|
---|
[15753] | 31 | #include "sqldbclass.h"
|
---|
[15599] | 32 | #include "sqlite3.h"
|
---|
| 33 |
|
---|
| 34 |
|
---|
[15753] | 35 | class sqlitedbclass : public sqldbclass
|
---|
[15599] | 36 | {
|
---|
| 37 | public:
|
---|
[22043] | 38 | sqlitedbclass();
|
---|
| 39 | virtual ~sqlitedbclass();
|
---|
[15599] | 40 |
|
---|
| 41 | // returns true if opened
|
---|
[22043] | 42 | bool opendatabase (const text_t &filename, int mode, int num_retrys,
|
---|
| 43 | bool need_filelock);
|
---|
[15642] | 44 |
|
---|
[15599] | 45 | void closedatabase ();
|
---|
| 46 |
|
---|
[15642] | 47 | void deletekey (const text_t &key);
|
---|
[15599] | 48 |
|
---|
[15679] | 49 | // returns file extension string
|
---|
| 50 | text_t getfileextension ();
|
---|
| 51 |
|
---|
[15599] | 52 | // returns true on success
|
---|
[15643] | 53 | bool getkeydata (const text_t& key, text_t &data);
|
---|
| 54 |
|
---|
[15642] | 55 | // returns array of keys
|
---|
[15631] | 56 | text_tarray getkeys ();
|
---|
[15599] | 57 |
|
---|
[22043] | 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 |
|
---|
[15752] | 64 | // returns array of values
|
---|
[22043] | 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);
|
---|
[15752] | 68 |
|
---|
[15642] | 69 | // returns true on success
|
---|
[15648] | 70 | bool setkeydata (const text_t &key, const text_t &data);
|
---|
[15647] | 71 |
|
---|
[15599] | 72 | protected:
|
---|
| 73 | text_t openfile;
|
---|
| 74 | sqlite3* sqlitefile;
|
---|
[15601] | 75 |
|
---|
[22043] | 76 | virtual text_t sql_safe (const text_t &value_arg);
|
---|
[15849] | 77 |
|
---|
[22043] | 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 |
|
---|
[15599] | 82 | };
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | #endif
|
---|