! Copyright (C) 2010 Sascha Matzke.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs bson.constants calendar combinators
-combinators.short-circuit io io.binary kernel math
+combinators.short-circuit io io.binary kernel math locals
namespaces sequences serialize strings vectors byte-arrays ;
FROM: io.encodings.binary => binary ;
: bson-object-data-read ( -- object )
read-int32 drop get-state
- [ exemplar>> clone ] [ scope>> ] bi
- [ push ] keep ; inline
+ [ exemplar>> clone dup ] [ scope>> ] bi push ; inline
: bson-binary-read ( -- binary )
read-int32 read-byte
TYPED: (prepare-object) ( type: integer -- object )
[ element-data-read ] [ end-element ] bi ; inline
-TYPED: (read-object) ( type: integer name: string state: state -- )
- [ (prepare-object) ] 2dip
- peek-scope set-at ; inline
+:: (read-object) ( type name state -- )
+ state peek-scope :> scope
+ type (prepare-object) name scope set-at ; inline
TYPED: bson-not-eoo-element-read ( type: integer -- cont?: boolean )
read-cstring get-state
"USING: mongodb.driver ;"
"\"db\" \"127.0.0.1\" 27017 <mdb>"
"[ \"mycollection\" [ H{ { \"name\" \"Alfred\" } { \"age\" 57 } } save ] "
- " [ ageIdx [ \"age\" asc ] key-spec <index-spec> ensure-index ]"
+ " [ \"ageIdx\" [ \"age\" asc ] key-spec <index-spec> ensure-index ]"
" [ H{ { \"age\" H{ { \"$gt\" 50 } } } } <query> find-one ] tri ] with-db "
"" }
{ $heading "Highlevel tuple integration" }
read-longlong >>cursor
read-int32 >>start#
read-int32 [ >>returned# ] keep
- [ H{ } stream>assoc ] collector [ times ] dip >>objects ;
+ [ H{ } clone stream>assoc ] collector [ times ] dip >>objects ;
: (read-message) ( message opcode -- message )
OP_Reply =