1 /* 2 Copyright(C) 2009-2018 Brazil 3 Copyright(C) 2018 Kouhei Sutou <kou@clear-code.com> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 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.output; 20 21 22 private static import groonga_d.groonga; 23 24 extern(C): 25 nothrow @nogc: 26 27 alias grn_obj_format = _grn_obj_format; 28 29 enum GRN_OBJ_FORMAT_WITH_COLUMN_NAMES = 0x01 << 0; 30 enum GRN_OBJ_FORMAT_AS_ARRAY = 0x01 << 3; 31 /* Deprecated since 4.0.1. It will be removed at 5.0.0. 32 Use GRN_OBJ_FORMAT_AS_ARRAY instead.*/ 33 enum GRN_OBJ_FORMAT_ASARRAY = GRN_OBJ_FORMAT_AS_ARRAY; 34 enum GRN_OBJ_FORMAT_WITH_WEIGHT = 0x01 << 4; 35 36 struct _grn_obj_format 37 { 38 groonga_d.groonga.grn_obj columns; 39 const (void)* min; 40 const (void)* max; 41 uint min_size; 42 uint max_size; 43 int nhits; 44 int offset; 45 int limit; 46 int hits_offset; 47 int flags; 48 groonga_d.groonga.grn_obj* expression; 49 } 50 51 //GRN_API 52 groonga_d.groonga.grn_rc grn_output_range_normalize(groonga_d.groonga.grn_ctx* ctx, int size, int* offset, int* limit); 53 54 /+ 55 #define GRN_OBJ_FORMAT_INIT(format, format_nhits, format_offset, format_limit, format_hits_offset) GRN_PTR_INIT(&(format)->columns, groonga_d.groonga.GRN_OBJ_VECTOR, groonga_d.groonga.GRN_ID_NIL); (format)->nhits = (format_nhits); (format)->offset = (format_offset); (format)->limit = (format_limit); (format)->hits_offset = (format_hits_offset); (format)->flags = 0; (format)->expression = null; 56 57 #define GRN_OBJ_FORMAT_FIN(ctx, format) int ncolumns = groonga_d.groonga.GRN_BULK_VSIZE(&(format)->columns) / sizeof(groonga_d.groonga.grn_obj *); groonga_d.groonga.grn_obj **columns = (groonga_d.groonga.grn_obj **)groonga_d.groonga.GRN_BULK_HEAD(&(format)->columns); while (ncolumns--) { groonga_d.groonga.grn_obj *column = *columns; columns++; if (grn_obj_is_accessor((ctx), column)) { grn_obj_close((ctx), column); } } GRN_OBJ_FIN((ctx), &(format)->columns); if ((format)->expression) { GRN_OBJ_FIN((ctx), (format)->expression); } 58 +/ 59 60 //GRN_API 61 void grn_output_obj(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, groonga_d.groonga.grn_obj* obj, grn_obj_format* format); 62 63 //GRN_API 64 void grn_output_envelope(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_rc rc, groonga_d.groonga.grn_obj* head, groonga_d.groonga.grn_obj* body, groonga_d.groonga.grn_obj* foot, const (char)* file, int line); 65 66 //GRN_API 67 void grn_output_array_open(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, const (char)* name, int n_elements); 68 69 //GRN_API 70 void grn_output_array_close(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type); 71 72 //GRN_API 73 void grn_output_map_open(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, const (char)* name, int n_elements); 74 75 //GRN_API 76 void grn_output_map_close(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type); 77 78 //GRN_API 79 void grn_output_null(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type); 80 81 //GRN_API 82 void grn_output_int32(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, int value); 83 84 //GRN_API 85 void grn_output_uint32(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, uint value); 86 87 //GRN_API 88 void grn_output_int64(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, long value); 89 90 //GRN_API 91 void grn_output_uint64(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, ulong value); 92 93 //GRN_API 94 void grn_output_float(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, double value); 95 96 //GRN_API 97 void grn_output_cstr(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, const (char)* value); 98 99 //GRN_API 100 void grn_output_str(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, const (char)* value, size_t value_len); 101 102 //GRN_API 103 void grn_output_bool(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* outbuf, groonga_d.groonga.grn_content_type output_type, ubyte value); 104 105 //GRN_API 106 void grn_ctx_output_flush(groonga_d.groonga.grn_ctx* ctx, int flags); 107 108 //GRN_API 109 void grn_ctx_output_array_open(groonga_d.groonga.grn_ctx* ctx, const (char)* name, int nelements); 110 111 //GRN_API 112 void grn_ctx_output_array_close(groonga_d.groonga.grn_ctx* ctx); 113 114 //GRN_API 115 void grn_ctx_output_map_open(groonga_d.groonga.grn_ctx* ctx, const (char)* name, int nelements); 116 117 //GRN_API 118 void grn_ctx_output_map_close(groonga_d.groonga.grn_ctx* ctx); 119 120 //GRN_API 121 void grn_ctx_output_null(groonga_d.groonga.grn_ctx* ctx); 122 123 //GRN_API 124 void grn_ctx_output_int32(groonga_d.groonga.grn_ctx* ctx, int value); 125 126 //GRN_API 127 void grn_ctx_output_uint32(groonga_d.groonga.grn_ctx* ctx, uint value); 128 129 //GRN_API 130 void grn_ctx_output_int64(groonga_d.groonga.grn_ctx* ctx, long value); 131 132 //GRN_API 133 void grn_ctx_output_uint64(groonga_d.groonga.grn_ctx* ctx, ulong value); 134 135 //GRN_API 136 void grn_ctx_output_float(groonga_d.groonga.grn_ctx* ctx, double value); 137 138 //GRN_API 139 void grn_ctx_output_cstr(groonga_d.groonga.grn_ctx* ctx, const (char)* value); 140 141 //GRN_API 142 void grn_ctx_output_str(groonga_d.groonga.grn_ctx* ctx, const (char)* value, uint value_len); 143 144 //GRN_API 145 void grn_ctx_output_bool(groonga_d.groonga.grn_ctx* ctx, ubyte value); 146 147 //GRN_API 148 void grn_ctx_output_obj(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* value, grn_obj_format* format); 149 150 //GRN_API 151 void grn_ctx_output_result_set_open(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* result_set, grn_obj_format* format, uint n_additional_elements); 152 153 //GRN_API 154 void grn_ctx_output_result_set_close(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* result_set, grn_obj_format* format); 155 156 //GRN_API 157 void grn_ctx_output_result_set(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* result_set, grn_obj_format* format); 158 159 //GRN_API 160 void grn_ctx_output_table_columns(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* table, grn_obj_format* format); 161 162 //GRN_API 163 void grn_ctx_output_table_records(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* table, grn_obj_format* format); 164 165 //GRN_API 166 groonga_d.groonga.grn_content_type grn_ctx_get_output_type(groonga_d.groonga.grn_ctx* ctx); 167 168 //GRN_API 169 groonga_d.groonga.grn_rc grn_ctx_set_output_type(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_content_type type); 170 171 //GRN_API 172 const (char)* grn_ctx_get_mime_type(groonga_d.groonga.grn_ctx* ctx); 173 174 /* obsolete */ 175 176 //GRN_API 177 groonga_d.groonga.grn_rc grn_text_otoj(groonga_d.groonga.grn_ctx* ctx, groonga_d.groonga.grn_obj* bulk, groonga_d.groonga.grn_obj* obj, grn_obj_format* format);