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

Last change on this file since 1285 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
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 *********************************************************************/
25
26#include "comtypes.h"
27
28
29text_t get_comerror_string (comerror_t err) {
30 if (err == noError) return "no error";
31 else if (err == authenticationFailure) return "authentication failure";
32 else if (err == protocolError) return "protocol error";
33 else if (err == configurationError) return "configuration error";
34 else if (err == systemProblem) return "system problem";
35
36 return "unknown problem";
37}
38
39
40void ShortColInfo_t::clear() {
41 name.clear();
42 host.clear();
43 port = 0;
44}
45
46void ColInfoResponse_t::clear () {
47 shortInfo.clear();
48 isPublic=false;
49 isBeta=false;
50 languages.erase(languages.begin(), languages.end());
51 ccsCols.erase(ccsCols.begin(), ccsCols.end());
52 buildDate=0;
53 numDocs=0;
54 numSections=0;
55 numWords=0;
56 numBytes=0;
57 format.erase(format.begin(), format.end());
58 building.erase(format.begin(), format.end());
59 receptionist.clear();
60}
61
62void InfoFiltersResponse_t::clear () {
63 filterNames.erase(filterNames.begin(), filterNames.end());
64}
65
66
67void InfoFilterOptionsRequest_t::clear () {
68 filterName.clear();
69}
70
71
72void FilterOption_t::clear () {
73 name.clear();
74 type = booleant;
75 repeatable = onePerQuery;
76 defaultValue.clear();
77 validValues.erase(validValues.begin(), validValues.end());
78}
79
80void FilterOption_t::check_defaultValue () {
81 text_tarray::iterator here, end;
82
83 // how the default is interpreted depends on the option type
84 switch (type) {
85 case booleant:
86 case enumeratedt: // has to be one of the validValues
87 here = validValues.begin ();
88 end = validValues.end ();
89 while (here != end) {
90 if (*here == defaultValue) return;
91 here++;
92 }
93
94 break;
95
96 case integert: // has to be in the validValues range
97 if ((validValues.size() >= 2) &&
98 (validValues[0].getint() <= defaultValue.getint()) &&
99 (validValues[1].getint() >= defaultValue.getint()))
100 return;
101 break;
102
103 case stringt: // any value is valid
104 return;
105 }
106
107 // did not find the defaultValue
108 if (validValues.empty()) defaultValue.clear();
109 else defaultValue = validValues[0];
110}
111
112
113bool operator==(const FilterOption_t &x, const FilterOption_t &y) {
114 return ((x.name == y.name) &&
115 (x.type == y.type) &&
116 (x.repeatable == y.repeatable) &&
117 (x.defaultValue == y.defaultValue) &&
118 (x.validValues == y.validValues));
119}
120
121bool operator<(const FilterOption_t &x, const FilterOption_t &y) {
122 return ((x.name < y.name) ||
123 ((x.name == y.name) &&
124 ((x.type < y.type) ||
125 ((x.type == y.type) &&
126 ((x.repeatable < y.repeatable) ||
127 ((x.repeatable == y.repeatable) &&
128 ((x.defaultValue < y.defaultValue) ||
129 ((x.defaultValue == y.defaultValue) &&
130 (x.validValues < y.validValues)))))))));
131}
132
133
134
135void InfoFilterOptionsResponse_t::clear () {
136 filterOptions.erase(filterOptions.begin(), filterOptions.end());
137}
138
139
140void OptionValue_t::clear () {
141 name.clear();
142 value.clear();
143}
144
145
146void FilterRequest_t::clear () {
147 filterName.clear();
148 filterOptions.erase(filterOptions.begin(), filterOptions.end());
149 docSet.erase(docSet.begin(), docSet.end());
150 filterResultOptions = 0;
151 requestParams.clear();
152 refParams.clear();
153 fields.erase(fields.begin(), fields.end());
154 getParents = false;
155}
156
157
158void TermInfo_t::clear () {
159 term.clear();
160 freq = 0;
161 matchTerms.erase (matchTerms.begin(), matchTerms.end());
162}
163
164
165void MetadataInfo_t::clear () {
166 params.clear();
167 isRef = false;
168 values.erase(values.begin(), values.end());
169 if (parent != NULL) {
170 delete parent;
171 parent = NULL;
172 }
173}
174
175MetadataInfo_t::MetadataInfo_t () {parent=NULL;clear();}
176
177// copy constructor
178MetadataInfo_t::MetadataInfo_t (const MetadataInfo_t &x) {
179 params = x.params;
180 isRef = x.isRef;
181 values = x.values;
182 if (x.parent == NULL) parent = NULL;
183 else {
184 parent = new MetadataInfo_t ();
185 *parent = *(x.parent);
186 }
187}
188
189MetadataInfo_t::~MetadataInfo_t () {
190 if (parent != NULL) {
191 delete parent;
192 parent = NULL;
193 }
194}
195
196MetadataInfo_t &MetadataInfo_t::operator=(const MetadataInfo_t &x) {
197 if (&x != this) {
198 params = x.params;
199 isRef = x.isRef;
200 values = x.values;
201 if (x.parent == NULL) parent = NULL;
202 else {
203 parent = new MetadataInfo_t ();
204 *parent = *(x.parent);
205 }
206 }
207 return *this;
208}
209
210void ResultDocInfo_t::clear () {
211 OID.clear ();
212 ranking = 0;
213 result_num = 0;
214 num_terms_matched = 0;
215 num_phrase_match = 0;
216 docFreq.erase(docFreq.begin(), docFreq.end());
217 metadata.erase(metadata.begin(), metadata.end());
218 classifier_metadata_type.erase(classifier_metadata_type.begin(),
219 classifier_metadata_type.end());
220 classifier_metadata_offset = 0;
221
222}
223
224ResultDocInfo_t &ResultDocInfo_t::operator=(const ResultDocInfo_t &x) {
225 OID = x.OID;
226 ranking = x.ranking;
227 result_num = x.result_num;
228 num_terms_matched = x.num_terms_matched;
229 num_phrase_match = x.num_phrase_match;
230 docFreq = x.docFreq;
231 metadata = x.metadata;
232 return *this;
233}
234
235void FilterResponse_t::clear () {
236 numDocs = 0;
237 isApprox = Exact;
238 termInfo.erase (termInfo.begin(), termInfo.end());
239 docInfo.erase (docInfo.begin(), docInfo.end());
240}
241
242FilterResponse_t &FilterResponse_t::operator=(const FilterResponse_t &x) {
243 numDocs = x.numDocs;
244 isApprox = x.isApprox;
245 termInfo = x.termInfo;
246 docInfo = x.docInfo;
247 return *this;
248}
249
250void DocumentRequest_t::clear () {
251 OID.clear();
252 docType.clear();
253 docFormat.clear();
254}
255
256void DocumentResponse_t::clear () {
257 doc.clear();
258}
Note: See TracBrowser for help on using the repository browser.