Kouhei Sutou
null+****@clear*****
Mon Jun 12 16:16:30 JST 2017
Kouhei Sutou 2017-06-12 16:16:30 +0900 (Mon, 12 Jun 2017) New Revision: e2819ecccf583542664a7e3cd112475a6328932b https://github.com/groonga/groonga/commit/e2819ecccf583542664a7e3cd112475a6328932b Message: grn_operator_to_exec_func: add a new API Modified files: include/groonga/operator.h lib/operator.c Modified: include/groonga/operator.h (+2 -1) =================================================================== --- include/groonga/operator.h 2017-06-08 15:00:32 +0900 (ef789cf) +++ include/groonga/operator.h 2017-06-12 16:16:30 +0900 (3e79e40) @@ -1,5 +1,5 @@ /* - Copyright(C) 2009-2016 Brazil + Copyright(C) 2009-2017 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -27,6 +27,7 @@ typedef grn_bool grn_operator_exec_func(grn_ctx *ctx, grn_obj *y); GRN_API const char *grn_operator_to_string(grn_operator op); +GRN_API grn_operator_exec_func *grn_operator_to_exec_func(grn_operator op); GRN_API grn_bool grn_operator_exec_equal(grn_ctx *ctx, grn_obj *x, grn_obj *y); GRN_API grn_bool grn_operator_exec_not_equal(grn_ctx *ctx, grn_obj *x, grn_obj *y); Modified: lib/operator.c (+41 -1) =================================================================== --- lib/operator.c 2017-06-08 15:00:32 +0900 (87fb57e) +++ lib/operator.c 2017-06-12 16:16:30 +0900 (bece438) @@ -1,6 +1,6 @@ /* -*- c-basic-offset: 2 -*- */ /* - Copyright(C) 2014-2016 Brazil + Copyright(C) 2014-2017 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -125,6 +125,46 @@ grn_operator_to_string(grn_operator op) } } +grn_operator_exec_func * +grn_operator_to_exec_func(grn_operator op) +{ + grn_operator_exec_func *func = NULL; + + switch (op) { + case GRN_OP_EQUAL : + func = grn_operator_exec_equal; + break; + case GRN_OP_NOT_EQUAL : + func = grn_operator_exec_not_equal; + break; + case GRN_OP_LESS : + func = grn_operator_exec_less; + break; + case GRN_OP_GREATER : + func = grn_operator_exec_greater; + break; + case GRN_OP_LESS_EQUAL : + func = grn_operator_exec_less_equal; + break; + case GRN_OP_GREATER_EQUAL : + func = grn_operator_exec_greater_equal; + break; + case GRN_OP_MATCH : + func = grn_operator_exec_match; + break; + case GRN_OP_PREFIX : + func = grn_operator_exec_prefix; + break; + case GRN_OP_REGEXP : + func = grn_operator_exec_regexp; + break; + default : + break; + } + + return func; +} + #define DO_EQ_SUB do {\ switch (y->header.domain) {\ case GRN_DB_INT8 :\ -------------- next part -------------- HTML����������������������������...ダウンロード