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

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

lots of changes - slowly getting document action sorted out

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