1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * formattools.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 | *********************************************************************/
|
---|
25 |
|
---|
26 |
|
---|
27 | #ifndef FORMATTOOLS_H
|
---|
28 | #define FORMATTOOLS_H
|
---|
29 |
|
---|
30 | #include "text_t.h"
|
---|
31 | #include "comtypes.h"
|
---|
32 |
|
---|
33 | enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,
|
---|
34 | comDoc, comHighlight, comEndHighlight};
|
---|
35 | enum pcommand_t {pNone, pImmediate, pTop, pAll};
|
---|
36 | enum dcommand_t {dMeta};
|
---|
37 | enum mcommand_t {mNone, mCgiSafe};
|
---|
38 |
|
---|
39 | struct metadata_t {
|
---|
40 | void clear();
|
---|
41 | metadata_t () {clear();}
|
---|
42 |
|
---|
43 | text_t metaname;
|
---|
44 | mcommand_t metacommand;
|
---|
45 | pcommand_t parentcommand;
|
---|
46 | text_t parentoptions;
|
---|
47 | };
|
---|
48 |
|
---|
49 | struct decision_t {
|
---|
50 | void clear();
|
---|
51 | decision_t () {clear();}
|
---|
52 |
|
---|
53 | dcommand_t command;
|
---|
54 | metadata_t meta;
|
---|
55 | };
|
---|
56 |
|
---|
57 | struct format_t {
|
---|
58 | void clear();
|
---|
59 | format_t () {clear();}
|
---|
60 |
|
---|
61 | command_t command;
|
---|
62 | decision_t decision;
|
---|
63 | text_t text;
|
---|
64 | metadata_t meta;
|
---|
65 | format_t *nextptr;
|
---|
66 | format_t *ifptr;
|
---|
67 | format_t *elseptr;
|
---|
68 | format_t *orptr;
|
---|
69 | };
|
---|
70 |
|
---|
71 | // the format structure used by this receptionist
|
---|
72 | struct formatinfo_t {
|
---|
73 | void clear();
|
---|
74 | formatinfo_t () {clear();}
|
---|
75 |
|
---|
76 | bool DocumentImages;
|
---|
77 | bool DocumentTitles;
|
---|
78 | text_t DocumentHeading;
|
---|
79 | bool DocumentContents;
|
---|
80 | bool DocumentArrowsBottom;
|
---|
81 | text_tarray DocumentButtons;
|
---|
82 | text_t DocumentText;
|
---|
83 | text_tmap formatstrings;
|
---|
84 | bool DocumentUseHTML;
|
---|
85 | };
|
---|
86 |
|
---|
87 | bool is_table_content (const text_t &formatstring);
|
---|
88 | bool is_table_content (const format_t *formatlistptr);
|
---|
89 |
|
---|
90 | bool get_formatstring (const text_t &key, const text_tmap &formatstringmap,
|
---|
91 | text_t &formatstring);
|
---|
92 | bool get_formatstring (const text_t &key1, const text_t &key2,
|
---|
93 | const text_tmap &formatstringmap,
|
---|
94 | text_t &formatstring);
|
---|
95 |
|
---|
96 | text_t format_date (const text_t &date);
|
---|
97 |
|
---|
98 | bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,
|
---|
99 | text_tset &metadata, bool &getParents);
|
---|
100 |
|
---|
101 | text_t get_formatted_string (ResultDocInfo_t &docinfo, format_t *formatlistptr,
|
---|
102 | const text_t &link, const text_t &icon);
|
---|
103 |
|
---|
104 | text_t get_formatted_string (ResultDocInfo_t &docinfo, format_t *formatlistptr);
|
---|
105 |
|
---|
106 | text_t get_formatted_string (ResultDocInfo_t &docinfo, format_t *formatlistptr,
|
---|
107 | const text_t &text);
|
---|
108 |
|
---|
109 | text_t get_formatted_string (ResultDocInfo_t &docinfo, format_t *formatlistptr,
|
---|
110 | const text_t &link, const text_t &icon, const text_t &text);
|
---|
111 |
|
---|
112 | text_t get_formatted_string (ResultDocInfo_t &docinfo, format_t *formatlistptr,
|
---|
113 | const text_t &link, const text_t &icon, bool highlight);
|
---|
114 |
|
---|
115 | text_t get_formatted_string (ResultDocInfo_t &docinfo, format_t *formatlistptr,
|
---|
116 | const text_t &link, const text_t &icon,
|
---|
117 | const text_t &text, bool highlight);
|
---|
118 |
|
---|
119 |
|
---|
120 | #endif
|
---|