[15416] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * comtypes.h --
|
---|
| 4 | * Copyright (C) 1999,2004 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
| 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
| 9 | *
|
---|
| 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
| 24 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #ifndef COMTYPES_H
|
---|
| 28 | #define COMTYPES_H
|
---|
| 29 |
|
---|
| 30 | #include "gsdlconf.h"
|
---|
| 31 | #include "text_t.h"
|
---|
| 32 |
|
---|
| 33 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 34 | # include <ospace\std\vector>
|
---|
| 35 | # include <ospace\std\list>
|
---|
| 36 | # include <ospace\std\memory> // for pair
|
---|
| 37 | # include <ospace\std\map>
|
---|
| 38 | #elif defined(GSDL_USE_STL_H)
|
---|
| 39 | # include <vector.h>
|
---|
| 40 | # include <list.h>
|
---|
| 41 | # include <memory.h> // for pair
|
---|
| 42 | # include <map.h>
|
---|
| 43 | #else
|
---|
| 44 | # include <vector>
|
---|
| 45 | # include <list>
|
---|
| 46 | # include <memory> // for pair
|
---|
| 47 | # include <map>
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 |
|
---|
[31903] | 51 | const text_t OAI_EARLIESTTIMESTAMP_OID = "earliesttimestamp";
|
---|
| 52 | // https://www.tutorialspoint.com/cplusplus/cpp_constants_literals.htm
|
---|
| 53 |
|
---|
[15416] | 54 | enum comerror_t {noError, authenticationFailure, protocolError,
|
---|
| 55 | configurationError, systemProblem, syntaxError};
|
---|
| 56 | text_t get_comerror_string (comerror_t err);
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | // ShortColInfo ::= SEQUENCE {
|
---|
| 60 | // name GeneralString,
|
---|
| 61 | // host GeneralString,
|
---|
| 62 | // port INTEGER
|
---|
| 63 | // }
|
---|
| 64 | struct ShortColInfo_t {
|
---|
| 65 | void clear ();
|
---|
| 66 | ShortColInfo_t () {clear();}
|
---|
| 67 |
|
---|
| 68 | text_t name;
|
---|
| 69 | text_t host;
|
---|
| 70 | int port;
|
---|
| 71 | };
|
---|
| 72 |
|
---|
| 73 | // for collection metadata: metadata name -> lang -> value
|
---|
| 74 | // for collection macros: macro name -> params -> value
|
---|
| 75 | typedef map<text_t, text_tmap, lttext_t> collectionmeta_map;
|
---|
| 76 |
|
---|
| 77 | #define CCSUniformSearchResultsFormatting 1
|
---|
| 78 |
|
---|
| 79 | #define SIcasefold 1
|
---|
| 80 | #define SIstem 2
|
---|
| 81 | #define SIaccentfold 4
|
---|
| 82 |
|
---|
| 83 | struct ColInfoResponse_t {
|
---|
| 84 | void clear ();
|
---|
| 85 | ColInfoResponse_t () {clear();}
|
---|
| 86 | text_t get_collectionmeta(text_t name, text_t lang);
|
---|
| 87 |
|
---|
| 88 | ShortColInfo_t shortInfo;
|
---|
| 89 | bool useBook; //whether we want to display the book
|
---|
| 90 | bool isPublic;
|
---|
| 91 | bool isBeta;
|
---|
| 92 | bool isSegmented;
|
---|
| 93 | bool isCollectGroup; // used to group a set of collections as one item on the home page
|
---|
| 94 | unsigned long buildDate;
|
---|
| 95 | text_tarray ccsCols; // empty if collection does not use cross-collection searching
|
---|
| 96 | int ccsOptions; // uses CCS #defines from above
|
---|
| 97 | int stemIndexes; // uses SI #defines from above
|
---|
| 98 | text_tarray languages;
|
---|
| 99 | unsigned long numDocs; // 0 if not known
|
---|
| 100 | unsigned long numSections; // 0 if not known
|
---|
| 101 | unsigned long numWords; // 0 if not known
|
---|
| 102 | unsigned long numBytes; // 0 if not known
|
---|
| 103 | collectionmeta_map collectionmeta;
|
---|
| 104 | text_tmap format;
|
---|
| 105 | collectionmeta_map collection_macros; // for collectionmacro config directive (> gsdl 2.53)
|
---|
| 106 | text_tmap building;
|
---|
| 107 | text_t httpdomain; // GRB: could these two http items need removing
|
---|
| 108 | text_t httpprefix;
|
---|
| 109 | text_t receptionist;
|
---|
| 110 | text_t buildType; // 'mg' or 'mgpp' or 'lucene'
|
---|
[22050] | 111 | text_t infodbType; // 'gdbm', 'sqlite', etc.
|
---|
| 112 | text_t authenticate; // 'document' or 'collection'
|
---|
[15416] | 113 | text_t auth_group; // 'mygroup' 'yourgroup'
|
---|
| 114 | text_tmap public_documents; // the acl to allow access to listed documents
|
---|
| 115 | text_tmap private_documents; // the acl to disallow access to listed documents
|
---|
[15771] | 116 | text_tmap dynamic_classifiers;
|
---|
[24114] | 117 | text_t earliestDatestamp; // For OAIserver validation. Time since linux Epoch, expressed as (long) integer value in string form
|
---|
[31903] | 118 | // This field stored the builddate value from a collection's index/build.cfg file.
|
---|
| 119 | // This field earliestDatestamp was used when oaiaction.calcEarliestDatestamp() needed to
|
---|
| 120 | // determine the earliest timestamp of the repository, by selecting the earliestDatestamp among
|
---|
| 121 | // all oai collections. Now it's no longer used by OAI, as that resorts to consulting oai-inf.db
|
---|
| 122 | // of each collection, which has a collection's earliest timestamp stored, to work out the
|
---|
| 123 | // earliest timestamp among all collections. But the build.cfg builddate stored in the
|
---|
| 124 | // earliestDatestamp field may still be useful in future for some purpose, so leaving it alone.
|
---|
| 125 |
|
---|
[15416] | 126 | };
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | // -- filter options which might be supported for the QueryFilter
|
---|
| 130 | // --
|
---|
| 131 | // -- onePerQuery StartResults integer
|
---|
| 132 | // -- onePerQuery EndResults integer
|
---|
| 133 | // -- onePerQuery QueryType enumerated (boolean, ranked)
|
---|
| 134 | // -- onePerTerm Term string ???
|
---|
| 135 | // -- onePerTerm Casefold boolean
|
---|
| 136 | // -- onePerTerm Stem boolean
|
---|
| 137 | // -- onePerTerm Index enumerated
|
---|
| 138 | // -- onePerTerm Subcollection enumerated
|
---|
| 139 | // --
|
---|
| 140 | // -- filter options which might be supported for the BrowseFilter
|
---|
| 141 | // --
|
---|
| 142 | // -- onePerQuery StartResults integer
|
---|
| 143 | // -- onePerQuery EndResults integer
|
---|
| 144 | // -- onePerQuery ParentNode string ("" will return the browsing available)
|
---|
| 145 | // --
|
---|
| 146 | // -- The NullFilter always returns the set it was given, it doesn't have
|
---|
| 147 | // -- any options
|
---|
| 148 |
|
---|
| 149 | // InfoFiltersResponse ::= SEQUENCE {
|
---|
| 150 | // filterNames StringSet
|
---|
| 151 | // }
|
---|
| 152 | struct InfoFiltersResponse_t {
|
---|
| 153 | void clear ();
|
---|
| 154 |
|
---|
| 155 | text_tset filterNames;
|
---|
| 156 | };
|
---|
| 157 |
|
---|
| 158 | // InfoFilterOptionsRequest ::= SEQUENCE {
|
---|
| 159 | // filterName GeneralString
|
---|
| 160 | // }
|
---|
| 161 | struct InfoFilterOptionsRequest_t {
|
---|
| 162 | void clear ();
|
---|
| 163 |
|
---|
| 164 | text_t filterName;
|
---|
| 165 | };
|
---|
| 166 |
|
---|
| 167 | // FilterOption ::= SEQUENCE {
|
---|
| 168 | // name GeneralString,
|
---|
| 169 | // type ENUMERATED {booleant(0), integert(1), enumeratedt(2), stringt(3)},
|
---|
| 170 | // repeatable ENUMERATED {onePerQuery(0), onePerTerm(1), nPerTerm(2)},
|
---|
| 171 | // defaultValue GeneralString,
|
---|
| 172 | // -- the interpretation of the validValues depends on the type
|
---|
| 173 | // -- for boolean: the first value is the false value, the second is true value
|
---|
| 174 | // -- for integer: the first value is the minimum, the second the maximum
|
---|
| 175 | // -- for enumerated: all values a listed
|
---|
| 176 | // -- for string: this value is ignored
|
---|
| 177 | // validValues StringSequence
|
---|
| 178 | // }
|
---|
| 179 | struct FilterOption_t {
|
---|
| 180 | void clear ();
|
---|
| 181 | void check_defaultValue ();
|
---|
| 182 | FilterOption_t () {clear();}
|
---|
| 183 |
|
---|
| 184 | text_t name;
|
---|
| 185 |
|
---|
| 186 | enum type_t {booleant=0, integert=1, enumeratedt=2, stringt=3};
|
---|
| 187 | type_t type;
|
---|
| 188 |
|
---|
| 189 | enum repeatable_t {onePerQuery=0, onePerTerm=1, nPerTerm=2};
|
---|
| 190 | repeatable_t repeatable;
|
---|
| 191 |
|
---|
| 192 | text_t defaultValue;
|
---|
| 193 | text_tarray validValues;
|
---|
| 194 | };
|
---|
| 195 |
|
---|
| 196 | bool operator==(const FilterOption_t &x, const FilterOption_t &y);
|
---|
| 197 | bool operator<(const FilterOption_t &x, const FilterOption_t &y);
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | typedef map<text_t, FilterOption_t, lttext_t> FilterOption_tmap;
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | // InfoFilterOptionsResponse ::= SEQUENCE {
|
---|
| 204 | // filterOptions SET OF FilterOption
|
---|
| 205 | // }
|
---|
| 206 | struct InfoFilterOptionsResponse_t {
|
---|
| 207 | void clear ();
|
---|
| 208 |
|
---|
| 209 | FilterOption_tmap filterOptions;
|
---|
| 210 | };
|
---|
| 211 |
|
---|
| 212 |
|
---|
| 213 | // OptionValue ::= SEQUENCE {
|
---|
| 214 | // name GeneralString,
|
---|
| 215 | // value GeneralString
|
---|
| 216 | // }
|
---|
| 217 | struct OptionValue_t {
|
---|
| 218 | void clear ();
|
---|
| 219 |
|
---|
| 220 | text_t name;
|
---|
| 221 | text_t value;
|
---|
| 222 | };
|
---|
| 223 |
|
---|
| 224 | typedef vector<OptionValue_t> OptionValue_tarray;
|
---|
| 225 |
|
---|
| 226 |
|
---|
| 227 | // -- Terms are presented in the same order that they are requested,
|
---|
| 228 | // -- any information relating to the terms is in reference to the
|
---|
| 229 | // -- index specified for that term.
|
---|
| 230 | //
|
---|
| 231 | // FilterRequest ::= SEQUENCE {
|
---|
| 232 | // filterName [0] GeneralString,
|
---|
| 233 | // filterOptions [1] IMPLICIT SEQUENCE OF OptionValue,
|
---|
| 234 | // docSet [2] IMPLICIT StringSequence, -- the OID "" represents everything
|
---|
| 235 | // filterResultOptions [3] IMPLICIT BIT STRING {termFreq(0), matchTerms(1), OID(2),
|
---|
| 236 | // subCol(3), ranking(4), docFreq(5),
|
---|
| 237 | // metadata(6)}
|
---|
| 238 | //
|
---|
| 239 | // -- the next set of options are for the metadata request,
|
---|
| 240 | // -- they can be left blank if metadata is not wanted
|
---|
| 241 | // requestParams [4] IMPLICIT GeneralString, -- used to negotiate the metadata content
|
---|
| 242 | // refParams [5] IMPLICIT GeneralString, -- used to decide whether to return a
|
---|
| 243 | // -- reference to the data or the actual data
|
---|
| 244 | // fields [6] IMPLICIT StringSet
|
---|
| 245 | // getParents [7] IMPLICIT BOOLEAN -- gets metadata of all parents too
|
---|
| 246 | // }
|
---|
| 247 | #define FRtermFreq 1
|
---|
| 248 | #define FRmatchTerms 2
|
---|
| 249 | #define FROID 4
|
---|
| 250 | #define FRsubCol 8
|
---|
| 251 | #define FRranking 16
|
---|
| 252 | #define FRdocFreq 32
|
---|
| 253 | #define FRmetadata 64
|
---|
| 254 | // used to indicate a full text browse query for mgpp
|
---|
| 255 | #define FRfullTextBrowse 128
|
---|
[31387] | 256 | #define FROAI 256
|
---|
[15416] | 257 |
|
---|
| 258 | struct FilterRequest_t {
|
---|
| 259 | void clear ();
|
---|
| 260 | FilterRequest_t () {clear();}
|
---|
| 261 |
|
---|
| 262 | text_t filterName;
|
---|
| 263 | text_t filterLang; // non empty if we want info to be retrived in language specific
|
---|
| 264 | OptionValue_tarray filterOptions;
|
---|
| 265 | text_tarray docSet; // empty if not used
|
---|
| 266 | int filterResultOptions; // use the FR* defines above
|
---|
| 267 |
|
---|
| 268 | text_t requestParams; // empty if not used
|
---|
| 269 | text_t refParams; // empty if not used
|
---|
| 270 | text_tset fields; // empty if not used
|
---|
| 271 | bool getParents; // defaults to false
|
---|
| 272 | };
|
---|
| 273 |
|
---|
| 274 |
|
---|
| 275 | // TermInfo ::= SEQUENCE {
|
---|
| 276 | // term [0] GeneralString,
|
---|
| 277 | // freq [1] IMPLICIT INTEGER, -- 0 if not requested
|
---|
| 278 | // matchTerms [2] IMPLICIT StringSequence -- empty if not requested
|
---|
| 279 | // }
|
---|
| 280 | struct TermInfo_t {
|
---|
| 281 | void clear ();
|
---|
| 282 | TermInfo_t () {clear();}
|
---|
| 283 |
|
---|
| 284 | text_t term;
|
---|
| 285 | int freq; // 0 if not requested
|
---|
| 286 | text_tarray matchTerms; // empty if not requested
|
---|
| 287 | };
|
---|
| 288 |
|
---|
| 289 | typedef vector<TermInfo_t> TermInfo_tarray;
|
---|
| 290 |
|
---|
| 291 |
|
---|
| 292 | // MetadataInfo ::= SEQUENCE {
|
---|
| 293 | // params [0] IMPLICIT GeneralString,
|
---|
| 294 | // isRef [1] IMPLICIT BOOLEAN,
|
---|
| 295 | // values [3] IMPLICIT SEQUENCE OF GeneralString,
|
---|
| 296 | // name [4] IMPLICIT GeneralString
|
---|
| 297 | // }
|
---|
| 298 | struct MetadataInfo_t {
|
---|
| 299 | text_t params;
|
---|
| 300 | bool isRef;
|
---|
| 301 | text_tarray values;
|
---|
| 302 | MetadataInfo_t *parent;
|
---|
| 303 |
|
---|
| 304 | void clear ();
|
---|
| 305 | MetadataInfo_t ();
|
---|
| 306 | MetadataInfo_t (const MetadataInfo_t &x); // copy constructor
|
---|
| 307 | ~MetadataInfo_t ();
|
---|
| 308 | MetadataInfo_t &operator=(const MetadataInfo_t &x);
|
---|
| 309 | };
|
---|
| 310 |
|
---|
| 311 | typedef map<text_t, MetadataInfo_t, lttext_t> MetadataInfo_tmap;
|
---|
| 312 |
|
---|
| 313 | // ResultDocInfo ::= SEQUENCE {
|
---|
| 314 | // OID [0] IMPLICIT GeneralString,
|
---|
| 315 | // ranking [1] IMPLICIT INTEGER, -- 0 if not requested, range 0-10000
|
---|
| 316 | // docFreq [2] IMPLICIT SEQUENCE OF INTEGER, -- empty if not requested
|
---|
| 317 | // metadata [3] IMPLICIT SEQUENCE OF MetadataInfo, -- no longer a SEQUENCE (SET maybe??)
|
---|
| 318 | // classifier_metadata_type [4] IMPLICIT GeneralString, -- empty if not requested
|
---|
| 319 | // classifier_metadata_offset [5] IMPLICIT INTEGER, -- 0 if not requested
|
---|
| 320 | // }
|
---|
| 321 | struct ResultDocInfo_t {
|
---|
| 322 | void clear ();
|
---|
| 323 | ResultDocInfo_t () {clear();}
|
---|
| 324 |
|
---|
| 325 | text_t OID;
|
---|
| 326 | int result_num; // place in results list
|
---|
| 327 | int ranking; // 0 if not requested (real ranking*10000)
|
---|
| 328 | int num_terms_matched; // not available on all versions of mg
|
---|
| 329 | int num_phrase_match; // not available on all versions of mg
|
---|
| 330 | vector<int> docFreq; // empty if not requested
|
---|
| 331 | MetadataInfo_tmap metadata; // empty if not requested
|
---|
| 332 | text_t classifier_metadata_type; // empty if not requested
|
---|
| 333 | int classifier_metadata_offset; // 0 if not requested
|
---|
| 334 | ResultDocInfo_t &operator=(const ResultDocInfo_t &x);
|
---|
| 335 | };
|
---|
| 336 |
|
---|
| 337 | typedef vector<ResultDocInfo_t> ResultDocInfo_tarray;
|
---|
| 338 |
|
---|
| 339 |
|
---|
| 340 | // FilterResponse ::= SEQUENCE {
|
---|
| 341 | // numDocs [0] IMPLICIT INTEGER,
|
---|
| 342 | // isApprox [1] ENUMERATED {Exact(0), Approximate(1), MoreThan(2)}, -- whether numDocs is approximate
|
---|
| 343 | // termInfo [2] IMPLICIT SEQUENCE OF TermInfo, -- empty if not required
|
---|
| 344 | // docInfo [3] IMPLICIT SEQUENCE OF ResultDocInfo -- empty if not required
|
---|
| 345 | // }
|
---|
| 346 |
|
---|
| 347 | enum isapprox {Exact=0, Approximate=1, MoreThan=2};
|
---|
| 348 |
|
---|
| 349 | struct FilterResponse_t {
|
---|
| 350 | void clear ();
|
---|
| 351 | FilterResponse_t () {clear();}
|
---|
| 352 |
|
---|
| 353 | text_t error_message; // Currently only used by Lucene
|
---|
| 354 | int numDocs;
|
---|
| 355 | isapprox isApprox;
|
---|
| 356 | TermInfo_tarray termInfo; // empty if not requested
|
---|
| 357 | ResultDocInfo_tarray docInfo; // empty if not requested
|
---|
| 358 | text_tset stopwords;
|
---|
| 359 |
|
---|
| 360 | FilterResponse_t &operator=(const FilterResponse_t &x);
|
---|
| 361 | };
|
---|
| 362 |
|
---|
| 363 |
|
---|
| 364 | // DocumentRequest ::= SEQUENCE {
|
---|
| 365 | // OID GeneralString,
|
---|
| 366 | // docType GeneralString,
|
---|
| 367 | // docFormat GeneralString
|
---|
| 368 | // }
|
---|
| 369 | struct DocumentRequest_t {
|
---|
| 370 | void clear ();
|
---|
| 371 | DocumentRequest_t () {clear();}
|
---|
| 372 |
|
---|
| 373 | text_t OID;
|
---|
| 374 | text_t docType;
|
---|
| 375 | text_t docFormat;
|
---|
| 376 | };
|
---|
| 377 |
|
---|
| 378 |
|
---|
| 379 | // DocumentResponse ::= SEQUENCE {
|
---|
| 380 | // doc OCTET STRING
|
---|
| 381 | // }
|
---|
| 382 |
|
---|
| 383 | struct DocumentResponse_t {
|
---|
| 384 | void clear ();
|
---|
| 385 | DocumentResponse_t () {clear();}
|
---|
| 386 |
|
---|
| 387 | text_t doc;
|
---|
| 388 | };
|
---|
| 389 |
|
---|
| 390 |
|
---|
| 391 | #endif
|
---|
| 392 |
|
---|