source: main/trunk/greenstone2/runtime-src/src/recpt/formattools.h@ 23515

Last change on this file since 23515 was 23515, checked in by davidb, 13 years ago

Generalizatoin of metadata-spanwrap to be either metadata-spanwrap or metadata-divwrap

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