classafBson::BsonWriter
sys::Obj afBson::BsonWriter
Wraps an OutStream
to write BSON objects.
CAUTION:
INTEGER_32
values will be read as Int values. If you then write its containing document, the storage type will be converted toINTEGER_64
.
This is only of concern if other, non Fantom drivers, are writing to the database.
- flush
This flush()
Flushes the underlying
OutStream
.- make
new make(OutStream? out)
Creates a
BsonWriter
, wrapping the givenOutSteam
As per the BSON spec, the stream's endian is set tolittle
.out
may benull
if the writer is just being used to size documents.- out
OutStream? out { private set }
The underlying
OutStream
.- sizeCString
Calculates the size (in bytes) of the given Str should it be serialised as a null terminated
CString
. Nothing is written to theOutStream
.- sizeDocument
Int sizeDocument([Obj:Obj?]? document)
Calculates the size (in bytes) of the given BSON Document should it be serialised. Nothing is written to the
OutStream
.- writeCString
Writes a
null
terminated BSON string toOutStream
.- writeDocument
This writeDocument([Obj:Obj?]? document)
Serialises the given BSON Document to the underlying
OutStream
.- writeInteger32
This writeInteger32(Int int32)
Writes a 32 bit integer value to
OutStream
. Unlike storingInts
in a Document, this method will write an actualINTEGER_32
.- writeInteger64
This writeInteger64(Int int64)
Writes a 64 bit integer value to
OutStream
.