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 private static import groonga_d.token; 24 private static import groonga_d.tokenizer; 25 private static import groonga_d.tokenizer_query_deprecated; 26 27 extern(C): 28 nothrow @nogc: 29 30 /+ 31 #include <groonga/tokenizer.h> 32 +/ 33 34 /* Deprecated since 8.0.9. Use grn_token_filter_init_query_func instead. */ 35 //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); 36 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); 37 38 //typedef void* grn_token_filter_init_query_func(groonga_d.groonga.grn_ctx* ctx, groonga_d.tokenizer.grn_tokenizer_query* query); 39 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); 40 41 //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); 42 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); 43 44 //typedef void grn_token_filter_fin_func(groonga_d.groonga.grn_ctx* ctx, void* user_data); 45 alias grn_token_filter_fin_func = extern (C) nothrow @nogc void function(groonga_d.groonga.grn_ctx* ctx, void* user_data); 46 47 /* 48 grn_token_filter_register() registers a plugin to the database which is 49 associated with `ctx'. `plugin_name_ptr' and `plugin_name_length' specify the 50 plugin name. Alphabetic letters ('A'-'Z' and 'a'-'z'), digits ('0'-'9') and 51 an underscore ('_') are capable characters. 52 53 `init', `filter' and `fin' specify the plugin functions. 54 55 `init' is called for initializing a token_filter for a document or 56 query. 57 58 `filter' is called for filtering tokens one by one. 59 60 `fin' is called for finalizing a token_filter. 61 62 grn_token_filter_register() returns GRN_SUCCESS on success, an error 63 code on failure. 64 65 Deprecated since 8.0.9. Use grn_token_filter_create() and 66 grn_token_filter_set_XXX_func() instead. 67 */ 68 69 //GRN_PLUGIN_EXPORT 70 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); 71 72 //GRN_PLUGIN_EXPORT 73 export groonga_d.groonga.grn_obj* 74 grn_token_filter_create(groonga_d.groonga.grn_ctx* ctx, const (char)* name, int name_length); 75 76 //GRN_PLUGIN_EXPORT 77 export groonga_d.groonga.grn_rc 78 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); 79 80 //GRN_PLUGIN_EXPORT 81 export groonga_d.groonga.grn_rc 82 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); 83 84 //GRN_PLUGIN_EXPORT 85 export groonga_d.groonga.grn_rc 86 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);