/* * call-seq: * context.inspect -> String * * コンテキストの中身を人に見やすい文字列で返す。 */ static VALUE rb_grn_context_inspect (VALUE self) { VALUE inspected; grn_ctx *context; grn_obj *database; VALUE rb_database; context = SELF(self); inspected = rb_str_new2("#<"); rb_str_concat(inspected, rb_inspect(rb_obj_class(self))); rb_str_cat2(inspected, " "); rb_str_cat2(inspected, "encoding: <"); rb_str_concat(inspected, rb_inspect(GRNENCODING2RVAL(context->encoding))); rb_str_cat2(inspected, ">, "); rb_str_cat2(inspected, "database: <"); database = grn_ctx_db(context); rb_database = GRNDB2RVAL(context, database, RB_GRN_FALSE); rb_str_concat(inspected, rb_inspect(rb_database)); rb_str_cat2(inspected, ">"); rb_str_cat2(inspected, ">"); return inspected; }
static VALUE rb_grn_table_key_support_inspect_content (VALUE self, VALUE inspected) { RbGrnTableKeySupport *rb_grn_table; grn_ctx *context = NULL; grn_obj *table; rb_grn_table = SELF(self); if (!rb_grn_table) return inspected; rb_grn_table_key_support_deconstruct(SELF(self), &table, &context, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (!table) return inspected; if (!context) return inspected; { grn_obj value; grn_encoding encoding; rb_str_cat2(inspected, ", "); rb_str_cat2(inspected, "encoding: <"); GRN_OBJ_INIT(&value, GRN_BULK, 0, GRN_ID_NIL); grn_obj_get_info(context, table, GRN_INFO_ENCODING, &value); encoding = *((grn_encoding *)GRN_BULK_HEAD(&value)); grn_obj_unlink(context, &value); if (context->rc == GRN_SUCCESS) { rb_str_concat(inspected, rb_inspect(GRNENCODING2RVAL(encoding))); } else { rb_str_cat2(inspected, "invalid"); } rb_str_cat2(inspected, ">"); } { grn_obj *default_tokenizer; rb_str_cat2(inspected, ", "); rb_str_cat2(inspected, "default_tokenizer: "); default_tokenizer = grn_obj_get_info(context, table, GRN_INFO_DEFAULT_TOKENIZER, NULL); if (default_tokenizer) { rb_grn_object_inspect_object_content_name(inspected, context, default_tokenizer); } else { rb_str_cat2(inspected, "(nil)"); } } { grn_obj *normalizer; rb_str_cat2(inspected, ", "); rb_str_cat2(inspected, "normalizer: "); normalizer = grn_obj_get_info(context, table, GRN_INFO_NORMALIZER, NULL); if (normalizer) { rb_grn_object_inspect_object_content_name(inspected, context, normalizer); } else { rb_str_cat2(inspected, "(nil)"); } } return inspected; }
/* * call-seq: * context.encoding -> Groonga::Encoding * * コンテキストが使うエンコーディングを返す。 */ static VALUE rb_grn_context_get_encoding (VALUE self) { return GRNENCODING2RVAL(GRN_CTX_GET_ENCODING(SELF(self))); }