[Groonga-commit] groonga/groonga at 7152c52 [master] Add grn_vector_get_element_bool()

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Apr 6 15:28:35 JST 2018


Kouhei Sutou	2018-04-06 15:28:35 +0900 (Fri, 06 Apr 2018)

  New Revision: 7152c523fec007311326a2f75bc80dd055c7b990
  https://github.com/groonga/groonga/commit/7152c523fec007311326a2f75bc80dd055c7b990

  Message:
    Add grn_vector_get_element_bool()

  Modified files:
    include/groonga/vector.h
    lib/vector.cpp

  Modified: include/groonga/vector.h (+4 -0)
===================================================================
--- include/groonga/vector.h    2018-04-06 15:27:21 +0900 (ec9a61455)
+++ include/groonga/vector.h    2018-04-06 15:28:35 +0900 (ac0cd3280)
@@ -33,6 +33,10 @@ GRN_API grn_rc grn_vector_add_element(grn_ctx *ctx, grn_obj *vector,
 GRN_API unsigned int grn_vector_get_element(grn_ctx *ctx, grn_obj *vector,
                                             unsigned int offset, const char **str,
                                             unsigned int *weight, grn_id *domain);
+GRN_API grn_bool grn_vector_get_element_bool(grn_ctx *ctx,
+                                             grn_obj *vector,
+                                             unsigned int offset,
+                                             grn_bool default_value);
 GRN_API int8_t grn_vector_get_element_int8(grn_ctx *ctx,
                                            grn_obj *vector,
                                            unsigned int offset,

  Modified: lib/vector.cpp (+12 -0)
===================================================================
--- lib/vector.cpp    2018-04-06 15:27:21 +0900 (fcf123813)
+++ lib/vector.cpp    2018-04-06 15:28:35 +0900 (e0c72bc74)
@@ -42,6 +42,9 @@ namespace grn {
                                     &domain);
     if (length > 0) {
       switch (domain) {
+      case GRN_DB_BOOL :
+        value = *reinterpret_cast<const grn_bool *>(raw_value);
+        break;
       case GRN_DB_INT8 :
         value = *reinterpret_cast<const int8_t *>(raw_value);
         break;
@@ -79,6 +82,15 @@ namespace grn {
 }
 
 extern "C" {
+  grn_bool
+  grn_vector_get_element_bool(grn_ctx *ctx,
+                              grn_obj *vector,
+                              unsigned int offset,
+                              grn_bool default_value)
+  {
+    return grn::vector_get_element<grn_bool>(ctx, vector, offset, default_value);
+  }
+
   int8_t
   grn_vector_get_element_int8(grn_ctx *ctx,
                               grn_obj *vector,
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180406/2a5749dd/attachment-0001.htm 



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