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

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

added ability to set receptionist from configuration files

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