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