Ark Server API (ASE) - Wiki
|
#include <BinaryWriter.h>
Public Types | |
enum | StreamByteOrder { NATIVE_BYTE_ORDER = 1 , BIG_ENDIAN_BYTE_ORDER = 2 , NETWORK_BYTE_ORDER = 2 , LITTLE_ENDIAN_BYTE_ORDER = 3 } |
Public Member Functions | |
BinaryWriter (std::ostream &ostr, StreamByteOrder byteOrder=NATIVE_BYTE_ORDER) | |
BinaryWriter (std::ostream &ostr, TextEncoding &encoding, StreamByteOrder byteOrder=NATIVE_BYTE_ORDER) | |
Creates the BinaryWriter. | |
~BinaryWriter () | |
BinaryWriter & | operator<< (bool value) |
Destroys the BinaryWriter. | |
BinaryWriter & | operator<< (char value) |
BinaryWriter & | operator<< (unsigned char value) |
BinaryWriter & | operator<< (signed char value) |
BinaryWriter & | operator<< (short value) |
BinaryWriter & | operator<< (unsigned short value) |
BinaryWriter & | operator<< (int value) |
BinaryWriter & | operator<< (unsigned int value) |
BinaryWriter & | operator<< (long value) |
BinaryWriter & | operator<< (unsigned long value) |
BinaryWriter & | operator<< (float value) |
BinaryWriter & | operator<< (double value) |
BinaryWriter & | operator<< (const std::string &value) |
BinaryWriter & | operator<< (const char *value) |
template<typename T > | |
BinaryWriter & | operator<< (const std::vector< T > &value) |
void | write7BitEncoded (UInt32 value) |
void | writeRaw (const std::string &rawData) |
void | writeRaw (const char *buffer, std::streamsize length) |
Writes the string as-is to the stream. | |
void | writeBOM () |
Writes length raw bytes from the given buffer to the stream. | |
void | flush () |
bool | good () |
Flushes the underlying stream. | |
bool | fail () |
Returns _ostr.good();. | |
bool | bad () |
Returns _ostr.fail();. | |
std::ostream & | stream () const |
Returns _ostr.bad();. | |
StreamByteOrder | byteOrder () const |
Returns the underlying stream. | |
Private Attributes | |
std::ostream & | _ostr |
bool | _flipBytes |
TextConverter * | _pTextConverter |
This class writes basic types (and std::vectors of these) in binary form into an output stream. It provides an inserter-based interface similar to ostream. The writer also supports automatic conversion from big-endian (network byte order) to little-endian and vice-versa. Use a BinaryReader to read from a stream created by a BinaryWriter. Be careful when exchanging data between systems with different data type sizes (e.g., 32-bit and 64-bit architectures), as the sizes of some of the basic types may be different. For example, writing a long integer on a 64-bit system and reading it on a 32-bit system may yield an incorrent result. Use fixed-size types (Int32, Int64, etc.) in such a case.
Definition at line 35 of file BinaryWriter.h.
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 |
Definition at line 50 of file BinaryWriter.h.
Poco::BinaryWriter::BinaryWriter | ( | std::ostream & | ostr, |
StreamByteOrder | byteOrder = NATIVE_BYTE_ORDER ) |
Poco::BinaryWriter::BinaryWriter | ( | std::ostream & | ostr, |
TextEncoding & | encoding, | ||
StreamByteOrder | byteOrder = NATIVE_BYTE_ORDER ) |
Creates the BinaryWriter.
Poco::BinaryWriter::~BinaryWriter | ( | ) |
Creates the BinaryWriter using the given TextEncoding.
Strings will be converted from the currently set global encoding (see Poco::TextEncoding::global()) to the specified encoding.
|
inline |
Returns _ostr.fail();.
Definition at line 250 of file BinaryWriter.h.
|
inline |
Returns the underlying stream.
Definition at line 256 of file BinaryWriter.h.
|
inline |
Returns _ostr.good();.
Definition at line 244 of file BinaryWriter.h.
void Poco::BinaryWriter::flush | ( | ) |
Writes a byte-order mark to the stream. A byte order mark is a 16-bit integer with a value of 0xFEFF, written in host byte-order. A BinaryReader uses the byte-order mark to determine the byte-order of the stream.
|
inline |
Flushes the underlying stream.
Definition at line 238 of file BinaryWriter.h.
BinaryWriter & Poco::BinaryWriter::operator<< | ( | bool | value | ) |
Destroys the BinaryWriter.
BinaryWriter & Poco::BinaryWriter::operator<< | ( | char | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | const char * | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | const std::string & | value | ) |
|
inline |
Definition at line 92 of file BinaryWriter.h.
BinaryWriter & Poco::BinaryWriter::operator<< | ( | double | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | float | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | int | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | long | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | short | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | signed char | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | unsigned char | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | unsigned int | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | unsigned long | value | ) |
BinaryWriter & Poco::BinaryWriter::operator<< | ( | unsigned short | value | ) |
|
inline |
Returns _ostr.bad();.
Definition at line 232 of file BinaryWriter.h.
void Poco::BinaryWriter::write7BitEncoded | ( | UInt32 | value | ) |
void Poco::BinaryWriter::writeBOM | ( | ) |
Writes length raw bytes from the given buffer to the stream.
void Poco::BinaryWriter::writeRaw | ( | const char * | buffer, |
std::streamsize | length ) |
Writes the string as-is to the stream.
void Poco::BinaryWriter::writeRaw | ( | const std::string & | rawData | ) |
Writes a 32-bit unsigned integer in a compressed format. The value is written out seven bits at a time, starting with the seven least-significant bits. The high bit of a byte indicates whether there are more bytes to be written after this one. If value will fit in seven bits, it takes only one byte of space. If value will not fit in seven bits, the high bit is set on the first byte and written out. value is then shifted by seven bits and the next byte is written. This process is repeated until the entire integer has been written.
|
private |
Definition at line 162 of file BinaryWriter.h.
|
private |
Returns the byte ordering used by the writer, which is either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.
Definition at line 161 of file BinaryWriter.h.
|
private |
Definition at line 163 of file BinaryWriter.h.