Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::BinaryReader Class Reference

#include <BinaryReader.h>

+ Inheritance diagram for Poco::BinaryReader:

Public Types

enum  StreamByteOrder {
  NATIVE_BYTE_ORDER = 1 , BIG_ENDIAN_BYTE_ORDER = 2 , NETWORK_BYTE_ORDER = 2 , LITTLE_ENDIAN_BYTE_ORDER = 3 ,
  UNSPECIFIED_BYTE_ORDER = 4
}
 

Public Member Functions

 BinaryReader (std::istream &istr, StreamByteOrder byteOrder=NATIVE_BYTE_ORDER)
 
 BinaryReader (std::istream &istr, TextEncoding &encoding, StreamByteOrder byteOrder=NATIVE_BYTE_ORDER)
 Creates the BinaryReader.
 
 ~BinaryReader ()
 
BinaryReaderoperator>> (bool &value)
 Destroys the BinaryReader.
 
BinaryReaderoperator>> (char &value)
 
BinaryReaderoperator>> (unsigned char &value)
 
BinaryReaderoperator>> (signed char &value)
 
BinaryReaderoperator>> (short &value)
 
BinaryReaderoperator>> (unsigned short &value)
 
BinaryReaderoperator>> (int &value)
 
BinaryReaderoperator>> (unsigned int &value)
 
BinaryReaderoperator>> (long &value)
 
BinaryReaderoperator>> (unsigned long &value)
 
BinaryReaderoperator>> (float &value)
 
BinaryReaderoperator>> (double &value)
 
BinaryReaderoperator>> (std::string &value)
 
template<typename T >
BinaryReaderoperator>> (std::vector< T > &value)
 
void read7BitEncoded (UInt32 &value)
 
void readRaw (std::streamsize length, std::string &value)
 
void readRaw (char *buffer, std::streamsize length)
 Reads length bytes of raw data into value.
 
void readBOM ()
 Reads length bytes of raw data into buffer.
 
bool good ()
 
bool fail ()
 Returns _istr.good();.
 
bool bad ()
 Returns _istr.fail();.
 
bool eof ()
 Returns _istr.bad();.
 
std::istream & stream () const
 Returns _istr.eof();.
 
StreamByteOrder byteOrder () const
 Returns the underlying stream.
 
void setExceptions (std::ios_base::iostate st=(std::istream::failbit|std::istream::badbit))
 
std::streamsize available () const
 Sets the stream to throw exception on specified state (default failbit and badbit);.
 

Private Attributes

std::istream & _istr
 Returns the number of available bytes in the stream.
 
bool _flipBytes
 
TextConverter * _pTextConverter
 

Detailed 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.

Definition at line 35 of file BinaryReader.h.

Member Enumeration Documentation

◆ StreamByteOrder

Enumerator
NATIVE_BYTE_ORDER 
BIG_ENDIAN_BYTE_ORDER 

the host's native byte-order

NETWORK_BYTE_ORDER 

big-endian (network) byte-order

LITTLE_ENDIAN_BYTE_ORDER 

big-endian (network) byte-order

UNSPECIFIED_BYTE_ORDER 

little-endian byte-order

Definition at line 44 of file BinaryReader.h.

Constructor & Destructor Documentation

◆ BinaryReader() [1/2]

Poco::BinaryReader::BinaryReader ( std::istream & istr,
StreamByteOrder byteOrder = NATIVE_BYTE_ORDER )

◆ BinaryReader() [2/2]

Poco::BinaryReader::BinaryReader ( std::istream & istr,
TextEncoding & encoding,
StreamByteOrder byteOrder = NATIVE_BYTE_ORDER )

Creates the BinaryReader.

◆ ~BinaryReader()

Poco::BinaryReader::~BinaryReader ( )

Creates the BinaryReader using the given TextEncoding.

Strings will be converted from the specified encoding to the currently set global encoding (see Poco::TextEncoding::global()).

Member Function Documentation

◆ available()

std::streamsize Poco::BinaryReader::available ( ) const
inline

Sets the stream to throw exception on specified state (default failbit and badbit);.

