root/main/trunk/greenstone2/runtime-src/src/recpt/formattools.h @ 28760

Revision 28760, 4.4 KB (checked in by ak19, 6 years ago)

Adding in the first working version of the formatconverter program which uses formattools to convert GS2 statements to GS3. Not all the GS2 terms have GS3 equivalents yet and the current ones still need to be run by Dr Bainbridge, but nested IFs and ORs seem to work alright in general. Kathy made the important changes to Makefile.in to get the new formatconverter.cpp to compile. formatconverter.cpp uses the new GS2-to-GS3 specific functions added to formattools.cpp

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