Add Weight::create() and Weight::create_from_parameters()
[xapian.git] / xapian-bindings / csharp / csharp.i
blob652fb636005be962ea3a8dc86dfec50bd4fb83b3
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 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
23 // In C#, we don't get SWIG_exception in the generated C++ wrapper sources.
24 #define XapianException(TYPE, MSG) SWIG_CSharpException(TYPE, (MSG).c_str())
27 // Use SWIG directors for C# wrappers.
28 #define XAPIAN_SWIG_DIRECTORS
30 %include ../xapian-head.i
32 // Rename function and method names to match C# conventions (e.g. from
33 // get_description() to GetDescription()).
34 %rename("%(camelcase)s",%$isfunction) "";
36 // Fix up API methods which aren't split by '_' on word boundaries.
37 %rename("GetTermPos") get_termpos;
38 %rename("GetTermFreq") get_termfreq;
39 %rename("GetTermWeight") get_termweight;
40 %rename("GetDocCount") get_doccount;
41 %rename("GetDocId") get_docid;
42 %rename("GetDocLength") get_doclength;
43 %rename("GetDocumentId") get_document_id;
44 %rename("PositionListBegin") positionlist_begin;
45 %rename("PositionListEnd") positionlist_end;
46 %rename("GetValueNo") get_valueno;
47 %rename("TermListCount") termlist_count;
48 %rename("TermListBegin") termlist_begin;
49 %rename("TermListEnd") termlist_end;
50 %rename("GetFirstItem") get_firstitem;
51 %rename("GetSumPart") get_sumpart;
52 %rename("GetMaxPart") get_maxpart;
53 %rename("GetSumExtra") get_sumextra;
54 %rename("GetMaxExtra") get_maxextra;
55 %rename("PostListBegin") postlist_begin;
56 %rename("PostListEnd") postlist_end;
57 %rename("AllTermsBegin") allterms_begin;
58 %rename("AllTermsEnd") allterms_end;
59 %rename("GetLastDocId") get_lastdocid;
60 %rename("GetAvLength") get_avlength;
61 %rename("StopListBegin") stoplist_begin;
62 %rename("StopListEnd") stoplist_end;
63 %rename("GetMSet") get_mset;
64 %rename("GetESet") get_eset;
66 %ignore ValueRangeProcessor::operator();
68 %inline {
69 namespace Xapian {
71 // Wrap Xapian::version_string as Xapian.Version.String() as C# can't have
72 // functions outside a class and we don't want Xapian.Xapian.VersionString()!
73 class Version {
74 private:
75 Version();
76 ~Version();
77 public:
78 static const char * String() { return Xapian::version_string(); }
79 static int Major() { return Xapian::major_version(); }
80 static int Minor() { return Xapian::minor_version(); }
81 static int Revision() { return Xapian::revision(); }
87 namespace Xapian {
89 %ignore version_string;
90 %ignore major_version;
91 %ignore minor_version;
92 %ignore revision;
94 %typemap(cscode) class MSetIterator %{
95 public static MSetIterator operator++(MSetIterator it) {
96 return it.Next();
98 public static MSetIterator operator--(MSetIterator it) {
99 return it.Prev();
101 public override bool Equals(object o) {
102 return o is MSetIterator && Equals((MSetIterator)o);
104 public static bool operator==(MSetIterator a, MSetIterator b) {
105 if ((object)a == (object)b) return true;
106 if ((object)a == null || (object)b == null) return false;
107 return a.Equals(b);
109 public static bool operator!=(MSetIterator a, MSetIterator b) {
110 if ((object)a == (object)b) return false;
111 if ((object)a == null || (object)b == null) return true;
112 return !a.Equals(b);
114 // Implementing GetHashCode() to always return 0 is rather lame, but
115 // using iterators as keys in a hash table would be rather strange.
116 public override int GetHashCode() { return 0; }
119 %typemap(cscode) ESetIterator %{
120 public static ESetIterator operator++(ESetIterator it) {
121 return it.Next();
123 public static ESetIterator operator--(ESetIterator it) {
124 return it.Prev();
126 public override bool Equals(object o) {
127 return o is ESetIterator && Equals((ESetIterator)o);
129 public static bool operator==(ESetIterator a, ESetIterator b) {
130 if ((object)a == (object)b) return true;
131 if ((object)a == null || (object)b == null) return false;
132 return a.Equals(b);
134 public static bool operator!=(ESetIterator a, ESetIterator b) {
135 if ((object)a == (object)b) return false;
136 if ((object)a == null || (object)b == null) return true;
137 return !a.Equals(b);
139 // Implementing GetHashCode() to always return 0 is rather lame, but
140 // using iterators as keys in a hash table would be rather strange.
141 public override int GetHashCode() { return 0; }
144 %typemap(cscode) TermIterator %{
145 public static TermIterator operator++(TermIterator it) {
146 return it.Next();
148 public override bool Equals(object o) {
149 return o is TermIterator && Equals((TermIterator)o);
151 public static bool operator==(TermIterator a, TermIterator b) {
152 if ((object)a == (object)b) return true;
153 if ((object)a == null || (object)b == null) return false;
154 return a.Equals(b);
156 public static bool operator!=(TermIterator a, TermIterator b) {
157 if ((object)a == (object)b) return false;
158 if ((object)a == null || (object)b == null) return true;
159 return !a.Equals(b);
161 // Implementing GetHashCode() to always return 0 is rather lame, but
162 // using iterators as keys in a hash table would be rather strange.
163 public override int GetHashCode() { return 0; }
166 %typemap(cscode) ValueIterator %{
167 public static ValueIterator operator++(ValueIterator it) {
168 return it.Next();
170 public override bool Equals(object o) {
171 return o is ValueIterator && Equals((ValueIterator)o);
173 public static bool operator==(ValueIterator a, ValueIterator b) {
174 if ((object)a == (object)b) return true;
175 if ((object)a == null || (object)b == null) return false;
176 return a.Equals(b);
178 public static bool operator!=(ValueIterator a, ValueIterator b) {
179 if ((object)a == (object)b) return false;
180 if ((object)a == null || (object)b == null) return true;
181 return !a.Equals(b);
183 // Implementing GetHashCode() to always return 0 is rather lame, but
184 // using iterators as keys in a hash table would be rather strange.
185 public override int GetHashCode() { return 0; }
188 %typemap(cscode) PostingIterator %{
189 public static PostingIterator operator++(PostingIterator it) {
190 return it.Next();
192 public override bool Equals(object o) {
193 return o is PostingIterator && Equals((PostingIterator)o);
195 public static bool operator==(PostingIterator a, PostingIterator b) {
196 if ((object)a == (object)b) return true;
197 if ((object)a == null || (object)b == null) return false;
198 return a.Equals(b);
200 public static bool operator!=(PostingIterator a, PostingIterator b) {
201 if ((object)a == (object)b) return false;
202 if ((object)a == null || (object)b == null) return true;
203 return !a.Equals(b);
205 // Implementing GetHashCode() to always return 0 is rather lame, but
206 // using iterators as keys in a hash table would be rather strange.
207 public override int GetHashCode() { return 0; }
210 %typemap(cscode) PositionIterator %{
211 public static PositionIterator operator++(PositionIterator it) {
212 return it.Next();
214 public override bool Equals(object o) {
215 return o is PositionIterator && Equals((PositionIterator)o);
217 public static bool operator==(PositionIterator a, PositionIterator b) {
218 if ((object)a == (object)b) return true;
219 if ((object)a == null || (object)b == null) return false;
220 return a.Equals(b);
222 public static bool operator!=(PositionIterator a, PositionIterator b) {
223 if ((object)a == (object)b) return false;
224 if ((object)a == null || (object)b == null) return true;
225 return !a.Equals(b);
227 // Implementing GetHashCode() to always return 0 is rather lame, but
228 // using iterators as keys in a hash table would be rather strange.
229 public override int GetHashCode() { return 0; }
232 %typemap(cscode) class Query %{
233 public static Query MatchAll = new Query("");
234 public static Query MatchNothing = new Query();
239 %define WARN_CSHARP_COVARIANT_RET 842 %enddef
241 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BB2Weight::create_from_parameters;
242 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BM25PlusWeight::create_from_parameters;
243 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BM25Weight::create_from_parameters;
244 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::BoolWeight::create_from_parameters;
245 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::CoordWeight::create_from_parameters;
246 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::DLHWeight::create_from_parameters;
247 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::DPHWeight::create_from_parameters;
248 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::IfB2Weight::create_from_parameters;
249 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::IneB2Weight::create_from_parameters;
250 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::InL2Weight::create_from_parameters;
251 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::LMWeight::create_from_parameters;
252 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::PL2PlusWeight::create_from_parameters;
253 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::PL2Weight::create_from_parameters;
254 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::TfIdfWeight::create_from_parameters;
255 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::TradWeight::create_from_parameters;
256 %warnfilter(WARN_CSHARP_COVARIANT_RET) Xapian::Weight::create_from_parameters;
258 %include ../generic/except.i
259 %include ../xapian-headers.i
260 %include ../fake_dbfactory.i