[15429] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * gdbmclass.h --
|
---|
| 4 | * Copyright (C) 1999-2008 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
| 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
| 9 | *
|
---|
| 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
| 24 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 | #ifndef GDBMCLASS_H
|
---|
| 27 | #define GDBMCLASS_H
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | #include "gsdlconf.h"
|
---|
[15436] | 31 | #include "dbclass.h"
|
---|
[15429] | 32 |
|
---|
| 33 | #ifdef __WIN32__
|
---|
| 34 |
|
---|
| 35 | #ifdef __cplusplus
|
---|
| 36 | extern "C" {
|
---|
| 37 | #endif
|
---|
| 38 | #include "autoconf.h"
|
---|
| 39 | #include "systems.h"
|
---|
| 40 | #include "gdbmconst.h"
|
---|
| 41 | #include "gdbm.h"
|
---|
| 42 | #ifdef __cplusplus
|
---|
| 43 | }
|
---|
| 44 | #endif
|
---|
| 45 |
|
---|
| 46 | #else
|
---|
| 47 | #include <gdbm.h>
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 |
|
---|
[15557] | 51 | class gdbmclass : public dbclass
|
---|
[15429] | 52 | {
|
---|
| 53 | public:
|
---|
[15436] | 54 | gdbmclass() { gdbmfile = NULL; };
|
---|
[15429] | 55 | ~gdbmclass();
|
---|
[15644] | 56 |
|
---|
[15429] | 57 | // returns true if opened
|
---|
[15644] | 58 | bool opendatabase (const text_t &filename, int mode, int num_retrys, bool need_filelock);
|
---|
| 59 |
|
---|
[15429] | 60 | void closedatabase ();
|
---|
| 61 |
|
---|
[15644] | 62 | void deletekey (const text_t &key);
|
---|
[15429] | 63 |
|
---|
| 64 | // returns true on success
|
---|
[15644] | 65 | bool getkeydata (const text_t& key, text_t &data);
|
---|
[15429] | 66 |
|
---|
[15644] | 67 | // returns array of keys
|
---|
[15630] | 68 | text_tarray getkeys ();
|
---|
[15429] | 69 |
|
---|
[15644] | 70 | // returns true on success
|
---|
[15649] | 71 | bool setkeydata (const text_t &key, const text_t &data);
|
---|
[15429] | 72 |
|
---|
| 73 | protected:
|
---|
| 74 | text_t openfile;
|
---|
| 75 | GDBM_FILE gdbmfile;
|
---|
| 76 |
|
---|
[15630] | 77 | // getfirstkey and getnextkey are used for traversing the database
|
---|
| 78 | // no insertions or deletions should be carried out while traversing
|
---|
| 79 | // the database. when there are no keys left to visit in the database
|
---|
| 80 | // an empty string is returned.
|
---|
| 81 | text_t getfirstkey ();
|
---|
| 82 | text_t getnextkey (const text_t &key);
|
---|
[15429] | 83 | };
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | #endif
|
---|