Class: Groonga::Conf
- Inherits:
-
Object
- Object
- Groonga::Conf
- Defined in:
- ext/groonga/rb-grn-conf.c,
ext/groonga/rb-grn-conf.c
Overview
This class manages database global configurations. Each configuration is key and value pair.
Instance Method Summary (collapse)
-
- (String?) conf
Gets a configuration value for key.
-
- (String) conf
Sets a configuration key and value pair.
-
- (Object) initialize(context = nil)
constructor
Creates a new configuration set for
context
.
Constructor Details
- (Object) initialize(context = nil)
Creates a new configuration set for context
.
39 40 41 42 43 44 45 |
# File 'ext/groonga/rb-grn-conf.c', line 39
static VALUE
rb_grn_conf_initialize (VALUE self, VALUE rb_context)
{
rb_iv_set(self, "@context", rb_context);
return Qnil;
}
|
Instance Method Details
- (String?) conf
Gets a configuration value for key.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'ext/groonga/rb-grn-conf.c', line 56
static VALUE
rb_grn_conf_get (VALUE self, VALUE rb_key)
{
VALUE rb_context;
VALUE rb_value;
grn_ctx *context;
const char *key;
int key_size;
const char *value;
uint32_t value_size;
rb_context = rb_iv_get(self, "@context");
context = rb_grn_context_ensure(&rb_context);
rb_key = rb_grn_convert_to_string(rb_key);
key = RSTRING_PTR(rb_key);
key_size = RSTRING_LEN(rb_key);
{
grn_rc rc;
rc = grn_conf_get(context,
key, key_size,
&value, &value_size);
rb_grn_context_check(context, self);
rb_grn_rc_check(rc, self);
}
if (value_size == 0) {
rb_value = Qnil;
} else {
rb_value = rb_grn_context_rb_string_new(context, value, value_size);
}
return rb_value;
}
|
- (String) conf
Sets a configuration key and value pair.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'ext/groonga/rb-grn-conf.c', line 100
static VALUE
rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value)
{
VALUE rb_value_original = rb_value;
VALUE rb_context;
grn_ctx *context;
const char *key;
int key_size;
const char *value;
int value_size;
rb_context = rb_iv_get(self, "@context");
context = rb_grn_context_ensure(&rb_context);
rb_key = rb_grn_convert_to_string(rb_key);
key = RSTRING_PTR(rb_key);
key_size = RSTRING_LEN(rb_key);
rb_value = rb_grn_convert_to_string(rb_value);
value = RSTRING_PTR(rb_value);
value_size = RSTRING_LEN(rb_value);
{
grn_rc rc;
rc = grn_conf_set(context,
key, key_size,
value, value_size);
rb_grn_context_check(context, self);
rb_grn_rc_check(rc, self);
}
return rb_value_original;
}
|