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

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

added name attribute to metadata

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