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

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

added format option to collection info

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