MIRA
|
Output stream adapter that can be assigned to any output stream and allows binary output using the << stream operators. More...
#include <stream/BinaryStream.h>
Public Types | |
typedef Base::char_type | char_type |
typedef StreamUnderlay::pos_type | pos_type |
enum | fmtflags { none = 0, net = 1L << 0 } |
Public Member Functions | |
BinaryOstream (streambuffer_pointer buffer) | |
Constructor. More... | |
BinaryOstream (Base &s) | |
Constructor. More... | |
BinaryOstream (Base &s, pos_type pos) | |
Constructor specifying the stream and the current write position. More... | |
BinaryOstream & | operator<< (const char *v) |
stream operator for the built-in C++ datatypes More... | |
BinaryOstream & | operator<< (const std::string &v) |
BinaryOstream & | operator<< (const bool &v) |
BinaryOstream & | operator<< (const char &v) |
BinaryOstream & | operator<< (const uint8 &v) |
BinaryOstream & | operator<< (const uint16 &v) |
BinaryOstream & | operator<< (const uint32 &v) |
BinaryOstream & | operator<< (const uint64 &v) |
BinaryOstream & | operator<< (const int8 &v) |
BinaryOstream & | operator<< (const int16 &v) |
BinaryOstream & | operator<< (const int32 &v) |
BinaryOstream & | operator<< (const int64 &v) |
BinaryOstream & | operator<< (const float &v) |
BinaryOstream & | operator<< (const double &v) |
template<typename T > | |
BinaryOstream & | operator<< (const Buffer< T > &v) |
BinaryOstream & | operator<< (BinaryIosBase &(*manipFn)(BinaryIosBase &)) |
This stream operator is for internal use only. More... | |
template<typename T > | |
void | write (const T *data, std::size_t count) |
BinaryOstream & | writeString (const char *value) |
Method for explicitly writing a C-string to the stream. More... | |
BinaryOstream & | writeString (const std::string &value) |
Method for explicitly writing a STL string to the stream. More... | |
BinaryOstream & | writeString (const char *value, uint32 length) |
Method for explicitly writing the first 'length' characters of the C-string 'value'. More... | |
BinaryOstream & | writeString (const std::string &value, uint32 length) |
Method for explicitly writing the first 'length' characters of the STL-string 'value'. More... | |
fmtflags | setf (fmtflags flags) |
Setting new format flags. More... | |
void | unsetf (fmtflags mask) |
Clearing format flags. More... | |
Public Attributes | |
decltype(std::declval< Base >().rdbuf()) typedef | streambuffer_pointer |
Protected Member Functions | |
template<typename T > | |
BinaryOstream & | toBinary (const T &value) |
Writes every type T to this binary stream. More... | |
Protected Attributes | |
fmtflags | mFmtFlags |
Output stream adapter that can be assigned to any output stream and allows binary output using the << stream operators.
This class can be used with different stream "underlays". The underlay provides the actual stream functionality and stores or transmits the data. Currently the binary stream comes in two flavors:
BinaryStlOstream can be used as adapter to any existing STL conform stream (like file streams, string streams, zip-streams, etc). The resulting binary stream object can be used to put data into the underlying stream in binary format using the <<-operator. Additionally, there exist special manipulators to control the byte-order: 'net' will set the binary stream into network byte order (big endian) mode, while 'host' sets it into host byte order mode (the default).
Example:
BinaryBufferOstream is similar to BinaryStlOstream but stores the data in a Buffer.
Example:
typedef Base::char_type char_type |
typedef StreamUnderlay::pos_type pos_type |
|
inherited |
|
inline |
Constructor.
Constructs an BinaryOstream based on the specified stream buffer object. The stream buffer object must be specified as pointer. If you use BinaryOstream based on STL streams, then the stream buffer object must be of the type std::basic_streambuf<_CharT, _Traits> (see corresponding documentation of STL streams). If you use BinaryOstream based on BinaryBufferStreamBase, the stream buffer object must be of the type std::vector<uint8>.
|
inline |
Constructor.
The underlying output stream must be specified as parameter.
|
inline |
Constructor specifying the stream and the current write position.
|
inline |
stream operator for the built-in C++ datatypes
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
This stream operator is for internal use only.
It provides an interface for stream manipulators like net and host. The manipulators are passed as function pointers. The passed manipulator functions are then called with the binary stream object as parameter (same mechanism as ios_base with manipulators hex, oct, etc).
|
inline |
|
inline |
Method for explicitly writing a C-string to the stream.
stream.writeString(string) has the same effect as stream << string;
|
inline |
Method for explicitly writing a STL string to the stream.
stream.writeString(string) has the same effect as stream << string;
|
inline |
Method for explicitly writing the first 'length' characters of the C-string 'value'.
|
inline |
Method for explicitly writing the first 'length' characters of the STL-string 'value'.
|
inlineprotected |
Writes every type T to this binary stream.
Can be used for native C++ types or POD.
Setting new format flags.
flags | Additional flags to set. |
This function sets additional flags in format control. Flags that were previously set remain set.
|
inlineinherited |
Clearing format flags.
mask | The flags to unset. |
This function clears mask in the format flags.
decltype(std::declval<Base>().rdbuf()) typedef streambuffer_pointer |
|
protectedinherited |