Make TimeOut objects non-copyable
[xapian.git] / xapian-bindings / xapian-headers.i
blobd3d9e8dc1cfaf107156e84c244db928b9b99ccf9
1 %{
2 /* xapian-headers.i: Getting SWIG to parse Xapian's C++ headers.
4 * Copyright 2004,2006,2011,2012,2013,2014,2015,2016,2017 Olly Betts
5 * Copyright 2014 Assem Chelli
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20 * USA
24 /* Ignore these functions: */
25 %ignore Xapian::iterator_rewind;
26 %ignore Xapian::iterator_valid;
28 /* Ignore anything ending in an underscore, which is for internal use only: */
29 %rename("$ignore", regexmatch$name="_$") "";
31 /* A class which can usefully be subclassed in the target language. */
32 %define SUBCLASSABLE(NS, CLASS)
33 %ignore NS::CLASS::clone;
34 %ignore NS::CLASS::serialise;
35 %ignore NS::CLASS::unserialise;
36 %#ifdef XAPIAN_SWIG_DIRECTORS
37 %feature(director) NS::CLASS;
38 %#endif
39 %enddef
41 /* A class which is only useful to wrap if the target language allows
42 * subclassing of wrapped classes (what SWIG calls "director support").
44 #ifdef XAPIAN_SWIG_DIRECTORS
45 #define SUBCLASSABLE_ONLY(NS, CLASS) SUBCLASSABLE(NS, CLASS)
46 #else
47 #define SUBCLASSABLE_ONLY(NS, CLASS) %ignore NS::CLASS;
48 #endif
50 #ifdef SWIGTCL
51 /* Tcl needs copy constructors it seems. */
52 %define STANDARD_IGNORES(NS, CLASS)
53 %ignore NS::CLASS::internal;
54 %ignore NS::CLASS::CLASS(Internal*);
55 %ignore NS::CLASS::CLASS(Internal&);
56 %ignore NS::CLASS::operator=;
57 %enddef
58 #else
59 %define STANDARD_IGNORES(NS, CLASS)
60 %ignore NS::CLASS::internal;
61 %ignore NS::CLASS::CLASS(Internal*);
62 %ignore NS::CLASS::CLASS(Internal&);
63 %ignore NS::CLASS::operator=;
64 %ignore NS::CLASS::CLASS(const CLASS &);
65 %enddef
66 #endif
68 #ifdef SWIGCSHARP
69 /* In C#, next and prev return the iterator object. */
70 #define INC_OR_DEC(METHOD, OP, NS, CLASS, RET_TYPE) NS::CLASS METHOD() { return OP(*self); }
71 #elif defined SWIGJAVA
72 /* In Java, next and prev return the result of dereferencing the iterator. */
73 #define INC_OR_DEC(METHOD, OP, NS, CLASS, RET_TYPE) RET_TYPE METHOD() { return *(OP(*self)); }
74 #else
75 /* Otherwise, next and prev return void. */
76 #define INC_OR_DEC(METHOD, OP, NS, CLASS, RET_TYPE) void METHOD() { OP(*self); }
77 #endif
79 /* For other languages, SWIG already renames operator() suitably. */
80 #if defined SWIGJAVA || defined SWIGPHP || defined SWIGTCL
81 %rename(apply) *::operator();
82 #elif defined SWIGCSHARP
83 %rename(Apply) *::operator();
84 #endif
86 /* We use %ignore and %extend rather than %rename on operator* so that any
87 * pattern rename used to match local naming conventions applies to
88 * DEREF_METHOD.
90 %define INPUT_ITERATOR_METHODS(NS, CLASS, RET_TYPE, DEREF_METHOD)
91 STANDARD_IGNORES(NS, CLASS)
92 %ignore NS::CLASS::operator++;
93 %ignore NS::CLASS::operator*;
94 %extend NS::CLASS {
95 bool equals(const NS::CLASS & o) const { return *self == o; }
96 RET_TYPE DEREF_METHOD() const { return **self; }
97 INC_OR_DEC(next, ++, NS, CLASS, RET_TYPE)
99 %enddef
101 %define RANDOM_ACCESS_ITERATOR_METHODS(NS, CLASS, RET_TYPE, DEREF_METHOD)
102 INPUT_ITERATOR_METHODS(NS, CLASS, RET_TYPE, DEREF_METHOD)
103 %ignore NS::CLASS::operator--;
104 %ignore NS::CLASS::operator+=;
105 %ignore NS::CLASS::operator-=;
106 %ignore NS::CLASS::operator+;
107 %ignore NS::CLASS::operator-;
108 %extend NS::CLASS {
109 INC_OR_DEC(prev, --, NS, CLASS, RET_TYPE)
111 %enddef
113 %define CONSTANT(TYPE, NS, NAME)
114 %ignore NS::NAME;
115 %constant TYPE NAME = NS::NAME;
116 %enddef
118 /* Ignore these for all classes: */
119 %ignore operator==;
120 %ignore operator!=;
121 %ignore operator<;
122 %ignore operator>;
123 %ignore operator<=;
124 %ignore operator>=;
125 %ignore operator+;
126 %ignore difference_type;
127 %ignore iterator_category;
128 %ignore value_type;
129 %ignore max_size;
130 %ignore swap;
131 %ignore iterator;
132 %ignore const_iterator;
133 %ignore size_type;
134 %ignore unserialise(const char **, const char *);
135 %ignore release();
137 /* These methods won't throw exceptions. */
138 %exception Xapian::major_version "$action"
139 %exception Xapian::minor_version "$action"
140 %exception Xapian::revision "$action"
141 %exception Xapian::version_string "$action"
142 // For XAPIAN_DOCID_BASE_TYPE and XAPIAN_TERMCOUNT_BASE_TYPE:
143 %import <xapian/version.h>
144 %include <xapian.h>
146 // Disable errors about not including headers individually.
147 #define XAPIAN_IN_XAPIAN_H
149 /* We don't wrap the version macros - they're useful for compile time checks
150 * in C++ code, but for a scripting language, the version functions tell us
151 * the version of Xapian we're actually using, which is more interesting than
152 * the one the bindings were built against.
154 /* %include <xapian/version.h> */
156 /* Types are needed by most of the other headers. */
157 %include <xapian/types.h>
159 CONSTANT(int, Xapian, DB_CREATE);
160 CONSTANT(int, Xapian, DB_CREATE_OR_OPEN);
161 CONSTANT(int, Xapian, DB_CREATE_OR_OVERWRITE);
162 CONSTANT(int, Xapian, DB_OPEN);
163 CONSTANT(int, Xapian, DB_NO_SYNC);
164 CONSTANT(int, Xapian, DB_FULL_SYNC);
165 CONSTANT(int, Xapian, DB_DANGEROUS);
166 CONSTANT(int, Xapian, DB_NO_TERMLIST);
167 CONSTANT(int, Xapian, DB_BACKEND_CHERT);
168 CONSTANT(int, Xapian, DB_BACKEND_GLASS);
169 CONSTANT(int, Xapian, DB_BACKEND_INMEMORY);
170 CONSTANT(int, Xapian, DB_BACKEND_STUB);
171 CONSTANT(int, Xapian, DB_RETRY_LOCK);
172 CONSTANT(int, Xapian, DBCHECK_SHORT_TREE);
173 CONSTANT(int, Xapian, DBCHECK_FULL_TREE);
174 CONSTANT(int, Xapian, DBCHECK_SHOW_FREELIST);
175 CONSTANT(int, Xapian, DBCHECK_SHOW_STATS);
176 CONSTANT(int, Xapian, DBCHECK_FIX);
177 CONSTANT(int, Xapian, DBCOMPACT_MULTIPASS);
178 CONSTANT(int, Xapian, DBCOMPACT_NO_RENUMBER);
179 CONSTANT(int, Xapian, DBCOMPACT_SINGLE_FILE);
180 CONSTANT(int, Xapian, DOC_ASSUME_VALID);
181 %include <xapian/constants.h>
183 /* The Error subclasses are handled separately for languages where we wrap
184 * them. */
185 /* %include <xapian/error.h> */
187 INPUT_ITERATOR_METHODS(Xapian, PositionIterator, Xapian::termpos, get_termpos)
188 %include <xapian/positioniterator.h>
190 %ignore Xapian::DocIDWrapper;
191 INPUT_ITERATOR_METHODS(Xapian, PostingIterator, Xapian::docid, get_docid)
192 %include <xapian/postingiterator.h>
194 INPUT_ITERATOR_METHODS(Xapian, TermIterator, std::string, get_term)
195 %include <xapian/termiterator.h>
197 INPUT_ITERATOR_METHODS(Xapian, ValueIterator, std::string, get_value)
198 %include <xapian/valueiterator.h>
200 STANDARD_IGNORES(Xapian, Document)
201 %include <xapian/document.h>
203 STANDARD_IGNORES(Xapian, Registry)
204 %include <xapian/registry.h>
206 STANDARD_IGNORES(Xapian, Query)
207 %ignore Xapian::Query::Internal;
208 %ignore operator Query;
209 %ignore *::operator&(const Xapian::Query &, const Xapian::InvertedQuery_ &);
210 %ignore *::operator~;
211 %ignore *::operator&=;
212 %ignore *::operator|=;
213 %ignore *::operator^=;
214 %ignore *::operator*=;
215 %ignore *::operator/=;
216 #if defined SWIGCSHARP || defined SWIGJAVA || defined SWIGLUA || defined SWIGPHP
217 %ignore *::operator&;
218 %ignore *::operator|;
219 %ignore *::operator^;
220 %ignore *::operator*;
221 %ignore *::operator/;
222 #endif
223 %ignore Xapian::Query::LEAF_TERM;
224 %ignore Xapian::Query::LEAF_POSTING_SOURCE;
225 %ignore Xapian::Query::LEAF_MATCH_ALL;
226 %ignore Xapian::Query::LEAF_MATCH_NOTHING;
228 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::Query::Internal;
229 #if defined SWIGCSHARP || defined SWIGJAVA || defined SWIGPERL || \
230 defined SWIGPYTHON || defined SWIGRUBY
231 // C#, Java, Perl, Python and Ruby wrap these "by hand" to give a nicer API
232 // than SWIG gives by default.
233 %ignore Xapian::Query::MatchAll;
234 %ignore Xapian::Query::MatchNothing;
235 #endif
236 #ifndef XAPIAN_MIXED_SUBQUERIES_BY_ITERATOR_TYPEMAP
237 %ignore Query(op op_, XapianSWIGQueryItor qbegin, XapianSWIGQueryItor qend,
238 Xapian::termcount parameter = 0);
239 #endif
240 %include <xapian/query.h>
242 // Suppress warning that Xapian::Internal::intrusive_base is unknown.
243 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::StemImplementation;
244 SUBCLASSABLE_ONLY(Xapian, StemImplementation)
245 #ifndef XAPIAN_SWIG_DIRECTORS
246 %ignore Xapian::Stem::Stem(Xapian::StemImplementation *);
247 #endif
248 STANDARD_IGNORES(Xapian, Stem)
249 %ignore Xapian::Stem::Stem();
250 %include <xapian/stem.h>
252 STANDARD_IGNORES(Xapian, TermGenerator)
253 %ignore Xapian::TermGenerator::operator=;
254 /* Ignore forms which use Utf8Iterator, as we don't wrap that class. */
255 %ignore Xapian::TermGenerator::index_text(const Xapian::Utf8Iterator &);
256 %ignore Xapian::TermGenerator::index_text(const Xapian::Utf8Iterator &, Xapian::termcount);
257 %ignore Xapian::TermGenerator::index_text(const Xapian::Utf8Iterator &, Xapian::termcount, const std::string &);
258 %ignore Xapian::TermGenerator::index_text_without_positions(const Xapian::Utf8Iterator &);
259 %ignore Xapian::TermGenerator::index_text_without_positions(const Xapian::Utf8Iterator &, Xapian::termcount);
260 %ignore Xapian::TermGenerator::index_text_without_positions(const Xapian::Utf8Iterator &, Xapian::termcount, const std::string &);
261 %ignore Xapian::TermGenerator::TermGenerator(const TermGenerator &);
262 %include <xapian/termgenerator.h>
264 STANDARD_IGNORES(Xapian, MSet)
265 #ifdef SWIGJAVA
266 // For compatibility with the original JNI wrappers.
267 %rename("getElement") Xapian::MSet::operator[];
268 #else
269 %ignore Xapian::MSet::operator[];
270 #endif
271 %extend Xapian::MSet {
272 Xapian::docid get_docid(Xapian::doccount i) const {
273 return *(*self)[i];
276 Xapian::Document get_document(Xapian::doccount i) const {
277 return (*self)[i].get_document();
280 Xapian::MSetIterator get_hit(Xapian::doccount i) const {
281 return (*self)[i];
284 int get_document_percentage(Xapian::doccount i) const {
285 return self->convert_to_percent((*self)[i]);
289 RANDOM_ACCESS_ITERATOR_METHODS(Xapian, MSetIterator, Xapian::docid, get_docid)
291 %include <xapian/mset.h>
293 STANDARD_IGNORES(Xapian, ESet)
294 %ignore Xapian::ESet::operator[];
296 RANDOM_ACCESS_ITERATOR_METHODS(Xapian, ESetIterator, std::string, get_term)
298 %include <xapian/eset.h>
300 STANDARD_IGNORES(Xapian, RSet)
302 %include <xapian/rset.h>
304 SUBCLASSABLE(Xapian, MatchDecider)
306 %include <xapian/matchdecider.h>
308 STANDARD_IGNORES(Xapian, Enquire)
310 #ifdef XAPIAN_TERMITERATOR_PAIR_OUTPUT_TYPEMAP
311 /* Instantiating the template we're going to use avoids SWIG wrapping uses
312 * of it in SwigValueWrapper.
314 %template() std::pair<Xapian::TermIterator, Xapian::TermIterator>;
316 %extend Xapian::Enquire {
317 /* This returns start and end iterators, then a typemap iterates between
318 * those and returns an array of strings in the target language.
320 std::pair<Xapian::TermIterator, Xapian::TermIterator>
321 get_matching_terms(const Xapian::MSetIterator & item) const {
322 return std::make_pair($self->get_matching_terms_begin(item),
323 $self->get_matching_terms_end(item));
326 #endif
328 %include <xapian/enquire.h>
330 SUBCLASSABLE(Xapian, ExpandDecider)
331 // Suppress warning that Xapian::Internal::opt_intrusive_base is unknown.
332 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::ExpandDecider;
333 %ignore Xapian::ExpandDeciderAnd::ExpandDeciderAnd(const ExpandDecider *, const ExpandDecider *);
334 /* FIXME: %extend ExpandDeciderFilterTerms so it can be constructed from an
335 * array of strings (or whatever the equivalent is in the target language).
337 %ignore Xapian::ExpandDeciderFilterTerms;
338 %include <xapian/expanddecider.h>
340 SUBCLASSABLE(Xapian, KeyMaker)
341 // Suppress warning that Xapian::Internal::opt_intrusive_base is unknown.
342 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::KeyMaker;
343 %include <xapian/keymaker.h>
345 %extend Xapian::SimpleStopper {
346 /** Load stop words from a text file (one word per line). */
347 SimpleStopper(const std::string &file) {
348 ifstream in_file(file.c_str());
349 if (!in_file.is_open())
350 throw Xapian::InvalidArgumentError("Stopword file not found: " + file);
351 istream_iterator<std::string> in_iter(in_file);
352 istream_iterator<std::string> eof;
353 return new Xapian::SimpleStopper(in_iter, eof);
357 SUBCLASSABLE(Xapian, FieldProcessor)
358 // Suppress warning that Xapian::Internal::opt_intrusive_base is unknown.
359 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::Stopper;
360 SUBCLASSABLE(Xapian, RangeProcessor)
361 SUBCLASSABLE(Xapian, Stopper)
362 SUBCLASSABLE(Xapian, ValueRangeProcessor)
363 // Suppress warning that Xapian::Internal::opt_intrusive_base is unknown.
364 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::RangeProcessor;
365 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::ValueRangeProcessor;
366 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::FieldProcessor;
367 STANDARD_IGNORES(Xapian, QueryParser)
368 %ignore Xapian::QueryParser::QueryParser(const QueryParser &);
369 CONSTANT(int, Xapian, RP_SUFFIX);
370 CONSTANT(int, Xapian, RP_REPEATED);
371 CONSTANT(int, Xapian, RP_DATE_PREFER_MDY);
372 %include <xapian/queryparser.h>
374 %include <xapian/valuesetmatchdecider.h>
376 /* Xapian::Weight isn't usefully subclassable via the bindings, as clone()
377 * needs to be implemented for it to be usable for weighting a search. But
378 * there are several supplied weighting schemes implemented in C++ which can
379 * usefully be used via the bindings so we wrap those.
381 STANDARD_IGNORES(Xapian, Weight)
382 /* The copy constructor isn't implemented, but is protected rather than
383 * private to work around a compiler bug, so we ignore it explicitly.
385 %ignore Xapian::Weight::Weight(const Weight &);
386 %ignore Xapian::Weight::clone;
387 %ignore Xapian::Weight::serialise;
388 %ignore Xapian::Weight::unserialise;
389 %include <xapian/weight.h>
391 /* We don't wrap Xapian's Unicode support as other languages usually already
392 * have their own Unicode support. */
393 /* %include <xapian/unicode.h> */
395 SUBCLASSABLE(Xapian, Compactor)
396 %include <xapian/compactor.h>
398 SUBCLASSABLE(Xapian, PostingSource)
399 // Suppress warning that Xapian::Internal::opt_intrusive_base is unknown.
400 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::PostingSource;
401 SUBCLASSABLE(Xapian, ValuePostingSource)
402 SUBCLASSABLE(Xapian, ValueWeightPostingSource)
403 %ignore Xapian::PostingSource::unserialise_with_registry;
404 %include <xapian/postingsource.h>
406 // Suppress warning that Xapian::Internal::intrusive_base is unknown.
407 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Xapian::MatchSpy;
408 SUBCLASSABLE(Xapian, MatchSpy)
409 %ignore Xapian::MatchSpy::serialise_results;
410 %include <xapian/matchspy.h>
412 SUBCLASSABLE(Xapian, LatLongMetric)
413 INPUT_ITERATOR_METHODS(Xapian, LatLongCoordsIterator, LatLongCoord, get_coord)
414 %ignore Xapian::LatLongCoord::operator<;
415 %include <xapian/geospatial.h>
417 STANDARD_IGNORES(Xapian, Database)
418 STANDARD_IGNORES(Xapian, WritableDatabase)
419 %ignore Xapian::WritableDatabase::WritableDatabase(Database::Internal *);
420 %ignore Xapian::Database::check(const std::string &, int, std::ostream *);
421 %ignore Xapian::Database::check(int fd, int, std::ostream *);
422 %include <xapian/database.h>
423 %extend Xapian::Database {
424 static size_t check(const std::string &path, int opts = 0) {
425 return Xapian::Database::check(path, opts, opts ? &std::cout : NULL);
429 #if defined SWIGCSHARP || defined SWIGJAVA
431 /* xapian/dbfactory.h is currently wrapped via fake class declarations in
432 * fake_dbfactory.i for C# and Java. */
434 #else
436 %rename("remote_open") Xapian::Remote::open;
437 %rename("remote_open_writable") Xapian::Remote::open_writable;
439 %include <xapian/dbfactory.h>
441 #endif