source: trunk/gsdl/src/library/gdbmclass.h@ 22

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

Added functionality to allow books to be sorted on the fly rather than being displayed only in the order they were built.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1#ifndef GDBMCLASS_H
2#define GDBMCLASS_H
3
4#ifdef __WIN32__
5#include "autoconf.h"
6#include "systems.h"
7#include "gdbmconst.h"
8#include "gdbm.h"
9
10#else
11#include <gdbm.h>
12#endif
13
14#include "locateinfo.h"
15
16
17class gdbm_info
18{
19public:
20 int docnum;
21 int d;
22 text_t t;
23 text_t p;
24 text_t x;
25 text_t c;
26 text_t j;
27 text_t o;
28 text_t a;
29
30 void clear ();
31};
32
33
34class gdbmclass
35{
36public:
37 gdbmclass() {gdbm_file = NULL; logout = &cerr;};
38 ~gdbmclass() {};
39
40 // returns 0 on success, -1 on failure
41 int getinfo (text_t key, text_t collection, gdbm_info &info);
42 void setgdbmhome (const text_t &thegdbmhome);
43 void setlogout (ostream *thelogout) {logout = thelogout;}
44 int exists (text_t key, text_t collection);
45
46protected:
47 text_t gdbmhome; // top level directory for gdbm files
48 GDBM_FILE gdbm_file;
49 text_t gdbm_open_name;
50 ostream *logout;
51
52 int open_database (const text_t &collection);
53 void close_database ();
54
55 int get_infoline (char *str, int len, int pos, char *key, char *value);
56};
57
58
59// a few useful functions
60
61int is_top_level (const text_t &targetdoc);
62int is_book (const text_t &targetdoc);
63void get_book_top (const text_t &targetdoc, text_t &book_top);
64void get_book (const text_t &targetdoc, text_t &book);
65void get_parent_section (text_t &section);
66void get_parent_section (text_t &parentsection, text_t &childsection);
67int count_dots (text_t::const_iterator first, text_t::const_iterator last);
68int count_dots (const text_t &targetdoc);
69int is_section_top (const text_t &targetdoc);
70void remove_tags (text_t &text);
71
72void seperate_parts (const text_t &targetdoc, gdbmclass &gdbm, const text_t &collection,
73 text_t &classification, text_t &booksection);
74void split_targetdoc (const text_t &targetdoc, text_t &classification,
75 text_t &booksection);
76void splitstring (const text_t &string, vector<text_t> &array);
77void get_parents (const text_t &targetdoc, vector<text_t> &parents);
78void get_siblings (const text_t &classification, const text_t &booksection,
79 gdbmclass &gdbm, const text_t &collection,
80 vector<text_t> &siblings);
81int are_same_chapter(text_t section1, text_t section2);
82void get_first_section(const text_t &instring, text_t &returnstring);
83int is_number (text_t &text);
84text_t get_section_str(const text_t &str);
85void alphabetize_string_english (text_t &text);
86void alphabetize_string_name (text_t &text);
87char ** string_add (char **array, int *len, char *str);
88void string_sort (char **array, int len);
89static int compare_str (const void *e1, const void *e2);
90void string_free(char **array, int len);
91#endif
Note: See TracBrowser for help on using the repository browser.