Class: ODPI::Dpi::Object

Inherits:
Object
  • Object
show all
Defined in:
ext/odpi_ext/rbdpi-object.c

Instance Method Summary collapse

Constructor Details

#initializeObject


41
42
43
44
45
# File 'ext/odpi_ext/rbdpi.c', line 41

VALUE rbdpi_initialize_error(VALUE self)
{
    rb_raise(rb_eRuntimeError, "could not initialize by %s::new", rb_obj_classname(self));
    return Qnil;
}

Instance Method Details

#append_element(val, native_type) ⇒ Object


76
77
78
79
80
81
82
83
84
85
86
# File 'ext/odpi_ext/rbdpi-object.c', line 76

static VALUE object_append_element(VALUE self, VALUE val, VALUE native_type)
{
    object_t *object = rbdpi_to_object(self);
    dpiNativeTypeNum type = rbdpi_to_dpiNativeTypeNum(native_type);
    dpiData data;

    val = rbdpi_to_dpiData(&data, val, type, object->object_type->elem_datatype);
    CHK(dpiObject_appendElement(object->handle, type, &data));
    RB_GC_GUARD(val);
    return self;
}

#attribute_value(attr, native_type) ⇒ Object


105
106
107
108
109
110
111
112
113
114
# File 'ext/odpi_ext/rbdpi-object.c', line 105

static VALUE object_get_attribute_value(VALUE self, VALUE attr, VALUE native_type)
{
    object_t *object = rbdpi_to_object(self);
    object_attr_t *objattr = rbdpi_to_object_attr(attr);
    dpiNativeTypeNum type = rbdpi_to_dpiNativeTypeNum(native_type);
    dpiData data;

    CHK(dpiObject_getAttributeValue(object->handle, objattr->handle, type, &data));
    return rbdpi_from_dpiData(&data, type, objattr->datatype);
}

#delete_element_by_index(idx) ⇒ Object


97
98
99
100
101
102
103
# File 'ext/odpi_ext/rbdpi-object.c', line 97

static VALUE object_delete_element_by_index(VALUE self, VALUE idx)
{
    object_t *object = rbdpi_to_object(self);

    CHK(dpiObject_deleteElementByIndex(object->handle, NUM2INT(idx)));
    return self;
}

#dupObject


88
89
90
91
92
93
94
95
# File 'ext/odpi_ext/rbdpi-object.c', line 88

static VALUE object_dup(VALUE self)
{
    object_t *object = rbdpi_to_object(self);
    dpiObject *handle;

    CHK(dpiObject_copy(object->handle, &handle));
    return rbdpi_from_object(handle, object->objtype);
}

#element_exists_by_index?(idx) ⇒ Boolean

Returns:

  • (Boolean)

116
117
118
119
120
121
122
123
# File 'ext/odpi_ext/rbdpi-object.c', line 116

static VALUE object_get_element_exists_by_index(VALUE self, VALUE idx)
{
    object_t *object = rbdpi_to_object(self);
    int exists;

    CHK(dpiObject_getElementExistsByIndex(object->handle, NUM2INT(idx), &exists));
    return exists ? Qtrue : Qfalse;
}

#element_value_by_index(idx, native_type) ⇒ Object


125
126
127
128
129
130
131
132
133
# File 'ext/odpi_ext/rbdpi-object.c', line 125

static VALUE object_get_element_value_by_index(VALUE self, VALUE idx, VALUE native_type)
{
    object_t *object = rbdpi_to_object(self);
    dpiNativeTypeNum type = rbdpi_to_dpiNativeTypeNum(native_type);
    dpiData data;

    CHK(dpiObject_getElementValueByIndex(object->handle, NUM2INT(idx), type, &data));
    return rbdpi_from_dpiData(&data, type, object->object_type->elem_datatype);
}

#first_indexObject


135
136
137
138
139
140
141
142
143
# File 'ext/odpi_ext/rbdpi-object.c', line 135

static VALUE object_get_first_index(VALUE self)
{
    object_t *object = rbdpi_to_object(self);
    int32_t index;
    int exists;

    CHK(dpiObject_getFirstIndex(object->handle, &index, &exists));
    return exists ? INT2NUM(index) : Qnil;
}

#initialize_copy(other) ⇒ Object


