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