Sha256: b547949154bc4af234340d7c509383c9d4e5c7219fb24e3e02543ffea27e3ba6

Contents?: true

Size: 1.63 KB

Versions: 6

Compression:

Stored size: 1.63 KB

Contents

/* -*- c-file-style: "ruby" -*- */
/*
  Copyright (C) 2009  Kouhei Sutou <kou@clear-code.com>

  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include "rb-grn.h"

#define SELF(object) ((RbGrnTableCursor *)DATA_PTR(object))

VALUE rb_mGrnTableCursorKeySupport;

static VALUE
rb_grn_table_cursor_get_key (VALUE self)
{
    VALUE rb_key = Qnil;
    grn_ctx *context;
    grn_table_cursor *cursor;

    rb_grn_table_cursor_deconstruct(SELF(self), &cursor, &context,
				    NULL, NULL, NULL, NULL);
    if (context && cursor) {
        void *key;
        int key_size;
	grn_obj *table;

	table = grn_table_cursor_table(context, cursor);
        key_size = grn_table_cursor_get_key(context, cursor, &key);
        rb_key = GRNKEY2RVAL(context, key, key_size, table, self);
    }

    return rb_key;
}

void
rb_grn_init_table_cursor_key_support (VALUE mGrn)
{
    rb_mGrnTableCursorKeySupport =
	rb_define_module_under(rb_cGrnTableCursor, "KeySupport");

    rb_define_method(rb_cGrnTableCursor, "key",
                     rb_grn_table_cursor_get_key, 0);
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
groonga-0.0.7 ext/rb-grn-table-cursor-key-support.c
groonga-0.0.3 ext/rb-grn-table-cursor-key-support.c
groonga-0.0.4 ext/rb-grn-table-cursor-key-support.c
groonga-0.0.5 ext/rb-grn-table-cursor-key-support.c
groonga-0.0.6 ext/rb-grn-table-cursor-key-support.c
groonga-0.0.2 ext/rb-grn-table-cursor-key-support.c