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

Last change on this file since 353 was 353, checked in by rjmcnab, 25 years ago

Added the result number to the ResultDocInfo_t

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