source: trunk/gsdl/src/colservr/gdbmclass.h@ 543

Last change on this file since 543 was 534, checked in by sjboddie, 25 years ago

added gpl notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/**********************************************************************
2 *
3 * gdbmclass.h --
4 * Copyright (C) 1999 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 * $Id: gdbmclass.h 534 1999-09-07 04:57:43Z sjboddie $
25 *
26 *********************************************************************/
27
28
29#ifndef GDBMCLASS_H
30#define GDBMCLASS_H
31
32
33
34#ifdef __WIN32__
35#include "autoconf.h"
36#include "systems.h"
37#include "gdbmconst.h"
38#include "gdbm.h"
39
40#else
41#include <gdbm.h>
42#endif
43
44
45class gdbm_info {
46public:
47 int docnum; // 'd'
48 text_t title; // 't'
49 text_t parent; // 'p'
50 text_t classification; // 'x'
51 text_t contents; // 'c'
52 text_t jobnum; // 'j'
53 text_t OID; // 'o'
54 text_t author; // 'a'
55 text_t source; // 's'
56 text_t date; // 'i'
57
58 void clear ();
59};
60
61
62class gdbmclass {
63public:
64 gdbmclass() {gdbmfile = NULL; logout = &cerr;};
65 ~gdbmclass() {};
66
67 // returns 0 if failed, 1 if opened
68 int opendatabase (const text_t &filename);
69 void closedatabase ();
70
71 // returns 0 on success, -1 on failure
72 int getinfo (text_t key, gdbm_info &info);
73 void setlogout (ostream *thelogout) {logout = thelogout;}
74 int exists (text_t key);
75
76protected:
77 text_t openfile;
78 GDBM_FILE gdbmfile;
79 ostream *logout;
80
81 int getkeydata (text_t key, text_t &data);
82 int getinfoline (text_t::iterator &here, text_t::iterator end,
83 text_t &key, text_t &value);
84};
85
86
87// a few useful functions
88
89int is_top_level (const text_t &targetdoc);
90int is_book (const text_t &targetdoc);
91void get_book_top (const text_t &targetdoc, text_t &book_top);
92void get_book (const text_t &targetdoc, text_t &book);
93void get_parent_section (text_t &section);
94void get_parent_section (text_t &parentsection, text_t &childsection);
95int count_dots (text_t::const_iterator first, text_t::const_iterator last);
96int count_dots (const text_t &targetdoc);
97int is_section_top (const text_t &targetdoc);
98void remove_tags (text_t &text);
99
100void separate_parts (const text_t &targetdoc, gdbmclass &gdbm,
101 text_t &classification, text_t &booksection);
102void split_targetdoc (const text_t &targetdoc, text_t &classification,
103 text_t &booksection);
104void splitstring (const text_t &string, vector<text_t> &array);
105void get_parents (const text_t &targetdoc, vector<text_t> &parents);
106void get_siblings (const text_t &classification, const text_t &booksection,
107 gdbmclass &gdbm, vector<text_t> &siblings);
108int are_same_chapter(text_t section1, text_t section2);
109void get_first_section(const text_t &instring, text_t &returnstring);
110int is_number (text_t &text);
111text_t get_section_str(const text_t &str);
112void alphabetize_string_english (text_t &text);
113void alphabetize_string_name (text_t &text);
114char ** string_add (char **array, int *len, char *str);
115void string_sort (char **array, int len);
116void string_free(char **array, int len);
117text_t format_date (const text_t &date);
118void format_month (text_t &month);
119void format_day(text_t &day);
120
121
122#endif
Note: See TracBrowser for help on using the repository browser.