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

Last change on this file since 1474 was 1330, checked in by kjm18, 24 years ago

added buildType support for mgpp collections. also FRfullTextBrowse added to the
FR* defines.

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