Module: CBson
- Defined in:
- ext/cbson/cbson.c
Constant Summary collapse
- VERSION =
ext_version
Class Method Summary collapse
- .deserialize(bson) ⇒ Object
- .max_bson_size ⇒ Object
- .serialize(doc, check_keys, move_id) ⇒ Object
- .update_max_bson_size(connection) ⇒ Object
Class Method Details
.deserialize(bson) ⇒ Object
880 881 882 883 884 885 886 887 888 889 |
# File 'ext/cbson/cbson.c', line 880
static VALUE method_deserialize(VALUE self, VALUE bson) {
const char* buffer = RSTRING_PTR(bson);
int remaining = RSTRING_LENINT(bson);
// NOTE we just swallow the size and end byte here
buffer += 4;
remaining -= 5;
return elements_to_hash(buffer, remaining);
}
|
.max_bson_size ⇒ Object
936 937 938 |
# File 'ext/cbson/cbson.c', line 936 static VALUE method_max_bson_size(VALUE self) { return INT2FIX(max_bson_size); } |
.serialize(doc, check_keys, move_id) ⇒ Object
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'ext/cbson/cbson.c', line 610
static VALUE method_serialize(VALUE self, VALUE doc, VALUE check_keys, VALUE move_id) {
VALUE result;
buffer_t buffer = buffer_new();
if (buffer == NULL) {
rb_raise(rb_eNoMemError, "failed to allocate memory in buffer.c");
}
write_doc(buffer, doc, check_keys, move_id);
result = rb_str_new(buffer_get_buffer(buffer), buffer_get_position(buffer));
if (buffer_free(buffer) != 0) {
rb_raise(rb_eRuntimeError, "failed to free buffer");
}
return result;
}
|
.update_max_bson_size(connection) ⇒ Object
931 932 933 934 |
# File 'ext/cbson/cbson.c', line 931
static VALUE method_update_max_bson_size(VALUE self, VALUE connection) {
max_bson_size = FIX2INT(rb_funcall(connection, rb_intern("max_bson_size"), 0));
return INT2FIX(max_bson_size);
}
|