oid encoder
This commit is contained in:
parent
634766b14e
commit
9f2305715e
@ -197,6 +197,16 @@ static int write_element(VALUE key, VALUE value, VALUE extra) {
|
|||||||
buffer_write_bytes(buffer, RSTRING(string_data)->ptr, length);
|
buffer_write_bytes(buffer, RSTRING(string_data)->ptr, length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (strcmp(cls, "XGen::Mongo::Driver::ObjectID") == 0) {
|
||||||
|
write_name_and_type(buffer, key, 0x07);
|
||||||
|
VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0);
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 12; i++) {
|
||||||
|
char byte = (char)FIX2INT(RARRAY(as_array)->ptr[i]);
|
||||||
|
buffer_write_bytes(buffer, &byte, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (strcmp(cls, "XGen::Mongo::Driver::Undefined") == 0) {
|
if (strcmp(cls, "XGen::Mongo::Driver::Undefined") == 0) {
|
||||||
write_name_and_type(buffer, key, 0x06);
|
write_name_and_type(buffer, key, 0x06);
|
||||||
break;
|
break;
|
||||||
|
@ -99,10 +99,14 @@ class ByteBuffer
|
|||||||
@cursor += len
|
@cursor += len
|
||||||
if one_byte
|
if one_byte
|
||||||
@buf[start]
|
@buf[start]
|
||||||
|
else
|
||||||
|
if @buf.respond_to? "unpack"
|
||||||
|
@buf[start, len].unpack("C*")
|
||||||
else
|
else
|
||||||
@buf[start, len]
|
@buf[start, len]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get_int
|
def get_int
|
||||||
check_read_length(4)
|
check_read_length(4)
|
||||||
|
Loading…
Reference in New Issue
Block a user