libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
|
A C++ stream class for chunked data. This class uses the chunked_outbuf class to provide for chunked binary serialization of data as specified by DAP4. Information to be serialized is broken into 'chunks' that are no more than 2^24 bytes in length. Each chunk is prefixed by a 4 byte header that indicates the type of chunk and size (number of bytes in the chunk body). There are three types of chunk: Data; End; and Error. In normal operation, a DAP4 data document/response is serialized as a sequence of DATA chunks followed by one END chunk (which may be zero bytes in length). If, during serialization, an error is detected, the currently buffered (but not sent) data are discarded and an ERROR chunk is sent with an error message. More...
#include <chunked_ostream.h>
Public Member Functions | |
chunked_ostream (std::ostream &os, unsigned int buf_size) | |
int_type | write_data_chunk () |
Send the current contents of the buffer as a data chunk. Normally, the chunked_ostream object waits until the buffer is full before sending the next data chunk. This will force a send with whatever is in the buffer (e.g., the DMR text). Data added after this call will be sent in subsequent chunks. | |
int_type | write_end_chunk () |
Send an end chunk. Normally, an end chunk is sent by closing the chunked_ostream, but this method can be used to force sending it without closing the stream. Subsequent calls to send data will send data chunks. | |
int_type | write_err_chunk (const std::string &msg) |
Send an error message down the stream. When called, this method dumps all the data currently in the buffer and sends the error message text instead, using a chunk type of CHUNK_ERR. The write buffer is maintained, however, so the stream ibject can still be used. | |
Protected Attributes | |
chunked_outbuf | d_cbuf |
A C++ stream class for chunked data. This class uses the chunked_outbuf class to provide for chunked binary serialization of data as specified by DAP4. Information to be serialized is broken into 'chunks' that are no more than 2^24 bytes in length. Each chunk is prefixed by a 4 byte header that indicates the type of chunk and size (number of bytes in the chunk body). There are three types of chunk: Data; End; and Error. In normal operation, a DAP4 data document/response is serialized as a sequence of DATA chunks followed by one END chunk (which may be zero bytes in length). If, during serialization, an error is detected, the currently buffered (but not sent) data are discarded and an ERROR chunk is sent with an error message.
This class sends the END chunk when its destructor is called.
Calling flush() on the ostream object will force a DATA chunk to be sent with the currently buffered data. Normal operation is to wait for the buffer to fill before sending a DATA chunk.
Definition at line 122 of file chunked_ostream.h.
|
inline |
Get a chunked_ostream with a buffer.
buf_size | The size of the buffer in bytes. |
Definition at line 132 of file chunked_ostream.h.
|
inline |
Send the current contents of the buffer as a data chunk. Normally, the chunked_ostream object waits until the buffer is full before sending the next data chunk. This will force a send with whatever is in the buffer (e.g., the DMR text). Data added after this call will be sent in subsequent chunks.
Definition at line 152 of file chunked_ostream.h.
|
inline |
Send an end chunk. Normally, an end chunk is sent by closing the chunked_ostream, but this method can be used to force sending it without closing the stream. Subsequent calls to send data will send data chunks.
Definition at line 142 of file chunked_ostream.h.
|
inline |
Send an error message down the stream. When called, this method dumps all the data currently in the buffer and sends the error message text instead, using a chunk type of CHUNK_ERR. The write buffer is maintained, however, so the stream ibject can still be used.
msg | The error message text |
Definition at line 162 of file chunked_ostream.h.
|
protected |
Definition at line 124 of file chunked_ostream.h.