added support (write/read) for timestamps
parent
87f0eeb282
commit
fbae728a2e
|
@ -1,6 +1,6 @@
|
||||||
USING: accessors assocs bson.constants byte-arrays byte-vectors fry io
|
USING: accessors assocs bson.constants byte-arrays byte-vectors fry io
|
||||||
io.binary io.encodings.string io.encodings.utf8 kernel math namespaces
|
io.binary io.encodings.string io.encodings.utf8 kernel math namespaces
|
||||||
sequences serialize arrays ;
|
sequences serialize arrays calendar ;
|
||||||
|
|
||||||
IN: bson.reader
|
IN: bson.reader
|
||||||
|
|
||||||
|
@ -168,6 +168,10 @@ M: bson-boolean element-data-read ( type -- boolean )
|
||||||
drop
|
drop
|
||||||
read-byte t = ;
|
read-byte t = ;
|
||||||
|
|
||||||
|
M: bson-date element-data-read ( type -- timestamp )
|
||||||
|
drop
|
||||||
|
read-longlong millis>timestamp ;
|
||||||
|
|
||||||
M: bson-binary element-data-read ( type -- binary )
|
M: bson-binary element-data-read ( type -- binary )
|
||||||
drop
|
drop
|
||||||
read-int32 read-byte element-binary-read ;
|
read-int32 read-byte element-binary-read ;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: accessors assocs bson.constants byte-arrays fry io io.binary
|
USING: accessors assocs bson.constants byte-arrays fry io io.binary
|
||||||
io.encodings.binary io.encodings.string io.encodings.utf8
|
io.encodings.binary io.encodings.string io.encodings.utf8
|
||||||
io.streams.byte-array kernel math math.parser quotations sequences
|
io.streams.byte-array kernel math math.parser quotations sequences
|
||||||
serialize strings words tools.hexdump ;
|
serialize strings words calendar ;
|
||||||
|
|
||||||
IN: bson.writer
|
IN: bson.writer
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ M: sequence bson-type? ( seq -- type ) drop T_Array ;
|
||||||
M: string bson-type? ( string -- type ) drop T_String ;
|
M: string bson-type? ( string -- type ) drop T_String ;
|
||||||
M: integer bson-type? ( integer -- type ) drop T_Integer ;
|
M: integer bson-type? ( integer -- type ) drop T_Integer ;
|
||||||
M: assoc bson-type? ( assoc -- type ) drop T_Object ;
|
M: assoc bson-type? ( assoc -- type ) drop T_Object ;
|
||||||
|
M: timestamp bson-type? ( timestamp -- type ) drop T_Date ;
|
||||||
|
|
||||||
M: oid bson-type? ( word -- type ) drop T_OID ;
|
M: oid bson-type? ( word -- type ) drop T_OID ;
|
||||||
M: objid bson-type? ( objid -- type ) drop T_Binary ;
|
M: objid bson-type? ( objid -- type ) drop T_Binary ;
|
||||||
|
@ -59,6 +60,9 @@ M: integer bson-write ( num -- )
|
||||||
M: real bson-write ( num -- )
|
M: real bson-write ( num -- )
|
||||||
>float write-double ;
|
>float write-double ;
|
||||||
|
|
||||||
|
M: timestamp bson-write ( timestamp -- )
|
||||||
|
timestamp>millis write-longlong ;
|
||||||
|
|
||||||
M: byte-array bson-write ( binary -- )
|
M: byte-array bson-write ( binary -- )
|
||||||
[ length write-int32 ] keep
|
[ length write-int32 ] keep
|
||||||
T_Binary_Bytes write-byte
|
T_Binary_Bytes write-byte
|
||||||
|
|
Loading…
Reference in New Issue