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

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

Slight change for multiple phrase matching.

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