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

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

Added a couple of fields to ResultDocInfo_t to handle a special
version of mg.

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