Kouhei Sutou
null+****@clear*****
Wed May 9 14:16:46 JST 2018
Kouhei Sutou 2018-05-09 14:16:46 +0900 (Wed, 09 May 2018) New Revision: d9e191b14de3720a93ae576815bfe8a3a3c5ccc5 https://github.com/groonga/groonga/commit/d9e191b14de3720a93ae576815bfe8a3a3c5ccc5 Message: token: support source location Modified files: include/groonga/token.h lib/grn_token.h lib/token.c Modified: include/groonga/token.h (+14 -0) =================================================================== --- include/groonga/token.h 2018-05-09 14:14:46 +0900 (8da3f46fe) +++ include/groonga/token.h 2018-05-09 14:16:46 +0900 (8783a4607) @@ -132,6 +132,20 @@ GRN_API grn_token_status grn_token_get_status(grn_ctx *ctx, GRN_API grn_rc grn_token_set_status(grn_ctx *ctx, grn_token *token, grn_token_status status); +GRN_API uint64_t +grn_token_get_source_offset(grn_ctx *ctx, + grn_token *token); +GRN_API grn_rc +grn_token_set_source_offset(grn_ctx *ctx, + grn_token *token, + uint64_t offset); +GRN_API uint32_t +grn_token_get_source_length(grn_ctx *ctx, + grn_token *token); +GRN_API grn_rc +grn_token_set_source_length(grn_ctx *ctx, + grn_token *token, + uint32_t length); #ifdef __cplusplus } /* extern "C" */ Modified: lib/grn_token.h (+2 -0) =================================================================== --- lib/grn_token.h 2018-05-09 14:14:46 +0900 (f0c38880f) +++ lib/grn_token.h 2018-05-09 14:16:46 +0900 (fa128e13f) @@ -27,6 +27,8 @@ extern "C" { struct _grn_token { grn_obj data; grn_token_status status; + uint64_t source_offset; + uint32_t source_length; }; grn_rc grn_token_init(grn_ctx *ctx, grn_token *token); Modified: lib/token.c (+59 -0) =================================================================== --- lib/token.c 2018-05-09 14:14:46 +0900 (b1b43d7b3) +++ lib/token.c 2018-05-09 14:16:46 +0900 (8a70d7f65) @@ -24,6 +24,8 @@ grn_token_init(grn_ctx *ctx, grn_token *token) GRN_API_ENTER; GRN_TEXT_INIT(&(token->data), GRN_OBJ_DO_SHALLOW_COPY); token->status = GRN_TOKEN_CONTINUE; + token->source_offset = 0; + token->source_length = 0; GRN_API_RETURN(ctx->rc); } @@ -113,6 +115,61 @@ exit: GRN_API_RETURN(ctx->rc); } +uint64_t +grn_token_get_source_offset(grn_ctx *ctx, grn_token *token) +{ + GRN_API_ENTER; + if (!token) { + ERR(GRN_INVALID_ARGUMENT, + "[token][source-offset][get] token must not be NULL"); + GRN_API_RETURN(0); + } + GRN_API_RETURN(token->source_offset); +} + +grn_rc +grn_token_set_source_offset(grn_ctx *ctx, + grn_token *token, + uint64_t offset) +{ + GRN_API_ENTER; + if (!token) { + ERR(GRN_INVALID_ARGUMENT, + "[token][source-offset][set] token must not be NULL"); + goto exit; + } + token->source_offset = offset; +exit: + GRN_API_RETURN(ctx->rc); +} + +uint32_t +grn_token_get_source_length(grn_ctx *ctx, grn_token *token) +{ + GRN_API_ENTER; + if (!token) { + ERR(GRN_INVALID_ARGUMENT, + "[token][source-length][get] token must not be NULL"); + GRN_API_RETURN(0); + } + GRN_API_RETURN(token->source_length); +} + +grn_rc +grn_token_set_source_length(grn_ctx *ctx, + grn_token *token, + uint32_t length) +{ + GRN_API_ENTER; + if (!token) { + ERR(GRN_INVALID_ARGUMENT, + "[token][source-length][set] token must not be NULL"); + goto exit; + } + token->source_length = length; +exit: + GRN_API_RETURN(ctx->rc); +} grn_rc grn_token_copy(grn_ctx *ctx, grn_token *token, @@ -128,6 +185,8 @@ grn_token_copy(grn_ctx *ctx, GRN_TEXT_VALUE(&(source->data)), GRN_TEXT_LEN(&(source->data))); token->status = source->status; + token->source_offset = source->source_offset; + token->source_length = source->source_length; exit: GRN_API_RETURN(ctx->rc); } -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180509/c5a97355/attachment-0001.htm