Kouhei Sutou
null+****@clear*****
Fri Feb 6 10:17:51 JST 2015
Kouhei Sutou 2015-02-06 10:17:51 +0900 (Fri, 06 Feb 2015) New Revision: 47f1e49bc27a4babe1168cc166c1e29e50b49d9e https://github.com/groonga/groonga/commit/47f1e49bc27a4babe1168cc166c1e29e50b49d9e Message: Extract output related declarations into other header Added files: include/groonga/output.h Modified files: include/groonga.h include/groonga/Makefile.am include/groonga/groonga.h Modified: include/groonga.h (+2 -1) =================================================================== --- include/groonga.h 2015-02-05 19:14:12 +0900 (115b954) +++ include/groonga.h 2015-02-06 10:17:51 +0900 (86e514e) @@ -1,5 +1,5 @@ /* - Copyright(C) 2014 Brazil + Copyright(C) 2014-2015 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -21,6 +21,7 @@ #include "groonga/groonga.h" #include "groonga/ii.h" #include "groonga/expr.h" +#include "groonga/output.h" #include "groonga/util.h" #include "groonga/request_canceler.h" Modified: include/groonga/Makefile.am (+1 -0) =================================================================== --- include/groonga/Makefile.am 2015-02-05 19:14:12 +0900 (ffdb083) +++ include/groonga/Makefile.am 2015-02-06 10:17:51 +0900 (d984f26) @@ -4,6 +4,7 @@ groonga_include_HEADERS = \ expr.h \ groonga.h \ ii.h \ + output.h \ plugin.h \ request_canceler.h \ token.h \ Modified: include/groonga/groonga.h (+0 -72) =================================================================== --- include/groonga/groonga.h 2015-02-05 19:14:12 +0900 (3e89629) +++ include/groonga/groonga.h 2015-02-06 10:17:51 +0900 (88a0908) @@ -1265,82 +1265,10 @@ GRN_API grn_rc grn_text_printf(grn_ctx *ctx, grn_obj *bulk, GRN_API grn_rc grn_text_vprintf(grn_ctx *ctx, grn_obj *bulk, const char *format, va_list args); -typedef struct _grn_obj_format grn_obj_format; - -#define GRN_OBJ_FORMAT_WITH_COLUMN_NAMES (0x01<<0) -#define GRN_OBJ_FORMAT_AS_ARRAY (0x01<<3) -/* Deprecated since 4.0.1. It will be remov****@5*****. - Use GRN_OBJ_FORMAT_AS_ARRAY instead.*/ -#define GRN_OBJ_FORMAT_ASARRAY GRN_OBJ_FORMAT_AS_ARRAY -#define GRN_OBJ_FORMAT_WITH_WEIGHT (0x01<<4) - -struct _grn_obj_format { - grn_obj columns; - const void *min; - const void *max; - unsigned int min_size; - unsigned int max_size; - int nhits; - int offset; - int limit; - int hits_offset; - int flags; - grn_obj *expression; -}; - -#define GRN_OBJ_FORMAT_INIT(format,format_nhits,format_offset,format_limit,format_hits_offset) do { \ - GRN_PTR_INIT(&(format)->columns, GRN_OBJ_VECTOR, 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;\ -} while (0) - -#define GRN_OBJ_FORMAT_FIN(ctx,format) do {\ - int ncolumns = GRN_BULK_VSIZE(&(format)->columns) / sizeof(grn_obj *);\ - grn_obj **columns = (grn_obj **)GRN_BULK_HEAD(&(format)->columns);\ - while (ncolumns--) { grn_obj_unlink((ctx), *columns++); }\ - GRN_OBJ_FIN((ctx), &(format)->columns);\ - if ((format)->expression) { GRN_OBJ_FIN((ctx), (format)->expression); } \ -} while (0) - -GRN_API void grn_output_obj(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type, - grn_obj *obj, grn_obj_format *format); -GRN_API void grn_output_envelope(grn_ctx *ctx, grn_rc rc, - grn_obj *head, grn_obj *body, grn_obj *foot, - const char *file, int line); - -GRN_API void grn_ctx_output_flush(grn_ctx *ctx, int flags); -GRN_API void grn_ctx_output_array_open(grn_ctx *ctx, - const char *name, int nelements); -GRN_API void grn_ctx_output_array_close(grn_ctx *ctx); -GRN_API void grn_ctx_output_map_open(grn_ctx *ctx, - const char *name, int nelements); -GRN_API void grn_ctx_output_map_close(grn_ctx *ctx); -GRN_API void grn_ctx_output_int32(grn_ctx *ctx, int value); -GRN_API void grn_ctx_output_int64(grn_ctx *ctx, long long int value); -GRN_API void grn_ctx_output_float(grn_ctx *ctx, double value); -GRN_API void grn_ctx_output_cstr(grn_ctx *ctx, const char *value); -GRN_API void grn_ctx_output_str(grn_ctx *ctx, - const char *value, unsigned int value_len); -GRN_API void grn_ctx_output_bool(grn_ctx *ctx, grn_bool value); -GRN_API void grn_ctx_output_obj(grn_ctx *ctx, - grn_obj *value, grn_obj_format *format); - - -GRN_API grn_content_type grn_ctx_get_output_type(grn_ctx *ctx); -GRN_API grn_rc grn_ctx_set_output_type(grn_ctx *ctx, grn_content_type type); -GRN_API const char *grn_ctx_get_mime_type(grn_ctx *ctx); GRN_API void grn_ctx_recv_handler_set(grn_ctx *, void (*func)(grn_ctx *, int, void *), void *func_arg); -/* obsolete */ -GRN_API grn_rc grn_text_otoj(grn_ctx *ctx, grn_obj *bulk, grn_obj *obj, - grn_obj_format *format); - /* various values exchanged via grn_obj */ #define GRN_OBJ_DO_SHALLOW_COPY (GRN_OBJ_REFER|GRN_OBJ_OUTPLACE) Added: include/groonga/output.h (+102 -0) 100644 =================================================================== --- /dev/null +++ include/groonga/output.h 2015-02-06 10:17:51 +0900 (ccdc252) @@ -0,0 +1,102 @@ +/* + Copyright(C) 2009-2015 Brazil + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef GROONGA_OUTPUT_H +#define GROONGA_OUTPUT_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _grn_obj_format grn_obj_format; + +#define GRN_OBJ_FORMAT_WITH_COLUMN_NAMES (0x01<<0) +#define GRN_OBJ_FORMAT_AS_ARRAY (0x01<<3) +/* Deprecated since 4.0.1. It will be remov****@5*****. + Use GRN_OBJ_FORMAT_AS_ARRAY instead.*/ +#define GRN_OBJ_FORMAT_ASARRAY GRN_OBJ_FORMAT_AS_ARRAY +#define GRN_OBJ_FORMAT_WITH_WEIGHT (0x01<<4) + +struct _grn_obj_format { + grn_obj columns; + const void *min; + const void *max; + unsigned int min_size; + unsigned int max_size; + int nhits; + int offset; + int limit; + int hits_offset; + int flags; + grn_obj *expression; +}; + +#define GRN_OBJ_FORMAT_INIT(format,format_nhits,format_offset,format_limit,format_hits_offset) do { \ + GRN_PTR_INIT(&(format)->columns, GRN_OBJ_VECTOR, 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;\ +} while (0) + +#define GRN_OBJ_FORMAT_FIN(ctx,format) do {\ + int ncolumns = GRN_BULK_VSIZE(&(format)->columns) / sizeof(grn_obj *);\ + grn_obj **columns = (grn_obj **)GRN_BULK_HEAD(&(format)->columns);\ + while (ncolumns--) { grn_obj_unlink((ctx), *columns++); }\ + GRN_OBJ_FIN((ctx), &(format)->columns);\ + if ((format)->expression) { GRN_OBJ_FIN((ctx), (format)->expression); } \ +} while (0) + +GRN_API void grn_output_obj(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type, + grn_obj *obj, grn_obj_format *format); +GRN_API void grn_output_envelope(grn_ctx *ctx, grn_rc rc, + grn_obj *head, grn_obj *body, grn_obj *foot, + const char *file, int line); + +GRN_API void grn_ctx_output_flush(grn_ctx *ctx, int flags); +GRN_API void grn_ctx_output_array_open(grn_ctx *ctx, + const char *name, int nelements); +GRN_API void grn_ctx_output_array_close(grn_ctx *ctx); +GRN_API void grn_ctx_output_map_open(grn_ctx *ctx, + const char *name, int nelements); +GRN_API void grn_ctx_output_map_close(grn_ctx *ctx); +GRN_API void grn_ctx_output_int32(grn_ctx *ctx, int value); +GRN_API void grn_ctx_output_int64(grn_ctx *ctx, long long int value); +GRN_API void grn_ctx_output_float(grn_ctx *ctx, double value); +GRN_API void grn_ctx_output_cstr(grn_ctx *ctx, const char *value); +GRN_API void grn_ctx_output_str(grn_ctx *ctx, + const char *value, unsigned int value_len); +GRN_API void grn_ctx_output_bool(grn_ctx *ctx, grn_bool value); +GRN_API void grn_ctx_output_obj(grn_ctx *ctx, + grn_obj *value, grn_obj_format *format); + + +GRN_API grn_content_type grn_ctx_get_output_type(grn_ctx *ctx); +GRN_API grn_rc grn_ctx_set_output_type(grn_ctx *ctx, grn_content_type type); +GRN_API const char *grn_ctx_get_mime_type(grn_ctx *ctx); + +/* obsolete */ +GRN_API grn_rc grn_text_otoj(grn_ctx *ctx, grn_obj *bulk, grn_obj *obj, + grn_obj_format *format); + +#ifdef __cplusplus +} +#endif + +#endif /* GROONGA_OUTPUT_H */ -------------- next part -------------- HTML����������������������������...Download