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