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