| 1 | /* |
| 2 | Copyright (C) 2010-2018 Brazil |
| 3 | Copyright (C) 2020-2022 Sutou Kouhei <[email protected]> |
| 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 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include "grn.h" |
| 23 | |
| 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
| 26 | #endif |
| 27 | |
| 28 | extern uint32_t grn_output_auto_flush_interval; |
| 29 | void |
| 30 | grn_output_init_from_env(void); |
| 31 | |
| 32 | GRN_API void |
| 33 | grn_output_result_set_open_metadata(grn_ctx *ctx, |
| 34 | grn_obj *outbuf, |
| 35 | grn_content_type output_type, |
| 36 | grn_obj *result_set, |
| 37 | grn_obj_format *format, |
| 38 | uint32_t n_additional_elements); |
| 39 | GRN_API void |
| 40 | grn_output_result_set_open(grn_ctx *ctx, |
| 41 | grn_obj *outbuf, |
| 42 | grn_content_type output_type, |
| 43 | grn_obj *result_set, |
| 44 | grn_obj_format *format, |
| 45 | uint32_t n_additional_elements); |
| 46 | GRN_API void |
| 47 | grn_output_result_set_close(grn_ctx *ctx, |
| 48 | grn_obj *outbuf, |
| 49 | grn_content_type output_type, |
| 50 | grn_obj *result_set, |
| 51 | grn_obj_format *format); |
| 52 | GRN_API void |
| 53 | grn_output_result_set(grn_ctx *ctx, |
| 54 | grn_obj *outbuf, |
| 55 | grn_content_type output_type, |
| 56 | grn_obj *result_set, |
| 57 | grn_obj_format *format); |
| 58 | GRN_API void |
| 59 | grn_output_table_columns(grn_ctx *ctx, |
| 60 | grn_obj *outbuf, |
| 61 | grn_content_type output_type, |
| 62 | grn_obj *table, |
| 63 | grn_obj_format *format); |
| 64 | GRN_API void |
| 65 | grn_output_table_records_open(grn_ctx *ctx, |
| 66 | grn_obj *outbuf, |
| 67 | grn_content_type output_type, |
| 68 | int n_records); |
| 69 | GRN_API void |
| 70 | grn_output_table_records_content(grn_ctx *ctx, |
| 71 | grn_obj *outbuf, |
| 72 | grn_content_type output_type, |
| 73 | grn_obj *table, |
| 74 | grn_obj_format *format); |
| 75 | GRN_API void |
| 76 | grn_output_table_records_close(grn_ctx *ctx, |
| 77 | grn_obj *outbuf, |
| 78 | grn_content_type output_type); |
| 79 | GRN_API void |
| 80 | grn_output_table_records(grn_ctx *ctx, |
| 81 | grn_obj *outbuf, |
| 82 | grn_content_type output_type, |
| 83 | grn_obj *table, |
| 84 | grn_obj_format *format); |
| 85 | |
| 86 | grn_rc |
| 87 | grn_obj_format_set_columns(grn_ctx *ctx, |
| 88 | grn_obj_format *format, |
| 89 | grn_obj *table, |
| 90 | const char *columns, |
| 91 | unsigned int columns_len); |
| 92 | |
| 93 | #define GRN_OUTPUT_ARRAY_OPEN(name, nelements) \ |
| 94 | (grn_ctx_output_array_open(ctx, name, nelements)) |
| 95 | #define GRN_OUTPUT_ARRAY_CLOSE() (grn_ctx_output_array_close(ctx)) |
| 96 | #define GRN_OUTPUT_MAP_OPEN(name, nelements) \ |
| 97 | (grn_ctx_output_map_open(ctx, name, nelements)) |
| 98 | #define GRN_OUTPUT_MAP_CLOSE() (grn_ctx_output_map_close(ctx)) |
| 99 | #define GRN_OUTPUT_NULL() (grn_ctx_output_null(ctx)) |
| 100 | #define GRN_OUTPUT_INT32(value) (grn_ctx_output_int32(ctx, value)) |
| 101 | #define GRN_OUTPUT_INT64(value) (grn_ctx_output_int64(ctx, value)) |
| 102 | #define GRN_OUTPUT_UINT32(value) (grn_ctx_output_uint32(ctx, value)) |
| 103 | #define GRN_OUTPUT_UINT64(value) (grn_ctx_output_uint64(ctx, value)) |
| 104 | #define GRN_OUTPUT_FLOAT(value) (grn_ctx_output_float(ctx, value)) |
| 105 | #define GRN_OUTPUT_CSTR(value) (grn_ctx_output_cstr(ctx, value)) |
| 106 | #define GRN_OUTPUT_STR(value, value_len) \ |
| 107 | (grn_ctx_output_str(ctx, value, value_len)) |
| 108 | #define GRN_OUTPUT_BOOL(value) (grn_ctx_output_bool(ctx, value)) |
| 109 | #define GRN_OUTPUT_OBJ(obj, format) (grn_ctx_output_obj(ctx, obj, format)) |
| 110 | #define GRN_OUTPUT_RESULT_SET_OPEN_METADATA(result_set, \ |
| 111 | format, \ |
| 112 | n_additional_elements) \ |
| 113 | (grn_ctx_output_result_set_open_metadata(ctx, \ |
| 114 | result_set, \ |
| 115 | format, \ |
| 116 | n_additional_elements)) |
| 117 | #define GRN_OUTPUT_RESULT_SET_OPEN(result_set, format, n_additional_elements) \ |
| 118 | (grn_ctx_output_result_set_open(ctx, \ |
| 119 | result_set, \ |
| 120 | format, \ |
| 121 | n_additional_elements)) |
| 122 | #define GRN_OUTPUT_RESULT_SET_CLOSE(result_set, format) \ |
| 123 | (grn_ctx_output_result_set_close(ctx, result_set, format)) |
| 124 | #define GRN_OUTPUT_RESULT_SET(result_set, format, n_additional_elements) \ |
| 125 | (grn_ctx_output_result_set(ctx, result_set, format, n_additional_elements)) |
| 126 | #define GRN_OUTPUT_TABLE_COLUMNS(table, format) \ |
| 127 | (grn_ctx_output_table_columns(ctx, table, format)) |
| 128 | #define GRN_OUTPUT_TABLE_RECORDS(table, format) \ |
| 129 | (grn_ctx_output_table_records(ctx, table, format)) |
| 130 | |
| 131 | #ifdef __cplusplus |
| 132 | } |
| 133 | #endif |