Module: CBson
- Defined in:
- ext/cbson/cbson.c
Class Method Summary collapse
Class Method Details
.deserialize(bson) ⇒ Object
727 728 729 730 731 732 733 734 735 736 |
# File 'ext/cbson/cbson.c', line 727
static VALUE method_deserialize(VALUE self, VALUE bson) {
const char* buffer = RSTRING_PTR(bson);
int remaining = RSTRING_LEN(bson);
// NOTE we just swallow the size and end byte here
buffer += 4;
remaining -= 5;
return elements_to_hash(buffer, remaining);
}
|
.serialize(doc, check_keys) ⇒ Object
469 470 471 472 473 474 475 476 477 478 479 |
# File 'ext/cbson/cbson.c', line 469
static VALUE method_serialize(VALUE self, VALUE doc, VALUE check_keys) {
VALUE result;
bson_buffer* buffer = buffer_new();
assert(buffer);
write_doc(buffer, doc, check_keys);
result = rb_str_new(buffer->buffer, buffer->position);
buffer_free(buffer);
return result;
}
|