Library: MongoDB
Package: MongoDB
Header: Poco/MongoDB/BSONReader.h
Description
Class for reading BSON using a Poco::BinaryReader.
The readers check only what keeps a malformed document from reading past its bounds, allocating without limit or recursing too deeply (see Document::read). The available argument holds the bytes left in the enclosing document and is decreased by what is read.
Member Summary
Member Functions: read, readBinary, readByte, readCString, readFixed, readString
Constructors
BSONReader
BSONReader(
const Poco::BinaryReader & reader
);
Creates the BSONReader using the given BinaryWriter.
Destructor
~BSONReader
virtual ~BSONReader();
Destroys the BSONReader.
Member Functions
read
template < typename T > void read(
T & t
);
Reads the value from the reader. The default implementation uses the >> operator to the given argument. Special types can write their own version.
readBinary
[[nodiscard]]
Poco::SharedPtr < Binary > readBinary(
Int32 & available
);
Reads a BSON binary (length, subtype, bytes) that fits in the available bytes and subtracts its size from available. Defined in Binary.h.
readByte
[[nodiscard]]
unsigned char readByte();
Reads one byte; throws DataFormatException at the end of the stream.
readCString
[[nodiscard]]
std::string readCString();
Reads a cstring of at most MAX_MESSAGE_SIZE_BYTES.
readCString
[[nodiscard]]
std::string readCString(
Int32 & available
);
Reads a cstring that ends within the available bytes and subtracts its size from available.
readFixed
template < typename T > void readFixed(
T & value,
Int32 & available,
Int32 size
);
Reads a value of size bytes with the read() specialization for T and subtracts size from available.
readString
[[nodiscard]]
std::string readString(
Int32 & available
);
Reads a BSON string (length, bytes, null character) that fits in the available bytes and subtracts its size from available.