[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"
|
---|
[1443] | 31 | #include "recptproto.h"
|
---|
[1610] | 32 | #include "display.h"
|
---|
[347] | 33 |
|
---|
[670] | 34 | enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,
|
---|
[4936] | 35 | comDoc, comHighlight, comEndHighlight, comRel, comHref, comSummary,
|
---|
| 36 | comTOC, comImage, comDocumentButtonDetach, comDocumentButtonHighlight,
|
---|
[16915] | 37 | comDocumentButtonExpandContents, comDocumentButtonExpandText, comOID, comTopOID, comRank,
|
---|
| 38 | comCollection, comDocTermsFreqTotal};
|
---|
[9401] | 39 |
|
---|
[12567] | 40 | enum mcommand_t {mNone=0, mCgiSafe=1, mParent=2, mSibling=4, mChild=8, mSpecial=16};
|
---|
[9401] | 41 |
|
---|
[649] | 42 | enum pcommand_t {pNone, pImmediate, pTop, pAll};
|
---|
[10415] | 43 | enum scommand_t {sNone, sAll, sNum};
|
---|
[9401] | 44 | enum ccommand_t {cNone, cAll, cNum};
|
---|
[1610] | 45 | enum dcommand_t {dMeta, dText};
|
---|
[347] | 46 |
|
---|
| 47 | struct metadata_t {
|
---|
| 48 | void clear();
|
---|
| 49 | metadata_t () {clear();}
|
---|
| 50 |
|
---|
[410] | 51 | text_t metaname;
|
---|
[5787] | 52 | int metacommand; // used to hold flags from mcommand_t
|
---|
[9401] | 53 | struct {
|
---|
| 54 | pcommand_t parent;
|
---|
| 55 | scommand_t sibling;
|
---|
| 56 | ccommand_t child;
|
---|
| 57 | } mqualifier;
|
---|
| 58 |
|
---|
[19046] | 59 | text_t pre_tree_traverse;
|
---|
[10415] | 60 | text_t parentoptions;
|
---|
| 61 | text_t siblingoptions;
|
---|
| 62 | text_t childoptions;
|
---|
[347] | 63 | };
|
---|
| 64 |
|
---|
[1610] | 65 |
|
---|
| 66 | // The decision component of an {If}{decision,true-text,false-text}
|
---|
[7389] | 67 | // formatstring. The decision can be based on metadata or on text;
|
---|
[1610] | 68 | // normally that text would be a macro like _cgiargmode_. --gordon
|
---|
[347] | 69 | struct decision_t {
|
---|
| 70 | void clear();
|
---|
| 71 | decision_t () {clear();}
|
---|
| 72 |
|
---|
| 73 | dcommand_t command;
|
---|
| 74 | metadata_t meta;
|
---|
[1610] | 75 | text_t text;
|
---|
[347] | 76 | };
|
---|
| 77 |
|
---|
| 78 | struct format_t {
|
---|
| 79 | void clear();
|
---|
| 80 | format_t () {clear();}
|
---|
| 81 |
|
---|
| 82 | command_t command;
|
---|
| 83 | decision_t decision;
|
---|
| 84 | text_t text;
|
---|
| 85 | metadata_t meta;
|
---|
| 86 | format_t *nextptr;
|
---|
| 87 | format_t *ifptr;
|
---|
| 88 | format_t *elseptr;
|
---|
| 89 | format_t *orptr;
|
---|
| 90 | };
|
---|
| 91 |
|
---|
[442] | 92 | // the format structure used by this receptionist
|
---|
| 93 | struct formatinfo_t {
|
---|
| 94 | void clear();
|
---|
| 95 | formatinfo_t () {clear();}
|
---|
[347] | 96 |
|
---|
[1079] | 97 | bool DocumentImages;
|
---|
| 98 | bool DocumentTitles;
|
---|
| 99 | text_t DocumentHeading;
|
---|
| 100 | bool DocumentContents;
|
---|
[442] | 101 | bool DocumentArrowsBottom;
|
---|
[4868] | 102 | bool DocumentArrowsTop;
|
---|
[13365] | 103 | bool DocumentSearchResultLinks;
|
---|
[442] | 104 | text_tarray DocumentButtons;
|
---|
| 105 | text_t DocumentText;
|
---|
[1941] | 106 | //-----------------
|
---|
| 107 | text_t RelatedDocuments;
|
---|
| 108 | //----------------
|
---|
[649] | 109 | text_tmap formatstrings;
|
---|
[868] | 110 | bool DocumentUseHTML;
|
---|
[4972] | 111 | bool AllowExtendedOptions;
|
---|
[442] | 112 | };
|
---|
| 113 |
|
---|
[749] | 114 | bool is_table_content (const text_t &formatstring);
|
---|
| 115 | bool is_table_content (const format_t *formatlistptr);
|
---|
| 116 |
|
---|
[649] | 117 | bool get_formatstring (const text_t &key, const text_tmap &formatstringmap,
|
---|
| 118 | text_t &formatstring);
|
---|
| 119 | bool get_formatstring (const text_t &key1, const text_t &key2,
|
---|
| 120 | const text_tmap &formatstringmap,
|
---|
| 121 | text_t &formatstring);
|
---|
[442] | 122 |
|
---|
[422] | 123 | text_t format_date (const text_t &date);
|
---|
[347] | 124 |
|
---|
[6645] | 125 | text_t remove_namespace(const text_t &meta_name);
|
---|
| 126 |
|
---|
[2001] | 127 | text_t iso639 (const text_t &langcode);
|
---|
[1941] | 128 |
|
---|
[2706] | 129 | text_t get_href (const text_t &link);
|
---|
| 130 |
|
---|
[1941] | 131 | text_t get_related_docs(const text_t& collection, recptproto* collectproto,
|
---|
| 132 | ResultDocInfo_t &docinfo, ostream& logout);
|
---|
| 133 |
|
---|
| 134 |
|
---|
[347] | 135 | bool parse_formatstring (const text_t &formatstring, format_t *formatlistptr,
|
---|
[649] | 136 | text_tset &metadata, bool &getParents);
|
---|
[347] | 137 |
|
---|
[407] | 138 |
|
---|
[347] | 139 |
|
---|
[1443] | 140 | text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
|
---|
[1610] | 141 | ResultDocInfo_t &docinfo, displayclass &disp,
|
---|
[4906] | 142 | format_t *formatlistptr, text_tmap &options,
|
---|
[1443] | 143 | ostream& logout);
|
---|
[347] | 144 |
|
---|
| 145 | #endif
|
---|
[1443] | 146 |
|
---|
| 147 |
|
---|