65
66
67
68
69
70
71
72
73
74
# File 'ext/odpi_ext/rbdpi-object.c', line 65

static VALUE object_initialize_copy(VALUE self, VALUE other)
{
    object_t *object = rbdpi_to_object(self);

    *object = *rbdpi_to_object(other);
    if (object->handle != NULL) {
        CHK(dpiObject_addRef(object->handle));
    }
    return self;
}

#last_indexObject


145
146
147
148
149
150
151
152
153
# File 'ext/odpi_ext/rbdpi-object.c', line 145

static VALUE object_get_last_index(VALUE self)
{
    object_t *object = rbdpi_to_object(self);
    int32_t index;
    int exists;

    CHK(dpiObject_getLastIndex(object->handle, &index, &exists));
    return exists ? INT2NUM(index) : Qnil;
}

#next_index(idx) ⇒ Object


155
156
157
158
159
160
161
162
163
# File 'ext/odpi_ext/rbdpi-object.c', line 155

static VALUE object_get_next_index(VALUE self, VALUE idx)
{
    object_t *object = rbdpi_to_object(self);
    int32_t next_index;
    int exists;

    CHK(dpiObject_getNextIndex(object->handle, NUM2INT(idx), &next_index, &exists));
    return exists ? INT2NUM(next_index) : Qnil;
}

#object_typeObject


217
218
219
220
221
222
# File 'ext/odpi_ext/rbdpi-object.c', line 217

static VALUE object_get_object_type(VALUE self)
{
    object_t *object = rbdpi_to_object(self);

    return object->objtype;
}

#prev_index(idx) ⇒ Object


165
166
167
168
169
170
171
172
173
# File 'ext/odpi_ext/rbdpi-object.c', line 165

static VALUE object_get_prev_index(VALUE self, VALUE idx)
{
    object_t *object = rbdpi_to_object(self);
    int32_t prev_index;
    int exists;

    CHK(dpiObject_getPrevIndex(object->handle, NUM2INT(idx), &prev_index, &exists));
    return exists ? INT2NUM(prev_index) : Qnil;
}

#set_attribute_value(attr, native_type, val) ⇒ Object


184
185
186
187
188
189
190
191
192
193
194
195
# File 'ext/odpi_ext/rbdpi-object.c', line 184

static VALUE object_set_attribute_value(VALUE self, VALUE attr, VALUE native_type, VALUE val)
{
    object_t *object = rbdpi_to_object(self);
    object_attr_t *objattr = rbdpi_to_object_attr(attr);
    dpiNativeTypeNum type = rbdpi_to_dpiNativeTypeNum(native_type);
    dpiData data;

    val = rbdpi_to_dpiData(&data, val, type, objattr->datatype);
    CHK(dpiObject_setAttributeValue(object->handle, objattr->handle, type, &data));
    RB_GC_GUARD(val);
    return self;
}

#set_element_value_by_index(idx, native_type, val) ⇒ Object


197
198
199
200
201
202
203
204
205
206
207
# File 'ext/odpi_ext/rbdpi-object.c', line 197

static VALUE object_set_element_value_by_index(VALUE self, VALUE idx, VALUE native_type, VALUE val)
{
    object_t *object = rbdpi_to_object(self);
    dpiNativeTypeNum type = rbdpi_to_dpiNativeTypeNum(native_type);
    dpiData data;

    val = rbdpi_to_dpiData(&data, val, type, object->object_type->elem_datatype);
    CHK(dpiObject_setElementValueByIndex(object->handle, NUM2INT(idx), type, &data));
    RB_GC_GUARD(val);
    return self;
}

#sizeObject


175
176
177
178
179
180
181
182
# File 'ext/odpi_ext/rbdpi-object.c', line 175

static VALUE object_get_size(VALUE self)
{
    object_t *object = rbdpi_to_object(self);
    int32_t size;

    CHK(dpiObject_getSize(object->handle, &size));
    return INT2NUM(size);
}

#trim(size) ⇒ Object


209
210
211
212
213
214
215
# File 'ext/odpi_ext/rbdpi-object.c', line 209

static VALUE object_trim(VALUE self, VALUE size)
{
    object_t *object = rbdpi_to_object(self);

    CHK(dpiObject_trim(object->handle, NUM2UINT(size)));
    return self;
}