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