Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's for supporting rewriting grn_expr. (Rewriting grn_expr isn't implemented yet.)
- Loading branch information
Showing
9 changed files
with
157 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* -*- c-basic-offset: 2 -*- */ | ||
| /* | ||
| Copyright(C) 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 version 2.1 as published by the Free Software Foundation. | ||
| 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 GRN_SCANNER_H | ||
| #define GRN_SCANNER_H | ||
|
|
||
| #include "grn_expr.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| typedef struct _grn_scaner { | ||
| grn_obj *expr; | ||
| grn_obj *rewritten_expr; | ||
| scan_info **sis; | ||
| unsigned int n_sis; | ||
| } grn_scanner; | ||
|
|
||
| grn_scanner *grn_scanner_open(grn_ctx *ctx, grn_obj *expr, | ||
| grn_operator op, grn_bool record_exist); | ||
| void grn_scanner_close(grn_ctx *ctx, grn_scanner *scanner); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* GRN_SCANNER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* -*- c-basic-offset: 2 -*- */ | ||
| /* | ||
| Copyright(C) 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 version 2.1 as published by the Free Software Foundation. | ||
| 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 | ||
| */ | ||
|
|
||
| #include "grn_scanner.h" | ||
|
|
||
| static void | ||
| sis_free(grn_ctx *ctx, scan_info **sis, unsigned int n_sis) | ||
| { | ||
| int i; | ||
| for (i = 0; i < n_sis; i++) { | ||
| grn_scan_info_close(ctx, sis[i]); | ||
| } | ||
| GRN_FREE(sis); | ||
| } | ||
|
|
||
| grn_scanner * | ||
| grn_scanner_open(grn_ctx *ctx, | ||
| grn_obj *expr, | ||
| grn_operator op, | ||
| grn_bool record_exist) | ||
| { | ||
| grn_scanner *scanner; | ||
| scan_info **sis; | ||
| unsigned int n_sis; | ||
|
|
||
| sis = grn_scan_info_build(ctx, expr, &n_sis, op, record_exist); | ||
| if (!sis) { | ||
| return NULL; | ||
| } | ||
|
|
||
| scanner = GRN_MALLOC(sizeof(grn_scanner)); | ||
| if (!scanner) { | ||
| sis_free(ctx, sis, n_sis); | ||
| return NULL; | ||
| } | ||
|
|
||
| scanner->expr = expr; | ||
| scanner->rewritten_expr = NULL; | ||
| scanner->sis = sis; | ||
| scanner->n_sis = n_sis; | ||
|
|
||
| return scanner; | ||
| } | ||
|
|
||
| void | ||
| grn_scanner_close(grn_ctx *ctx, grn_scanner *scanner) | ||
| { | ||
| if (!scanner) { | ||
| return; | ||
| } | ||
|
|
||
| if (scanner->rewritten_expr) { | ||
| grn_obj_close(ctx, scanner->rewritten_expr); | ||
| } | ||
|
|
||
| if (scanner->sis) { | ||
| sis_free(ctx, scanner->sis, scanner->n_sis); | ||
| } | ||
|
|
||
| GRN_FREE(scanner); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters