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

Last change on this file since 398 was 398, checked in by sjboddie, 25 years ago

changed isApprox

  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/**********************************************************************
2 *
3 * comtypes.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: comtypes.cpp 398 1999-07-16 03:42:23Z sjboddie $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.14 1999/07/16 03:41:29 sjboddie
15 changed isApprox
16
17 Revision 1.13 1999/07/08 20:46:45 rjmcnab
18 Added the result number to the ResultDocInfo_t
19
20 Revision 1.12 1999/07/07 06:11:33 rjmcnab
21 Slight change for multiple phrase matching.
22
23 Revision 1.11 1999/07/01 22:47:49 sjboddie
24 added format option to collection info
25
26 Revision 1.10 1999/06/29 22:05:01 rjmcnab
27 Added a couple of fields to ResultDocInfo_t to handle a special
28 version of mg.
29
30 Revision 1.9 1999/06/16 02:01:22 sjboddie
31 Few changes to get getParents filter option to return metadata of parents
32 as well as current OID
33
34 Revision 1.8 1999/05/10 03:40:33 sjboddie
35 lots of changes - slowly getting document action sorted out
36
37 Revision 1.7 1999/04/21 05:23:14 sjboddie
38
39 Changed the way metadata is returned
40
41 Revision 1.6 1999/04/06 22:20:34 rjmcnab
42 Got browsefilter working.
43
44 Revision 1.5 1999/03/31 23:44:47 rjmcnab
45 Altered the protocol so that the metadata is part of the filter.
46
47 Revision 1.4 1999/03/11 00:11:19 rjmcnab
48 Added a function to get a string version of comerror_t
49
50 Revision 1.3 1999/03/09 21:00:47 rjmcnab
51 Reorganised the statusaction, added more functions to comtypes.
52
53 Revision 1.2 1999/03/04 21:19:15 rjmcnab
54
55 Added clear() functions to all the data types.
56
57 Revision 1.1 1999/02/21 22:35:25 rjmcnab
58
59 Initial revision.
60
61 */
62
63
64#include "comtypes.h"
65
66
67text_t get_comerror_string (comerror_t err) {
68 if (err == noError) return "no error";
69 else if (err == authenticationFailure) return "authentication failure";
70 else if (err == protocolError) return "protocol error";
71 else if (err == configurationError) return "configuration error";
72 else if (err == systemProblem) return "system problem";
73
74 return "unknown problem";
75}
76
77
78void ShortColInfo_t::clear() {
79 name.clear();
80 host.clear();
81 port = 0;
82}
83
84void ColInfoResponse_t::clear () {
85 shortInfo.clear();
86 isPublic=false;
87 isBeta=false;
88 buildDate=0;
89 numDocs=0;
90 numWords=0;
91 numBytes=0;
92 format.erase(format.begin(), format.end());
93}
94
95void InfoFiltersResponse_t::clear () {
96 filterNames.erase(filterNames.begin(), filterNames.end());
97}
98
99
100void InfoFilterOptionsRequest_t::clear () {
101 filterName.clear();
102}
103
104
105void FilterOption_t::clear () {
106 name.clear();
107 type = booleant;
108 repeatable = onePerQuery;
109 defaultValue.clear();
110 validValues.erase(validValues.begin(), validValues.end());
111}
112
113void FilterOption_t::check_defaultValue () {
114 text_tarray::iterator here, end;
115
116 // how the default is interpreted depends on the option type
117 switch (type) {
118 case booleant:
119 case enumeratedt: // has to be one of the validValues
120 here = validValues.begin ();
121 end = validValues.end ();
122 while (here != end) {
123 if (*here == defaultValue) return;
124 here++;
125 }
126
127 break;
128
129 case integert: // has to be in the validValues range
130 if ((validValues.size() >= 2) &&
131 (validValues[0].getint() <= defaultValue.getint()) &&
132 (validValues[1].getint() >= defaultValue.getint()))
133 return;
134 break;
135
136 case stringt: // any value is valid
137 return;
138 }
139
140 // did not find the defaultValue
141 if (validValues.empty()) defaultValue.clear();
142 else defaultValue = validValues[0];
143}
144
145
146void InfoFilterOptionsResponse_t::clear () {
147 filterOptions.erase(filterOptions.begin(), filterOptions.end());
148}
149
150
151void OptionValue_t::clear () {
152 name.clear();
153 value.clear();
154}
155
156
157void FilterRequest_t::clear () {
158 filterName.clear();
159 filterOptions.erase(filterOptions.begin(), filterOptions.end());
160 docSet.erase(docSet.begin(), docSet.end());
161 filterResultOptions = 0;
162 requestParams.clear();
163 refParams.clear();
164 fields.erase(fields.begin(), fields.end());
165 getParents = false;
166}
167
168
169void TermInfo_t::clear () {
170 term.clear();
171 freq = 0;
172 matchTerms.erase (matchTerms.begin(), matchTerms.end());
173}
174
175
176void MetadataInfo_t::clear () {
177 params.clear();
178 isRef = false;
179 values.erase(values.begin(), values.end());
180}
181
182
183void ResultDocInfo_t::clear () {
184 OID.clear ();
185 ranking = 0;
186 result_num = 0;
187 num_terms_matched = 0;
188 num_phrase_match = 0;
189 docFreq.erase(docFreq.begin(), docFreq.end());
190 metadata.erase(metadata.begin(), metadata.end());
191}
192
193ResultDocInfo_t &ResultDocInfo_t::operator=(const ResultDocInfo_t &x) {
194 OID=x.OID;
195 ranking=x.ranking;
196 result_num=x.result_num;
197 num_terms_matched=x.num_terms_matched;
198 num_phrase_match = x.num_phrase_match;
199 docFreq=x.docFreq;
200 metadata=x.metadata;
201 return *this;
202}
203
204
205void FilterResponse_t::clear () {
206 numDocs = 0;
207 isApprox = Exact;
208 termInfo.erase (termInfo.begin(), termInfo.end());
209 docInfo.erase (docInfo.begin(), docInfo.end());
210}
211
212
213void DocumentRequest_t::clear () {
214 OID.clear();
215 docType.clear();
216 docFormat.clear();
217}
218
219void DocumentResponse_t::clear () {
220 doc.clear();
221}
222
223
224
Note: See TracBrowser for help on using the repository browser.