File: csharp.i

package info (click to toggle)
xapian-bindings 1.4.31-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,456 kB
  • sloc: cpp: 379,927; python: 10,780; cs: 9,529; java: 6,949; sh: 5,017; perl: 4,435; makefile: 1,277; ruby: 1,028; php: 586; tcl: 246
file content (177 lines) | stat: -rw-r--r-- 5,503 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
%module(directors="1") xapian
%{
/* csharp.i: SWIG interface file for the C# bindings
 *
 * Copyright (c) 2005,2006,2008,2009,2011,2012,2018,2019 Olly Betts
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
%}

// Use SWIG directors for C# wrappers.
#define XAPIAN_SWIG_DIRECTORS

%include ../xapian-head.i

// Rename function and method names to match C# conventions (e.g. from
// get_description() to GetDescription()).
%rename("%(camelcase)s",%$isfunction) "";

// Fix up API methods which aren't split by '_' on word boundaries.
%rename("GetTermPos") get_termpos;
%rename("GetTermFreq") get_termfreq;
%rename("GetTermWeight") get_termweight;
%rename("GetDocCount") get_doccount;
%rename("GetDocId") get_docid;
%rename("GetDocLength") get_doclength;
%rename("GetDocumentId") get_document_id;
%rename("PositionListBegin") positionlist_begin;
%rename("PositionListEnd") positionlist_end;
%rename("GetValueNo") get_valueno;
%rename("TermListCount") termlist_count;
%rename("TermListBegin") termlist_begin;
%rename("TermListEnd") termlist_end;
%rename("GetFirstItem") get_firstitem;
%rename("GetSumPart") get_sumpart;
%rename("GetMaxPart") get_maxpart;
%rename("GetSumExtra") get_sumextra;
%rename("GetMaxExtra") get_maxextra;
%rename("PostListBegin") postlist_begin;
%rename("PostListEnd") postlist_end;
%rename("AllTermsBegin") allterms_begin;
%rename("AllTermsEnd") allterms_end;
%rename("GetLastDocId") get_lastdocid;
%rename("GetAvLength") get_avlength;
%rename("StopListBegin") stoplist_begin;
%rename("StopListEnd") stoplist_end;
%rename("GetMSet") get_mset;
%rename("GetESet") get_eset;

%ignore ValueRangeProcessor::operator();

%inline {
namespace Xapian {

// Wrap Xapian::version_string as Xapian.Version.String() as C# can't have
// functions outside a class and we don't want Xapian.Xapian.VersionString()!
class Version {
  private:
    Version();
    ~Version();
  public:
    static const char * String() { return Xapian::version_string(); }
    static int Major() { return Xapian::major_version(); }
    static int Minor() { return Xapian::minor_version(); }
    static int Revision() { return Xapian::revision(); }
};

}
}

namespace Xapian {

%ignore version_string;
%ignore major_version;
%ignore minor_version;
%ignore revision;

%define WRAP_RANDOM_ITERATOR(ITOR)
%typemap(cscode) ITOR %{
    public static ITOR operator++(ITOR it) {
	return it.Next();
    }
    public static ITOR operator--(ITOR it) {
	return it.Prev();
    }
    public override bool Equals(object o) {
	return o is ITOR && Equals((ITOR)o);
    }
    public static bool operator==(ITOR a, ITOR b) {
	if ((object)a == (object)b) return true;
	if ((object)a == null || (object)b == null) return false;
	return a.Equals(b);
    }
    public static bool operator!=(ITOR a, ITOR b) {
	if ((object)a == (object)b) return false;
	if ((object)a == null || (object)b == null) return true;
	return !a.Equals(b);
    }
    // Implementing GetHashCode() to always return 0 is rather lame, but
    // using iterators as keys in a hash table would be rather strange.
    public override int GetHashCode() { return 0; }
%}
%enddef

%define WRAP_INPUT_ITERATOR(ITOR)
%typemap(cscode) ITOR %{
    public static ITOR operator++(ITOR it) {
	return it.Next();
    }
    public override bool Equals(object o) {
	return o is ITOR && Equals((ITOR)o);
    }
    public static bool operator==(ITOR a, ITOR b) {
	if ((object)a == (object)b) return true;
	if ((object)a == null || (object)b == null) return false;
	return a.Equals(b);
    }
    public static bool operator!=(ITOR a, ITOR b) {
	if ((object)a == (object)b) return false;
	if ((object)a == null || (object)b == null) return true;
	return !a.Equals(b);
    }
    // Implementing GetHashCode() to always return 0 is rather lame, but
    // using iterators as keys in a hash table would be rather strange.
    public override int GetHashCode() { return 0; }
%}
%enddef

WRAP_RANDOM_ITERATOR(MSetIterator)
WRAP_RANDOM_ITERATOR(ESetIterator)
WRAP_INPUT_ITERATOR(TermIterator)
WRAP_INPUT_ITERATOR(ValueIterator)
WRAP_INPUT_ITERATOR(PostingIterator)
WRAP_INPUT_ITERATOR(PositionIterator)

%typemap(cscode) class Query %{
  public static readonly Query MatchAll = new Query("");
  public static readonly Query MatchNothing = new Query();
%}

}

// For QueryParser::add_boolean_prefix() and add_rangeprocessor().
%typemap(ctype) const std::string* "char*"
%typemap(imtype) const std::string* "string"
%typemap(cstype) const std::string* "string"

%typemap(in) const std::string* %{
    $*1_ltype $1_str;
    if ($input) {
        $1_str.assign($input);
        $1 = &$1_str;
    } else {
        $1 = nullptr;
    }
%}

%typemap(csin) const std::string* "$csinput"

%typecheck(SWIG_TYPECHECK_STRING) const std::string* ""

%include ../generic/except.i
%include ../xapian-headers.i
%include ../fake_dbfactory.i