1 /* -*- c-basic-offset: 2 -*- */
2 /*
3   Copyright(C) 2014-2016 Brazil
4   Copyright(C) 2018 Kouhei Sutou <kou@clear-code.com>
5 
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Lesser General Public
8   License version 2.1 as published by the Free Software Foundation.
9 
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14 
15   You should have received a copy of the GNU Lesser General Public
16   License along with this library; if not, write to the Free Software
17   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19 module groonga_d.token_filter;
20 
21 
22 private static import groonga_d.groonga;
23 
24 extern(C):
25 nothrow @nogc:
26 
27 /+
28 #include <groonga/tokenizer.h>
29 +/
30 
31 /* Deprecated since 8.0.9. Use grn_token_filter_init_query_func instead. */
32 //typedef void* grn_token_filter_init_func(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* table, groonga_d.token.grn_tokenize_mode mode);
33 alias grn_token_filter_init_func = extern (C) nothrow @nogc void* function(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* table, groonga_d.token.grn_tokenize_mode mode);
34 
35 //typedef void* grn_token_filter_init_query_func(groonga_d.groonga.grn_ctx* ctx, groonga_d.tokenizer.grn_tokenizer_query* query);
36 alias grn_token_filter_init_query_func = extern (C) nothrow @nogc void* function(groonga_d.groonga.grn_ctx* ctx, groonga_d.tokenizer_query_deprecated.grn_tokenizer_query* query);
37 
38 //typedef void grn_token_filter_filter_func(groonga_d.groonga.grn_ctx* ctx, groonga_d.token.grn_token* current_token, groonga_d.token.grn_token* next_token, void* user_data);
39 alias grn_token_filter_filter_func = extern (C) nothrow @nogc void function(groonga_d.groonga.grn_ctx* ctx, groonga_d.token.grn_token* current_token, groonga_d.token.grn_token* next_token, void* user_data);
40 
41 //typedef void grn_token_filter_fin_func(groonga_d.groonga.grn_ctx* ctx, void* user_data);
42 alias grn_token_filter_fin_func = extern (C) nothrow @nogc void function(groonga_d.groonga.grn_ctx* ctx, void* user_data);
43 
44 /*
45   grn_token_filter_register() registers a plugin to the database which is
46   associated with `ctx'. `plugin_name_ptr' and `plugin_name_length' specify the
47   plugin name. Alphabetic letters ('A'-'Z' and 'a'-'z'), digits ('0'-'9') and
48   an underscore ('_') are capable characters.
49 
50   `init', `filter' and `fin' specify the plugin functions.
51 
52   `init' is called for initializing a token_filter for a document or
53   query.
54 
55   `filter' is called for filtering tokens one by one.
56 
57   `fin' is called for finalizing a token_filter.
58 
59   grn_token_filter_register() returns GRN_SUCCESS on success, an error
60   code on failure.
61 
62   Deprecated since 8.0.9. Use grn_token_filter_create() and
63   grn_token_filter_set_XXX_func() instead.
64  */
65 
66 //GRN_PLUGIN_EXPORT
67 export groonga_d.groonga.grn_rc grn_token_filter_register(groonga_d.groonga.grn_ctx* ctx, const (char)* plugin_name_ptr, int plugin_name_length, grn_token_filter_init_func* init, grn_token_filter_filter_func* filter, grn_token_filter_fin_func* fin);
68 
69 //GRN_PLUGIN_EXPORT
70 export groonga_d.groonga.grn_obj*
71 grn_token_filter_create(groonga_d.groonga.grn_ctx* ctx, const (char)* name, int name_length);
72 
73 //GRN_PLUGIN_EXPORT
74 export groonga_d.groonga.grn_rc
75 grn_token_filter_set_init_func(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* token_filter, grn_token_filter_init_query_func* init);
76 
77 //GRN_PLUGIN_EXPORT
78 export groonga_d.groonga.grn_rc
79 grn_token_filter_set_filter_func(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* token_filter, grn_token_filter_filter_func* filter);
80 
81 //GRN_PLUGIN_EXPORT
82 export groonga_d.groonga.grn_rc
83 grn_token_filter_set_fin_func(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* token_filter, grn_token_filter_fin_func* fin);