[347] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * formattools.h --
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
[533] | 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.
|
---|
[347] | 9 | *
|
---|
[533] | 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 | *
|
---|
[347] | 24 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #ifndef FORMATTOOLS_H
|
---|
| 28 | #define FORMATTOOLS_H
|
---|
| 29 |
|
---|
| 30 | #include "text_t.h"
|
---|
| 31 | #include "comtypes.h"
|
---|
[1443] | 32 | #include "recptproto.h"
|
---|
[1610] | 33 | #include "display.h"
|
---|
[347] | 34 |
|
---|
[670] | 35 | enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,
|
---|
| 36 | comDoc, comHighlight, comEndHighlight};
|
---|
[649] | 37 | enum pcommand_t {pNone, pImmediate, pTop, pAll};
|
---|
[1610] | 38 | enum dcommand_t {dMeta, dText};
|
---|
[462] | 39 | enum mcommand_t {mNone, mCgiSafe};
|
---|
[347] | 40 |
|
---|
| 41 | struct metadata_t {
|
---|
| 42 | void clear();
|
---|
| 43 | metadata_t () {clear();}
|
---|
| 44 |
|
---|
[410] | 45 | text_t metaname;
|
---|
[462] | 46 | mcommand_t metacommand;
|
---|
[347] | 47 | pcommand_t parentcommand;
|
---|
| 48 | text_t parentoptions;
|
---|
| 49 | };
|
---|
| 50 |
|
---|
[1610] | 51 |
|
---|
| 52 | // The decision component of an {If}{decision,true-text,false-text}
|
---|
| 53 | // formatstring. Te decision can be based on metadata or on text;
|
---|
| 54 | // normally that text would be a macro like _cgiargmode_. --gordon
|
---|
[347] | 55 | struct decision_t {
|
---|
| 56 | void clear();
|
---|
| 57 | decision_t () {clear();}
|
---|
| 58 |
|
---|
| 59 | dcommand_t command;
|
---|
| 60 | metadata_t meta;
|
---|
[1610] | 61 | text_t text;
|
---|
[347] | 62 | };
|
---|
| 63 |
|
---|
| 64 | struct format_t {
|
---|
| 65 | void clear();
|
---|
| 66 | format_t () {clear();}
|
---|
| 67 |
|
---|
| 68 | command_t command;
|
---|
| 69 | decision_t decision;
|
---|
| 70 | text_t text;
|
---|
| 71 | metadata_t meta;
|
---|
| 72 | format_t *nextptr;
|
---|
| 73 | format_t *ifptr;
|
---|
| 74 | format_t *elseptr;
|
---|
| 75 | format_t *orptr;
|
---|
| 76 | };
|
---|
| 77 |
|
---|
[442] | 78 | // the format structure used by this receptionist
|
---|
| 79 | struct formatinfo_t {
|
---|
| 80 | void clear();
|
---|
| 81 | formatinfo_t () {clear();}
|
---|
[347] | 82 |
|
---|
[1079] | 83 | bool DocumentImages;
|
---|
| 84 | bool DocumentTitles;
|
---|
| 85 | text_t DocumentHeading;
|
---|
| 86 | bool DocumentContents;
|
---|
[442] | 87 | bool DocumentArrowsBottom;
|
---|
| 88 | text_tarray DocumentButtons;
|
---|
| 89 | text_t DocumentText;
|
---|
[649] | 90 | text_tmap formatstrings;
|
---|
[868] | 91 | bool DocumentUseHTML;
|
---|
[442] | 92 | };
|
---|
| 93 |
|
---|
[749] | 94 | bool is_table_content (const text_t &formatstring);
|
---|
| 95 | bool is_table_content (const format_t *formatlistptr);
|
---|
| 96 |
|
---|
[649] | 97 | bool get_formatstring (const text_t &key, const text_tmap &formatstringmap,
|
---|
| 98 | text_t &formatstring);
|
---|
| 99 | bool get_formatstring (const text_t &key1, const text_t &key2,
|
---|
| 100 | const text_tmap &formatstringmap,
|
---|
| 101 | text_t &formatstring);
|
---|
[442] | 102 |
|
---|
[422] | 103 | text_t format_date (const text_t &date);
|
---|
[347] | 104 |
|
---|
| 105 | bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,
|
---|
[649] | 106 | text_tset &metadata, bool &getParents);
|
---|
[347] | 107 |
|
---|
[407] | 108 |
|
---|
[1443] | 109 | text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
|
---|
[1610] | 110 | ResultDocInfo_t &docinfo, displayclass &disp,
|
---|
| 111 | format_t *formatlistptr,
|
---|
[1443] | 112 | const text_t &link, const text_t &icon,
|
---|
| 113 | const text_t& t, const bool highlight,
|
---|
| 114 | ostream& logout);
|
---|
[347] | 115 |
|
---|
[1443] | 116 | text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
|
---|
[1610] | 117 | ResultDocInfo_t &docinfo, displayclass &disp,
|
---|
| 118 | format_t *formatlistptr,
|
---|
[1443] | 119 | const text_t &link, const text_t &icon,
|
---|
| 120 | const bool highlight,
|
---|
| 121 | ostream& logout);
|
---|
[347] | 122 |
|
---|
[1443] | 123 | text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
|
---|
[1610] | 124 | ResultDocInfo_t &docinfo, displayclass &disp,
|
---|
| 125 | format_t *formatlistptr,
|
---|
[1443] | 126 | const text_t &text,
|
---|
| 127 | ostream& logout);
|
---|
[442] | 128 |
|
---|
[1443] | 129 | text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
|
---|
[1610] | 130 | ResultDocInfo_t &docinfo, displayclass &disp,
|
---|
| 131 | format_t *formatlistptr, ostream& logout);
|
---|
[442] | 132 |
|
---|
[670] | 133 |
|
---|
| 134 |
|
---|
[347] | 135 | #endif
|
---|
[1443] | 136 |
|
---|
| 137 |
|
---|