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