source: trunk/gsdl/src/recpt/comtypes.cpp@ 509

Last change on this file since 509 was 509, checked in by rjmcnab, 25 years ago

changes to get compiling on AIX

  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
RevLine 
[166]1/**********************************************************************
2 *
3 * comtypes.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: comtypes.cpp 509 1999-09-02 00:25:27Z rjmcnab $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
[509]14 Revision 1.17 1999/09/02 00:25:26 rjmcnab
15 changes to get compiling on AIX
16
[459]17 Revision 1.16 1999/08/13 04:19:05 sjboddie
18 added name attribute to metadata
19
[432]20 Revision 1.15 1999/08/03 03:31:43 sjboddie
21 added ability to set receptionist from configuration files
22
[398]23 Revision 1.14 1999/07/16 03:41:29 sjboddie
24 changed isApprox
25
[353]26 Revision 1.13 1999/07/08 20:46:45 rjmcnab
27 Added the result number to the ResultDocInfo_t
28
[348]29 Revision 1.12 1999/07/07 06:11:33 rjmcnab
30 Slight change for multiple phrase matching.
31
[336]32 Revision 1.11 1999/07/01 22:47:49 sjboddie
33 added format option to collection info
34
[310]35 Revision 1.10 1999/06/29 22:05:01 rjmcnab
36 Added a couple of fields to ResultDocInfo_t to handle a special
37 version of mg.
38
[272]39 Revision 1.9 1999/06/16 02:01:22 sjboddie
40 Few changes to get getParents filter option to return metadata of parents
41 as well as current OID
42
[257]43 Revision 1.8 1999/05/10 03:40:33 sjboddie
44 lots of changes - slowly getting document action sorted out
45
[241]46 Revision 1.7 1999/04/21 05:23:14 sjboddie
47
48 Changed the way metadata is returned
49
[226]50 Revision 1.6 1999/04/06 22:20:34 rjmcnab
51 Got browsefilter working.
52
[220]53 Revision 1.5 1999/03/31 23:44:47 rjmcnab
54 Altered the protocol so that the metadata is part of the filter.
55
[199]56 Revision 1.4 1999/03/11 00:11:19 rjmcnab
57 Added a function to get a string version of comerror_t
58
[197]59 Revision 1.3 1999/03/09 21:00:47 rjmcnab
60 Reorganised the statusaction, added more functions to comtypes.
61
[187]62 Revision 1.2 1999/03/04 21:19:15 rjmcnab
63
64 Added clear() functions to all the data types.
65
[166]66 Revision 1.1 1999/02/21 22:35:25 rjmcnab
67
68 Initial revision.
69
70 */
71
72
73#include "comtypes.h"
74
75
[199]76text_t get_comerror_string (comerror_t err) {
77 if (err == noError) return "no error";
78 else if (err == authenticationFailure) return "authentication failure";
79 else if (err == protocolError) return "protocol error";
[226]80 else if (err == configurationError) return "configuration error";
[199]81 else if (err == systemProblem) return "system problem";
82
83 return "unknown problem";
84}
85
86
[187]87void ShortColInfo_t::clear() {
88 name.clear();
89 host.clear();
90 port = 0;
91}
92
93void ColInfoResponse_t::clear () {
94 shortInfo.clear();
[166]95 isPublic=false;
96 isBeta=false;
97 buildDate=0;
98 numDocs=0;
99 numWords=0;
100 numBytes=0;
[336]101 format.erase(format.begin(), format.end());
[432]102 receptionist.clear();
[166]103}
104
[220]105void InfoFiltersResponse_t::clear () {
106 filterNames.erase(filterNames.begin(), filterNames.end());
107}
108
109
110void InfoFilterOptionsRequest_t::clear () {
111 filterName.clear();
112}
113
114
[187]115void FilterOption_t::clear () {
116 name.clear();
117 type = booleant;
118 repeatable = onePerQuery;
119 defaultValue.clear();
120 validValues.erase(validValues.begin(), validValues.end());
121}
122
[197]123void FilterOption_t::check_defaultValue () {
[226]124 text_tarray::iterator here, end;
[197]125
[226]126 // how the default is interpreted depends on the option type
127 switch (type) {
128 case booleant:
129 case enumeratedt: // has to be one of the validValues
130 here = validValues.begin ();
131 end = validValues.end ();
132 while (here != end) {
133 if (*here == defaultValue) return;
134 here++;
[197]135 }
[226]136
137 break;
[197]138
[226]139 case integert: // has to be in the validValues range
140 if ((validValues.size() >= 2) &&
141 (validValues[0].getint() <= defaultValue.getint()) &&
142 (validValues[1].getint() >= defaultValue.getint()))
143 return;
144 break;
145
146 case stringt: // any value is valid
147 return;
[197]148 }
149
[226]150 // did not find the defaultValue
151 if (validValues.empty()) defaultValue.clear();
152 else defaultValue = validValues[0];
[197]153}
154
[187]155
[509]156bool operator==(const FilterOption_t &x, const FilterOption_t &y) {
157 return ((x.name == y.name) &&
158 (x.type == y.type) &&
159 (x.repeatable == y.repeatable) &&
160 (x.defaultValue == y.defaultValue) &&
161 (x.validValues == y.validValues));
162}
163
164bool operator<(const FilterOption_t &x, const FilterOption_t &y) {
165 return ((x.name < y.name) ||
166 ((x.name == y.name) &&
167 ((x.type < y.type) ||
168 ((x.type == y.type) &&
169 ((x.repeatable < y.repeatable) ||
170 ((x.repeatable == y.repeatable) &&
171 ((x.defaultValue < y.defaultValue) ||
172 ((x.defaultValue == y.defaultValue) &&
173 (x.validValues < y.validValues)))))))));
174}
175
176
177
[187]178void InfoFilterOptionsResponse_t::clear () {
179 filterOptions.erase(filterOptions.begin(), filterOptions.end());
180}
181
[220]182
[187]183void OptionValue_t::clear () {
184 name.clear();
185 value.clear();
186}
187
[220]188
[187]189void FilterRequest_t::clear () {
190 filterName.clear();
191 filterOptions.erase(filterOptions.begin(), filterOptions.end());
192 docSet.erase(docSet.begin(), docSet.end());
193 filterResultOptions = 0;
[220]194 requestParams.clear();
195 refParams.clear();
196 fields.erase(fields.begin(), fields.end());
[272]197 getParents = false;
[187]198}
199
[220]200
[187]201void TermInfo_t::clear () {
202 term.clear();
203 freq = 0;
204 matchTerms.erase (matchTerms.begin(), matchTerms.end());
205}
206
[197]207
[220]208void MetadataInfo_t::clear () {
209 params.clear();
210 isRef = false;
[241]211 values.erase(values.begin(), values.end());
[459]212 name.clear();
[220]213}
214
215
[187]216void ResultDocInfo_t::clear () {
217 OID.clear ();
[220]218 ranking = 0;
[353]219 result_num = 0;
[310]220 num_terms_matched = 0;
[348]221 num_phrase_match = 0;
[187]222 docFreq.erase(docFreq.begin(), docFreq.end());
[220]223 metadata.erase(metadata.begin(), metadata.end());
[187]224}
225
[197]226ResultDocInfo_t &ResultDocInfo_t::operator=(const ResultDocInfo_t &x) {
227 OID=x.OID;
[310]228 ranking=x.ranking;
[353]229 result_num=x.result_num;
[310]230 num_terms_matched=x.num_terms_matched;
[348]231 num_phrase_match = x.num_phrase_match;
[197]232 docFreq=x.docFreq;
[220]233 metadata=x.metadata;
[197]234 return *this;
235}
236
237
[187]238void FilterResponse_t::clear () {
[220]239 numDocs = 0;
[398]240 isApprox = Exact;
[187]241 termInfo.erase (termInfo.begin(), termInfo.end());
242 docInfo.erase (docInfo.begin(), docInfo.end());
243}
244
[257]245
246void DocumentRequest_t::clear () {
247 OID.clear();
248 docType.clear();
249 docFormat.clear();
250}
251
252void DocumentResponse_t::clear () {
253 doc.clear();
254}
255
256
257
Note: See TracBrowser for help on using the repository browser.