Definition at line 256 of file BinaryReader.h.

◆ bad()

bool Poco::BinaryReader::bad ( )
inline

Returns _istr.fail();.

Definition at line 222 of file BinaryReader.h.

◆ byteOrder()

BinaryReader::StreamByteOrder Poco::BinaryReader::byteOrder ( ) const
inline

Returns the underlying stream.

Definition at line 240 of file BinaryReader.h.

◆ eof()

bool Poco::BinaryReader::eof ( )
inline

Returns _istr.bad();.

Definition at line 228 of file BinaryReader.h.

◆ fail()

bool Poco::BinaryReader::fail ( )
inline

Returns _istr.good();.

Definition at line 216 of file BinaryReader.h.

◆ good()

bool Poco::BinaryReader::good ( )
inline

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.

Definition at line 210 of file BinaryReader.h.

◆ operator>>() [1/14]

BinaryReader & Poco::BinaryReader::operator>> ( bool & value)

Destroys the BinaryReader.

◆ operator>>() [2/14]

BinaryReader & Poco::BinaryReader::operator>> ( char & value)

◆ operator>>() [3/14]

BinaryReader & Poco::BinaryReader::operator>> ( double & value)

◆ operator>>() [4/14]

BinaryReader & Poco::BinaryReader::operator>> ( float & value)

◆ operator>>() [5/14]

BinaryReader & Poco::BinaryReader::operator>> ( int & value)

◆ operator>>() [6/14]

BinaryReader & Poco::BinaryReader::operator>> ( long & value)

◆ operator>>() [7/14]

BinaryReader & Poco::BinaryReader::operator>> ( short & value)

◆ operator>>() [8/14]

BinaryReader & Poco::BinaryReader::operator>> ( signed char & value)

◆ operator>>() [9/14]

BinaryReader & Poco::BinaryReader::operator>> ( std::string & value)

◆ operator>>() [10/14]

template<typename T >
BinaryReader & Poco::BinaryReader::operator>> ( std::vector< T > & value)
inline

Definition at line 86 of file BinaryReader.h.

◆ operator>>() [11/14]

BinaryReader & Poco::BinaryReader::operator>> ( unsigned char & value)

◆ operator>>() [12/14]

BinaryReader & Poco::BinaryReader::operator>> ( unsigned int & value)

◆ operator>>() [13/14]

BinaryReader & Poco::BinaryReader::operator>> ( unsigned long & value)

◆ operator>>() [14/14]

BinaryReader & Poco::BinaryReader::operator>> ( unsigned short & value)

◆ read7BitEncoded()

void Poco::BinaryReader::read7BitEncoded ( UInt32 & value)

◆ readBOM()

void Poco::BinaryReader::readBOM ( )

Reads length bytes of raw data into buffer.

◆ readRaw() [1/2]

void Poco::BinaryReader::readRaw ( char * buffer,
std::streamsize length )

Reads length bytes of raw data into value.

◆ readRaw() [2/2]

void Poco::BinaryReader::readRaw ( std::streamsize length,
std::string & value )

Reads a 32-bit unsigned integer in compressed format. See BinaryWriter::write7BitEncoded() for a description of the compression algorithm.

◆ setExceptions()

void Poco::BinaryReader::setExceptions ( std::ios_base::iostate st = (std::istream::failbit | std::istream::badbit))
inline

Returns the byte-order used by the reader, which is either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.

Definition at line 250 of file BinaryReader.h.

◆ stream()

std::istream & Poco::BinaryReader::stream ( ) const
inline

Returns _istr.eof();.

Definition at line 234 of file BinaryReader.h.

Member Data Documentation

◆ _flipBytes

bool Poco::BinaryReader::_flipBytes
private

Definition at line 153 of file BinaryReader.h.

◆ _istr

std::istream& Poco::BinaryReader::_istr
private

Returns the number of available bytes in the stream.

Definition at line 152 of file BinaryReader.h.

◆ _pTextConverter

TextConverter* Poco::BinaryReader::_pTextConverter
private

Definition at line 154 of file BinaryReader.h.


The documentation for this class was generated from the following file: