Module: CBson
- Defined in:
- ext/cbson/cbson.c
Class Method Summary collapse
Class Method Details
.deserialize(bson) ⇒ Object
707 708 709 710 711 712 713 714 715 716 |
# File 'ext/cbson/cbson.c', line 707
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
457 458 459 460 461 462 463 464 465 466 467 |
# File 'ext/cbson/cbson.c', line 457
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;
}
|