output buffer for a chunked stream This performs buffered output encoding the data in the stream using the simple chunking protocol defined for DAP4's binary data transmission. Each block of data is prefixed by four bytes: A CHUNK TYPE byte followed by three bytes that are the CHUNK SIZE. There are three CHUNK TYPES: data, end and error, indicated by the code values 0x00, 0x01 and 0x02. The size of a chunk is limited to 2^24 data bytes + 4 bytes for the chunk header.
More...
#include <chunked_ostream.h>
|
int_type | data_chunk () |
| Write out the contents of the buffer as a chunk. More...
|
|
int_type | end_chunk () |
| Send an end chunk. More...
|
|
int_type | err_chunk (const std::string &msg) |
| Send an error chunk While building up the next chunk, send an error chunk, ignoring the data currently write buffer. The buffer is left in a consistent state. More...
|
|
virtual int_type | overflow (int c) |
| Virtual method called when the internal buffer would overflow. When the internal buffer fills, this method is called by the byte that would cause that overflow. The buffer pointers have been set so that there is actually space for one more character, so c can really be sent. Put c into the buffer and send it, prefixing the buffer contents with a chunk header. More...
|
|
virtual int_type | sync () |
| Synchronize the stream with its data sink. More...
|
|
virtual std::streamsize | xsputn (const char *s, std::streamsize num) |
| Write bytes to the chunked stream Write the bytes in s to the chunked stream. More...
|
|
output buffer for a chunked stream This performs buffered output encoding the data in the stream using the simple chunking protocol defined for DAP4's binary data transmission. Each block of data is prefixed by four bytes: A CHUNK TYPE byte followed by three bytes that are the CHUNK SIZE. There are three CHUNK TYPES: data, end and error, indicated by the code values 0x00, 0x01 and 0x02. The size of a chunk is limited to 2^24 data bytes + 4 bytes for the chunk header.
Definition at line 53 of file chunked_ostream.h.
◆ chunked_outbuf()
libdap::chunked_outbuf::chunked_outbuf |
( |
std::ostream & |
os, |
|
|
unsigned int |
buf_size |
|
) |
| |
|
inline |
◆ ~chunked_outbuf()
virtual libdap::chunked_outbuf::~chunked_outbuf |
( |
| ) |
|
|
inlinevirtual |
◆ data_chunk()
std::streambuf::int_type libdap::chunked_outbuf::data_chunk |
( |
| ) |
|
|
protected |
Write out the contents of the buffer as a chunk.
- Returns
- EOF on error, otherwise the number of bytes in the chunk body.
Definition at line 54 of file chunked_ostream.cc.
◆ end_chunk()
std::streambuf::int_type libdap::chunked_outbuf::end_chunk |
( |
| ) |
|
|
protected |
Send an end chunk.
This is like calling flush_chunk(), but it sends a chunk header with a type of CHUNK_END (instead of CHUNK_DATA). Whatever is in the buffer is written out, but the stream is can be used to send more chunks.
- Note
- This is called by the chunked_outbuf destructor, so closing a stream using chunked_outbuf always sends a CHUNK_END type chunk, even if it will have zero bytes
- Returns
- EOF on error, otherwise the number of bytes sent in the chunk.
Definition at line 108 of file chunked_ostream.cc.
◆ err_chunk()
std::streambuf::int_type libdap::chunked_outbuf::err_chunk |
( |
const std::string & |
m | ) |
|
|
protected |
Send an error chunk While building up the next chunk, send an error chunk, ignoring the data currently write buffer. The buffer is left in a consistent state.
- Parameters
-
msg | The error message to include in the error chunk |
- Returns
- The number of characters ignored.
Definition at line 150 of file chunked_ostream.cc.
◆ overflow()
std::streambuf::int_type libdap::chunked_outbuf::overflow |
( |
int |
c | ) |
|
|
protectedvirtual |
Virtual method called when the internal buffer would overflow. When the internal buffer fills, this method is called by the byte that would cause that overflow. The buffer pointers have been set so that there is actually space for one more character, so c
can really be sent. Put c
into the buffer and send it, prefixing the buffer contents with a chunk header.
- Note
- This method is called by the std::ostream code.
- Parameters
-
c | The last character to add to the buffer before sending the next chunk. |
- Returns
- EOF on error, otherwise the value of
c
.
Definition at line 205 of file chunked_ostream.cc.
◆ sync()
std::streambuf::int_type libdap::chunked_outbuf::sync |
( |
| ) |
|
|
protectedvirtual |
Synchronize the stream with its data sink.
- Note
- This method is called by flush() among others
- Returns
- -1 on error, 0 otherwise.
Definition at line 329 of file chunked_ostream.cc.
◆ xsputn()
std::streamsize libdap::chunked_outbuf::xsputn |
( |
const char * |
s, |
|
|
std::streamsize |
num |
|
) |
| |
|
protectedvirtual |
Write bytes to the chunked stream Write the bytes in s
to the chunked stream.
- Parameters
-
- Returns
- The number of bytes written
Definition at line 247 of file chunked_ostream.cc.
◆ chunked_ostream
◆ d_big_endian
bool libdap::chunked_outbuf::d_big_endian |
|
protected |
◆ d_buf_size
unsigned int libdap::chunked_outbuf::d_buf_size |
|
protected |
◆ d_buffer
char* libdap::chunked_outbuf::d_buffer |
|
protected |
◆ d_os
std::ostream& libdap::chunked_outbuf::d_os |
|
protected |
The documentation for this class was generated from the following files: