1 /* 2 Copyright(C) 2009-2018 Brazil 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, write to the Free Software 16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 module groonga_d.string_; 19 20 21 private static import groonga_d.groonga; 22 23 extern(C): 24 nothrow @nogc: 25 26 /* grn_str: deprecated. use grn_string instead. */ 27 28 struct grn_str 29 { 30 const (char)* orig; 31 char* norm; 32 short* checks; 33 ubyte* ctypes; 34 int flags; 35 uint orig_blen; 36 uint norm_blen; 37 uint length; 38 groonga_d.groonga.grn_encoding encoding; 39 } 40 41 enum GRN_STR_REMOVEBLANK = 0x01 << 0; 42 enum GRN_STR_WITH_CTYPES = 0x01 << 1; 43 enum GRN_STR_WITH_CHECKS = 0x01 << 2; 44 enum GRN_STR_NORMALIZE = groonga_d.groonga.GRN_OBJ_KEY_NORMALIZE; 45 46 //GRN_API 47 grn_str* grn_str_open(groonga_d.groonga.grn_ctx* ctx, const (char)* str, uint str_len, int flags); 48 49 //GRN_API 50 groonga_d.groonga.grn_rc grn_str_close(groonga_d.groonga.grn_ctx* ctx, grn_str* nstr); 51 52 /* grn_string */ 53 54 enum GRN_STRING_REMOVE_BLANK = 0x01 << 0; 55 enum GRN_STRING_WITH_TYPES = 0x01 << 1; 56 enum GRN_STRING_WITH_CHECKS = 0x01 << 2; 57 enum GRN_STRING_REMOVE_TOKENIZED_DELIMITER = 0x01 << 3; 58 59 /+ 60 #define GRN_NORMALIZER_AUTO (cast(groonga_d.groonga.grn_obj *)(1)) 61 +/ 62 63 enum GRN_CHAR_BLANK = 0x80; 64 65 /+ 66 #define GRN_CHAR_IS_BLANK(c) ((c) & (GRN_CHAR_BLANK)) 67 #define GRN_CHAR_TYPE(c) ((c) & 0x7F) 68 +/ 69 70 enum grn_char_type 71 { 72 GRN_CHAR_NULL = 0, 73 GRN_CHAR_ALPHA, 74 GRN_CHAR_DIGIT, 75 GRN_CHAR_SYMBOL, 76 GRN_CHAR_HIRAGANA, 77 GRN_CHAR_KATAKANA, 78 GRN_CHAR_KANJI, 79 GRN_CHAR_OTHERS, 80 GRN_CHAR_EMOJI, 81 } 82 83 //GRN_API 84 const (char)* grn_char_type_to_string(grn_char_type type); 85 86 //GRN_API 87 groonga_d.groonga.grn_obj* grn_string_open(groonga_d.groonga.grn_ctx* ctx, const (char)* string, uint length_in_bytes, groonga_d.groonga.grn_obj* lexicon_or_normalizer, int flags); 88 89 //GRN_API 90 groonga_d.groonga.grn_rc grn_string_get_original(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string, const (char)** original, uint* length_in_bytes); 91 92 //GRN_API 93 int grn_string_get_flags(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string); 94 95 //GRN_API 96 groonga_d.groonga.grn_rc grn_string_get_normalized(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string, const (char)** normalized, uint* length_in_bytes, uint* n_characters); 97 98 //GRN_API 99 groonga_d.groonga.grn_rc grn_string_set_normalized(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string, char* normalized, uint length_in_bytes, uint n_characters); 100 101 //GRN_API 102 const (short)* grn_string_get_checks(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string); 103 104 //GRN_API 105 groonga_d.groonga.grn_rc grn_string_set_checks(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string, short* checks); 106 107 //GRN_API 108 const (ubyte)* grn_string_get_types(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string); 109 110 //GRN_API 111 groonga_d.groonga.grn_rc grn_string_set_types(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string, ubyte* types); 112 113 //GRN_API 114 const (ulong)* grn_string_get_offsets(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string); 115 116 //GRN_API 117 groonga_d.groonga.grn_rc grn_string_set_offsets(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string, ulong* offsets); 118 119 //GRN_API 120 groonga_d.groonga.grn_encoding grn_string_get_encoding(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string); 121 122 //GRN_API 123 groonga_d.groonga.grn_obj* grn_string_get_table(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* string); 124 125 //GRN_API 126 int grn_charlen(groonga_d.groonga.grn_ctx* ctx, const (char)* str, const (char)* end);