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

Last change on this file since 7433 was 7422, checked in by mdewsnip, 20 years ago

(Human Info) Now has language parameter.

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