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

Last change on this file since 1994 was 1994, checked in by kjm18, 23 years ago

ColInfoResponse_t.isPublic now defaults to true. this means that all
collections are public unless specifically designated private in the
configuration file

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