1 /* -*- c-basic-offset: 2 -*- */ 2 /* 3 Copyright(C) 2014-2018 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; 20 21 22 private static import groonga_d.groonga; 23 24 extern(C): 25 nothrow @nogc: 26 27 /* 28 * grn_tokenize_mode describes propose for tokenization. 29 * 30 * `GRN_TOKENIZE_GET`: Tokenize for search. 31 * 32 * `GRN_TOKENIZE_ADD`: Tokenize for adding token to index. 33 * 34 * `GRN_TOKENIZE_DELETE`: Tokenize for deleting token from index. 35 * 36 * @since 4.0.8 37 */ 38 enum grn_tokenize_mode 39 { 40 GRN_TOKENIZE_GET = 0, 41 GRN_TOKENIZE_ADD, 42 GRN_TOKENIZE_DELETE, 43 GRN_TOKENIZE_ONLY, 44 } 45 46 /* 47 grn_token_mode describes propose for tokenization. 48 49 `GRN_TOKEN_GET`: Tokenization for search. 50 51 `GRN_TOKEN_ADD`: Tokenization for adding token to index. 52 53 `GRN_TOKEN_DEL`: Tokenization for deleting token from index. 54 55 @since 4.0.7 56 @deprecated since 4.0.8. Use grn_tokenize_mode instead. 57 */ 58 alias grn_token_mode = grn_tokenize_mode; 59 60 enum GRN_TOKEN_GET = grn_token_mode.GRN_TOKENIZE_GET; 61 enum GRN_TOKEN_ADD = grn_token_mode.GRN_TOKENIZE_ADD; 62 enum GRN_TOKEN_DEL = grn_token_mode.GRN_TOKENIZE_DELETE; 63 64 /* 65 * grn_token_status is a flag set for tokenizer status codes. 66 * If a document or query contains no tokens, push an empty string with 67 * GRN_TOKEN_LAST as a token. 68 * 69 * @since 4.0.8 70 */ 71 alias grn_token_status = uint; 72 73 /* 74 * GRN_TOKEN_CONTINUE means that the next token is not the last one. 75 * 76 * @since 4.0.8 77 */ 78 enum GRN_TOKEN_CONTINUE = 0; 79 /* 80 * GRN_TOKEN_LAST means that the next token is the last one. 81 * 82 * @since 4.0.8 83 */ 84 enum GRN_TOKEN_LAST = 0x01L << 0; 85 /* 86 * GRN_TOKEN_OVERLAP means that ... 87 * 88 * @since 4.0.8 89 */ 90 enum GRN_TOKEN_OVERLAP = 0x01L << 1; 91 /* 92 * GRN_TOKEN_UNMATURED means that ... 93 * 94 * @since 4.0.8 95 */ 96 enum GRN_TOKEN_UNMATURED = 0x01L << 2; 97 /* 98 * GRN_TOKEN_REACH_END means that ... 99 * 100 * @since 4.0.8 101 */ 102 enum GRN_TOKEN_REACH_END = 0x01L << 3; 103 /* 104 * GRN_TOKEN_SKIP means that the token is skipped 105 * 106 * @since 4.0.8 107 */ 108 enum GRN_TOKEN_SKIP = 0x01L << 4; 109 /* 110 * GRN_TOKEN_SKIP_WITH_POSITION means that the token and postion is skipped 111 * 112 * @since 4.0.8 113 */ 114 enum GRN_TOKEN_SKIP_WITH_POSITION = 0x01L << 5; 115 /* 116 * GRN_TOKEN_FORCE_PREIX that the token is used common prefix search 117 * 118 * @since 4.0.8 119 */ 120 enum GRN_TOKEN_FORCE_PREFIX = 0x01L << 6; 121 122 extern struct _grn_token; 123 alias grn_token = _grn_token; 124 125 //GRN_API 126 groonga_d.groonga.grn_obj* grn_token_get_data(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 127 128 //GRN_API 129 const (char)* grn_token_get_data_raw(groonga_d.groonga.grn_ctx* ctx, grn_token* token, size_t* length); 130 131 //GRN_API 132 groonga_d.groonga.grn_rc grn_token_set_data(groonga_d.groonga.grn_ctx* ctx, grn_token* token, const (char)* str_ptr, int str_length); 133 134 //GRN_API 135 grn_token_status grn_token_get_status(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 136 137 //GRN_API 138 groonga_d.groonga.grn_rc grn_token_set_status(groonga_d.groonga.grn_ctx* ctx, grn_token* token, grn_token_status status); 139 140 //GRN_API 141 ulong grn_token_get_source_offset(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 142 143 //GRN_API 144 groonga_d.groonga.grn_rc grn_token_set_source_offset(groonga_d.groonga.grn_ctx* ctx, grn_token* token, ulong offset); 145 146 //GRN_API 147 uint grn_token_get_source_length(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 148 149 //GRN_API 150 groonga_d.groonga.grn_rc grn_token_set_source_length(groonga_d.groonga.grn_ctx* ctx, grn_token* token, uint length); 151 152 //GRN_API 153 uint grn_token_get_source_first_character_length(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 154 155 //GRN_API 156 groonga_d.groonga.grn_rc grn_token_set_source_first_character_length(groonga_d.groonga.grn_ctx* ctx, grn_token* token, uint length); 157 158 //GRN_API 159 ubyte grn_token_have_overlap(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 160 161 //GRN_API 162 groonga_d.groonga.grn_rc grn_token_set_overlap(groonga_d.groonga.grn_ctx* ctx, grn_token* token, ubyte have_overlap); 163 164 //GRN_API 165 groonga_d.groonga.grn_obj* grn_token_get_metadata(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 166 167 //GRN_API 168 ubyte grn_token_get_force_prefix_search(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 169 170 //GRN_API 171 groonga_d.groonga.grn_rc grn_token_set_force_prefix_search(groonga_d.groonga.grn_ctx* ctx, grn_token* token, ubyte force); 172 173 //GRN_API 174 uint grn_token_get_position(groonga_d.groonga.grn_ctx* ctx, grn_token* token); 175 176 //GRN_API 177 groonga_d.groonga.grn_rc grn_token_set_position(groonga_d.groonga.grn_ctx* ctx, grn_token* token, uint position);