[honey] Fix portability to systems without pread()
[xapian.git] / xapian-bindings / csharp / csharp.i
blobd0eecd5528ed7afe5ad2d3d617b11ae4d18c18d0
1 %module(directors="1") xapian
2 %{
3 /* csharp.i: SWIG interface file for the C# bindings
5 * Copyright (c) 2005,2006,2008,2009,2011,2012,2018 Olly Betts
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 // Use SWIG directors for C# wrappers.
25 #define XAPIAN_SWIG_DIRECTORS
27 %include ../xapian-head.i
29 // Rename function and method names to match C# conventions (e.g. from
30 // get_description() to GetDescription()).
31 %rename("%(camelcase)s",%$isfunction) "";
33 // Fix up API methods which aren't split by '_' on word boundaries.
34 %rename("GetTermPos") get_termpos;
35 %rename("GetTermFreq") get_termfreq;
36 %rename("GetTermWeight") get_termweight;
37 %rename("GetDocCount") get_doccount;
38 %rename("GetDocId") get_docid;
39 %rename("GetDocLength") get_doclength;
40 %rename("GetDocumentId") get_document_id;
41 %rename("PositionListBegin") positionlist_begin;
42 %rename("PositionListEnd") positionlist_end;
43 %rename("GetValueNo") get_valueno;
44 %rename("TermListCount") termlist_count;
45 %rename("TermListBegin") termlist_begin;
46 %rename("TermListEnd") termlist_end;
47 %rename("GetFirstItem") get_firstitem;
48 %rename("GetSumPart") get_sumpart;
49 %rename("GetMaxPart") get_maxpart;
50 %rename("GetSumExtra") get_sumextra;
51 %rename("GetMaxExtra") get_maxextra;
52 %rename("PostListBegin") postlist_begin;
53 %rename("PostListEnd") postlist_end;
54 %rename("AllTermsBegin") allterms_begin;
55 %rename("AllTermsEnd") allterms_end;
56 %rename("GetLastDocId") get_lastdocid;
57 %rename("GetAvLength") get_avlength;
58 %rename("StopListBegin") stoplist_begin;
59 %rename("StopListEnd") stoplist_end;
60 %rename("GetMSet") get_mset;
61 %rename("GetESet") get_eset;
63 %ignore ValueRangeProcessor::operator();
65 %inline {
66 namespace Xapian {
68 // Wrap Xapian::version_string as Xapian.Version.String() as C# can't have
69 // functions outside a class and we don't want Xapian.Xapian.VersionString()!
70 class Version {
71 private:
72 Version();
73 ~Version();
74 public:
75 static const char * String() { return Xapian::version_string(); }
76 static int Major() { return Xapian::major_version(); }
77 static int Minor() { return Xapian::minor_version(); }
78 static int Revision() { return Xapian::revision(); }
84 namespace Xapian {
86 %ignore version_string;
87 %ignore major_version;
88 %ignore minor_version;
89 %ignore revision;
91 %typemap(cscode) class MSetIterator %{
92 public static MSetIterator operator++(MSetIterator it) {
93 return it.Next();
95 public static MSetIterator operator--(MSetIterator it) {
96 return it.Prev();
98 public override bool Equals(object o) {
99 return o is MSetIterator && Equals((MSetIterator)o);
101 public static bool operator==(MSetIterator a, MSetIterator b) {
102 if ((object)a == (object)b) return true;
103 if ((object)a == null || (object)b == null) return false;
104 return a.Equals(b);
106 public static bool operator!=(MSetIterator a, MSetIterator b) {
107 if ((object)a == (object)b) return false;
108 if ((object)a == null || (object)b == null) return true;
109 return !a.Equals(b);
111 // Implementing GetHashCode() to always return 0 is rather lame, but
112 // using iterators as keys in a hash table would be rather strange.
113 public override int GetHashCode() { return 0; }
116 %typemap(cscode) ESetIterator %{
117 public static ESetIterator operator++(ESetIterator it) {
118 return it.Next();
120 public static ESetIterator operator--(ESetIterator it) {
121 return it.Prev();
123 public override bool Equals(object o) {
124 return o is ESetIterator && Equals((ESetIterator)o);
126 public static bool operator==(ESetIterator a, ESetIterator b) {
127 if ((object)a == (object)b) return true;
128 if ((object)a == null || (object)b == null) return false;
129 return a.Equals(b);
131 public static bool operator!=(ESetIterator a, ESetIterator b) {
132 if ((object)a == (object)b) return false;
133 if ((object)a == null || (object)b == null) return true;
134 return !a.Equals(b);
136 // Implementing GetHashCode() to always return 0 is rather lame, but
137 // using iterators as keys in a hash table would be rather strange.
138 public override int GetHashCode() { return 0; }
141 %typemap(cscode) TermIterator %{
142 public static TermIterator operator++(TermIterator it) {
143 return it.Next();
145 public override bool Equals(object o) {
146 return o is TermIterator && Equals((TermIterator)o);
148 public static bool operator==(TermIterator a, TermIterator b) {
149 if ((object)a == (object)b) return true;
150 if ((object)a == null || (object)b == null) return false;
151 return a.Equals(b);
153 public static bool operator!=(TermIterator a, TermIterator b) {
154 if ((object)a == (object)b) return false;
155 if ((object)a == null || (object)b == null) return true;
156 return !a.Equals(b);
158 // Implementing GetHashCode() to always return 0 is rather lame, but
159 // using iterators as keys in a hash table would be rather strange.
160 public override int GetHashCode() { return 0; }
163 %typemap(cscode) ValueIterator %{
164 public static ValueIterator operator++(ValueIterator it) {
165 return it.Next();
167 public override bool Equals(object o) {
168 return o is ValueIterator && Equals((ValueIterator)o);
170 public static bool operator==(ValueIterator a, ValueIterator b) {
171 if ((object)a == (object)b) return true;
172 if ((object)a == null || (object)b == null) return false;
173 return a.Equals(b);
175 public static bool operator!=(ValueIterator a, ValueIterator b) {
176 if ((object)a == (object)b) return false;
177 if ((object)a == null || (object)b == null) return true;
178 return !a.Equals(b);
180 // Implementing GetHashCode() to always return 0 is rather lame, but
181 // using iterators as keys in a hash table would be rather strange.
182 public override int GetHashCode() { return 0; }
185 %typemap(cscode) PostingIterator %{
186 public static PostingIterator operator++(PostingIterator it) {
187 return it.Next();
189 public override bool Equals(object o) {
190 return o is PostingIterator && Equals((PostingIterator)o);
192 public static bool operator==(PostingIterator a, PostingIterator b) {
193 if ((object)a == (object)b) return true;
194 if ((object)a == null || (object)b == null) return false;
195 return a.Equals(b);
197 public static bool operator!=(PostingIterator a, PostingIterator b) {
198 if ((object)a == (object)b) return false;
199 if ((object)a == null || (object)b == null) return true;
200 return !a.Equals(b);
202 // Implementing GetHashCode() to always return 0 is rather lame, but
203 // using iterators as keys in a hash table would be rather strange.
204 public override int GetHashCode() { return 0; }
207 %typemap(cscode) PositionIterator %{
208 public static PositionIterator operator++(PositionIterator it) {
209 return it.Next();
211 public override bool Equals(object o) {
212 return o is PositionIterator && Equals((PositionIterator)o);
214 public static bool operator==(PositionIterator a, PositionIterator b) {
215 if ((object)a == (object)b) return true;
216 if ((object)a == null || (object)b == null) return false;
217 return a.Equals(b);
219 public static bool operator!=(PositionIterator a, PositionIterator b) {
220 if ((object)a == (object)b) return false;
221 if ((object)a == null || (object)b == null) return true;
222 return !a.Equals(b);
224 // Implementing GetHashCode() to always return 0 is rather lame, but
225 // using iterators as keys in a hash table would be rather strange.
226 public override int GetHashCode() { return 0; }
229 %typemap(cscode) class Query %{
230 public static Query MatchAll = new Query("");
231 public static Query MatchNothing = new Query();
236 %define WARN_CSHARP_COVARIANT_RET 842 %enddef
238 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BB2Weight::create_from_parameters;
239 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BM25PlusWeight::create_from_parameters;
240 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BM25Weight::create_from_parameters;
241 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BoolWeight::create_from_parameters;
242 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::CoordWeight::create_from_parameters;
243 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::DLHWeight::create_from_parameters;
244 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::DPHWeight::create_from_parameters;
245 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::IfB2Weight::create_from_parameters;
246 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::IneB2Weight::create_from_parameters;
247 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::InL2Weight::create_from_parameters;
248 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::LMWeight::create_from_parameters;
249 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::PL2PlusWeight::create_from_parameters;
250 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::PL2Weight::create_from_parameters;
251 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::TfIdfWeight::create_from_parameters;
252 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::TradWeight::create_from_parameters;
253 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::Weight::create_from_parameters;
255 %include ../generic/except.i
256 %include ../xapian-headers.i
257 %include ../fake_dbfactory.i