1 %module
(directors
="1") xapian
3 /* csharp.i
: SWIG interface file for the C# bindings
5 * Copyright
(c
) 2005,2006,2008,2009,2011,2012,2018,2019 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
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
();
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
()!
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
(); }
86 %ignore version_string
;
87 %ignore major_version
;
88 %ignore minor_version
;
91 %define WRAP_RANDOM_ITERATOR
(ITOR
)
92 %typemap
(cscode
) ITOR
%{
93 public static ITOR operator
++(ITOR it
) {
96 public static ITOR operator--
(ITOR it
) {
99 public override bool Equals
(object o
) {
100 return o is ITOR
&& Equals((ITOR)o);
102 public static bool operator
==(ITOR a
, ITOR b
) {
103 if
((object
)a
== (object
)b
) return true
;
104 if
((object
)a
== null ||
(object
)b
== null
) return false
;
107 public static bool operator
!=(ITOR a
, ITOR b
) {
108 if
((object
)a
== (object
)b
) return false
;
109 if
((object
)a
== null ||
(object
)b
== null
) return true
;
112 // Implementing GetHashCode
() to always return
0 is rather lame
, but
113 // using iterators as keys in a hash table would be rather strange.
114 public override int GetHashCode
() { return
0; }
118 %define WRAP_INPUT_ITERATOR
(ITOR
)
119 %typemap
(cscode
) ITOR
%{
120 public static ITOR operator
++(ITOR it
) {
123 public override bool Equals
(object o
) {
124 return o is ITOR
&& Equals((ITOR)o);
126 public static bool operator
==(ITOR a
, ITOR b
) {
127 if
((object
)a
== (object
)b
) return true
;
128 if
((object
)a
== null ||
(object
)b
== null
) return false
;
131 public static bool operator
!=(ITOR a
, ITOR b
) {
132 if
((object
)a
== (object
)b
) return false
;
133 if
((object
)a
== null ||
(object
)b
== null
) return true
;
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; }
142 WRAP_RANDOM_ITERATOR
(MSetIterator
)
143 WRAP_RANDOM_ITERATOR
(ESetIterator
)
144 WRAP_INPUT_ITERATOR
(TermIterator
)
145 WRAP_INPUT_ITERATOR
(ValueIterator
)
146 WRAP_INPUT_ITERATOR
(PostingIterator
)
147 WRAP_INPUT_ITERATOR
(PositionIterator
)
149 %typemap
(cscode
) class Query
%{
150 public static readonly Query MatchAll
= new Query
("");
151 public static readonly Query MatchNothing
= new Query
();
156 // For QueryParser
::add_boolean_prefix
() and add_rangeprocessor
().
157 %typemap
(ctype
) const std
::string
* "char*"
158 %typemap
(imtype
) const std
::string
* "string"
159 %typemap
(cstype
) const std
::string
* "string"
161 %typemap
(in
) const std
::string
* %{
164 $
1_str.assign
($input
);
171 %typemap
(csin
) const std
::string
* "$csinput"
173 %typecheck
(SWIG_TYPECHECK_STRING
) const std
::string
* ""
175 %include ..
/generic
/except.i
176 %include ..
/xapian-headers.i
177 %include ..
/fake_dbfactory.i