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); }
static VALUE method_max_bson_size(VALUE self) { return INT2FIX(max_bson_size); }
static VALUE method_serialize(VALUE self, VALUE doc, VALUE check_keys, VALUE move_id, VALUE max_size) { VALUE result; bson_buffer_t buffer = bson_buffer_new(); bson_buffer_set_max_size(buffer, FIX2INT(max_size)); 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(bson_buffer_get_buffer(buffer), bson_buffer_get_position(buffer)); if (bson_buffer_free(buffer) != 0) { rb_raise(rb_eRuntimeError, "failed to free buffer"); } return result; }
Generated with the Darkfish Rdoc Generator 2.