[Groonga-commit] groonga/groonga at 29873a2 [master] Add grn_token_get_data_raw() convenient API

Back to archive index

Kouhei Sutou null+****@clear*****
Wed May 9 10:14:32 JST 2018


Kouhei Sutou	2018-05-09 10:14:32 +0900 (Wed, 09 May 2018)

  New Revision: 29873a29b85bd54781e91dc1a1b38c63051b34c3
  https://github.com/groonga/groonga/commit/29873a29b85bd54781e91dc1a1b38c63051b34c3

  Message:
    Add grn_token_get_data_raw() convenient API

  Modified files:
    include/groonga/token.h
    lib/token.c

  Modified: include/groonga/token.h (+3 -0)
===================================================================
--- include/groonga/token.h    2018-05-08 16:07:38 +0900 (d2dba74fb)
+++ include/groonga/token.h    2018-05-09 10:14:32 +0900 (8da3f46fe)
@@ -120,6 +120,9 @@ typedef struct _grn_token grn_token;
 
 GRN_API grn_obj *grn_token_get_data(grn_ctx *ctx,
                                     grn_token *token);
+GRN_API const char *grn_token_get_data_raw(grn_ctx *ctx,
+                                           grn_token *token,
+                                           size_t *length);
 GRN_API grn_rc grn_token_set_data(grn_ctx *ctx,
                                   grn_token *token,
                                   const char *str_ptr,

  Modified: lib/token.c (+17 -0)
===================================================================
--- lib/token.c    2018-05-08 16:07:38 +0900 (8954331fb)
+++ lib/token.c    2018-05-09 10:14:32 +0900 (9f1482568)
@@ -46,6 +46,23 @@ grn_token_get_data(grn_ctx *ctx, grn_token *token)
   GRN_API_RETURN(&(token->data));
 }
 
+const char *
+grn_token_get_data_raw(grn_ctx *ctx, grn_token *token, size_t *length)
+{
+  GRN_API_ENTER;
+  if (!token) {
+    ERR(GRN_INVALID_ARGUMENT, "token must not be NULL");
+    if (length) {
+      *length = 0;
+    }
+    GRN_API_RETURN(NULL);
+  }
+  if (length) {
+    *length = GRN_TEXT_LEN(&(token->data));
+  }
+  GRN_API_RETURN(GRN_TEXT_VALUE(&(token->data)));
+}
+
 grn_rc
 grn_token_set_data(grn_ctx *ctx,
                    grn_token *token,
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180509/186e9205/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index