source: trunk/greenorg/src/recpt/comtypes.cpp@ 9483

Last change on this file since 9483 was 5503, checked in by sjboddie, 21 years ago

* empty log message *

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