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