Class Poco::BinaryReader (original) (raw)
Library: Foundation
Package: Streams
Header: Poco/BinaryReader.h
Description
This class reads basic types (and std::vectors thereof) in binary form into an input stream. It provides an extractor-based interface similar to istream. The reader also supports automatic conversion from big-endian (network byte order) to little-endian and vice-versa. Use a BinaryWriter to create a stream suitable for a BinaryReader.
Inheritance
Known Derived Classes: BasicMemoryBinaryReader
Member Summary
Member Functions: available, bad, byteOrder, eof, fail, good, operator >>, read7BitEncoded, readBOM, readCString, readRaw, setExceptions, stream
Enumerations
StreamByteOrder
NATIVE_BYTE_ORDER = 1
the host's native byte-order
BIG_ENDIAN_BYTE_ORDER = 2
big-endian (network) byte-order
NETWORK_BYTE_ORDER = 2
big-endian (network) byte-order
LITTLE_ENDIAN_BYTE_ORDER = 3
little-endian byte-order
UNSPECIFIED_BYTE_ORDER = 4
unknown, byte-order will be determined by reading the byte-order mark
Constructors
BinaryReader
BinaryReader(
std::istream & istr,
StreamByteOrder byteOrder = NATIVE_BYTE_ORDER
);
BinaryReader
BinaryReader(
std::istream & istr,
TextEncoding & encoding,
StreamByteOrder byteOrder = NATIVE_BYTE_ORDER
);
Destructor
~BinaryReader
~BinaryReader();
Member Functions
available 
std::streamsize available() const;
Returns the number of available bytes in the stream.
bad 
bool bad();
Returns _istr.bad();
byteOrder 
StreamByteOrder byteOrder() const;
eof 
bool eof();
Returns _istr.eof();
fail 
bool fail();
Returns _istr.fail();
good 
bool good();
Returns _istr.good();
operator >>
BinaryReader & operator >> (
bool & value
);
operator >>
BinaryReader & operator >> (
char & value
);
operator >>
BinaryReader & operator >> (
unsigned char & value
);
operator >>
BinaryReader & operator >> (
signed char & value
);
operator >>
BinaryReader & operator >> (
short & value
);
operator >>
BinaryReader & operator >> (
unsigned short & value
);
operator >>
BinaryReader & operator >> (
int & value
);
operator >>
BinaryReader & operator >> (
unsigned int & value
);
operator >>
BinaryReader & operator >> (
long & value
);
operator >>
BinaryReader & operator >> (
unsigned long & value
);
operator >>
BinaryReader & operator >> (
float & value
);
operator >>
BinaryReader & operator >> (
double & value
);
operator >>
BinaryReader & operator >> (
long long & value
);
operator >>
BinaryReader & operator >> (
unsigned long long & value
);
operator >>
BinaryReader & operator >> (
std::string & value
);
operator >> 
template < typename T > BinaryReader & operator >> (
std::vector < T > & value
);
read7BitEncoded
void read7BitEncoded(
UInt32 & value
);
Reads a 32-bit unsigned integer in compressed format. See BinaryWriter::write7BitEncoded() for a description of the compression algorithm.
read7BitEncoded
void read7BitEncoded(
UInt64 & value
);
Reads a 64-bit unsigned integer in compressed format. See BinaryWriter::write7BitEncoded() for a description of the compression algorithm.
readBOM
void readBOM();
Reads a byte-order mark from the stream and configures the reader for the encountered byte order. A byte-order mark is a 16-bit integer with a value of 0xFEFF, written in host byte order.
readCString
void readCString(
std::string & value
);
Reads zero-terminated C-string into value.
readRaw
void readRaw(
std::streamsize length,
std::string & value
);
Reads length bytes of raw data into value.
readRaw
void readRaw(
char * buffer,
std::streamsize length
);
Reads length bytes of raw data into buffer.
setExceptions 
void setExceptions(
std::ios_base::iostate st = (std::istream::failbit | std::istream::badbit)
);
Sets the stream to throw exception on specified state (default failbit and badbit);
stream 
std::istream & stream() const;
Returns the underlying stream.