In-memory stream of bytes.
More...
#include <binary_serializer.h>
|
| | ByteStream () |
| | Create empty stream. More...
|
| |
| | ByteStream (size_t n) |
| | Create stream with n readable bytes initialized to 0. More...
|
| |
| size_t | data_size () const |
| | Get the size of the buffer of the stream. More...
|
| |
| bool | read (unsigned char *p, size_t s) |
| | Read bytes from the stream. More...
|
| |
| void | reset () |
| | Reset the stream to empty. More...
|
| |
| void | reset (size_t n) |
| | Reset the stream to n readable bytes of value 0. More...
|
| |
| void | write (const unsigned char *const p, size_t s) |
| | Write bytes to the stream. More...
|
| |
|
| const unsigned char * | data () const |
| | Get the pointer to the buffer of the stream. More...
|
| |
| unsigned char * | data () |
| | Get the pointer to the buffer of the stream. More...
|
| |
|
| std::vector< unsigned char > | m_buf |
| | store of written/readable bytes More...
|
| |
| size_t | m_read_head |
| | index in the buffer where next byte is read/written More...
|
| |
In-memory stream of bytes.
◆ ByteStream() [1/2]
| mio::ByteStream::ByteStream |
( |
size_t |
n | ) |
|
|
inline |
Create stream with n readable bytes initialized to 0.
The value of the readable bytes can be set through the pointer returned by the data() member function.
- Parameters
-
| n | number of readable bytes. |
◆ ByteStream() [2/2]
| mio::ByteStream::ByteStream |
( |
| ) |
|
|
inline |
◆ data() [1/2]
| unsigned char* mio::ByteStream::data |
( |
| ) |
|
|
inline |
Get the pointer to the buffer of the stream.
◆ data() [2/2]
| const unsigned char* mio::ByteStream::data |
( |
| ) |
const |
|
inline |
Get the pointer to the buffer of the stream.
◆ data_size()
| size_t mio::ByteStream::data_size |
( |
| ) |
const |
|
inline |
Get the size of the buffer of the stream.
◆ read()
| bool mio::ByteStream::read |
( |
unsigned char * |
p, |
|
|
size_t |
s |
|
) |
| |
|
inline |
Read bytes from the stream.
- Parameters
-
| p | pointer to buffer to read bytes into. |
| s | number of bytes to read. |
- Returns
- true if bytes can be read, false if there are not enough readable bytes in the stream.
◆ reset() [1/2]
| void mio::ByteStream::reset |
( |
| ) |
|
|
inline |
Reset the stream to empty.
◆ reset() [2/2]
| void mio::ByteStream::reset |
( |
size_t |
n | ) |
|
|
inline |
Reset the stream to n readable bytes of value 0.
- Parameters
-
| n | number of readable bytes. |
◆ write()
| void mio::ByteStream::write |
( |
const unsigned char *const |
p, |
|
|
size_t |
s |
|
) |
| |
|
inline |
Write bytes to the stream.
- Parameters
-
| p | pointer to bytes to be written. |
| s | number of bytes to write. |
◆ m_buf
| std::vector<unsigned char> mio::ByteStream::m_buf |
|
private |
store of written/readable bytes
◆ m_read_head
| size_t mio::ByteStream::m_read_head |
|
private |
index in the buffer where next byte is read/written