#include <chunked_istream.h>
|
int | bytes_in_buffer () const |
|
| chunked_inbuf (std::istream &is, int size) |
| Build a chunked input buffer.
|
|
bool | error () const |
|
std::string | error_message () const |
|
int_type | read_next_chunk () |
| Read a chunk Normally the chunked nature of a chunked_istream/chunked_inbuf is hidden from the caller. This method provides a way to get one chunk from the stream by forcing its read and returning the size. A subsequent call to read() for that number of bytes will return all of the data in the chunk. If there is any data in the chunk_inbuf object's buffer, it is lost.
|
|
bool | twiddle_bytes () const |
|
virtual | ~chunked_inbuf () |
|
|
virtual int_type | underflow () |
| Insert new characters into the buffer This specialization of underflow is called when the gptr() is advanced to the end of the input buffer. At that point it calls the underlying I/O stream to read the next chunk of data and transfers the data read to the internal buffer. If an error is found, EOF is returned. If an END chunk with zero bytes is found, an EOF is returned.
|
|
virtual std::streamsize | xsgetn (char *s, std::streamsize num) |
| Read a block of data This specialization of xsgetn() reads num bytes and puts them in s first reading from the internal beffer and then from the stream. Any characters read from the last chunk that won't fit in to s are put in the buffer, otherwise all data are read directly into s , bypassing the internal buffer (and the extra copy operation that would imply). If the END chunk is found EOF is not returned and the final read of the underlying stream is not made; the next call to read(), get(), ..., will return EOF.
|
|
Definition at line 42 of file chunked_istream.h.
◆ chunked_inbuf()
libdap::chunked_inbuf::chunked_inbuf |
( |
std::istream & | is, |
|
|
int | size ) |
|
inline |
Build a chunked input buffer.
This reads from a chunked stream, extracting an entire chunk and storing it in a buffer in one operation. If the chunked_inbuf reads a chunk header that indicates the next chunk is going be bigger than its current buffer size, the object will make the buffer larger. This object support 128 characters of 'put back' space. Since DAP4 uses receiver makes right, the buffer must be told if it should 'twiddle' the header size information. In DAP4 the byte order is sent using a one-byte code before the chunked transmission starts.
- Note
- In the current implementation, the byte order of the sender is read from the first chunk header. The method twiddle_bytes() returns false until the first chunk is read, then it returns the correct value. Only the first chunk_header is tested for the byte order flag; all subsequent chunks are assumed to use the same byte order.
- Parameters
-
is | Use this as a data source |
size | The size of the input buffer. This should match the likely chunk size. If it is smaller than a chunk, it will be resized. |
twiddle_bytes | Should the header bytes be twiddled? True if this host and the send use a different byte-order. The sender's byte order must be sent out-of-band. |
Definition at line 98 of file chunked_istream.h.
◆ ~chunked_inbuf()
virtual libdap::chunked_inbuf::~chunked_inbuf |
( |
| ) |
|
|
inlinevirtual |
◆ bytes_in_buffer()
int libdap::chunked_inbuf::bytes_in_buffer |
( |
| ) |
const |
|
inline |
◆ error()
bool libdap::chunked_inbuf::error |
( |
| ) |
const |
|
inline |
◆ error_message()
std::string libdap::chunked_inbuf::error_message |
( |
| ) |
const |
|
inline |
◆ read_next_chunk()
std::streambuf::int_type libdap::chunked_inbuf::read_next_chunk |
( |
| ) |
|
Read a chunk Normally the chunked nature of a chunked_istream/chunked_inbuf is hidden from the caller. This method provides a way to get one chunk from the stream by forcing its read and returning the size. A subsequent call to read() for that number of bytes will return all of the data in the chunk. If there is any data in the chunk_inbuf object's buffer, it is lost.
- Returns
- The number of bytes read, which is exactly the size of the next chunk in the stream. Returns EOF on error.
Definition at line 338 of file chunked_istream.cc.
◆ twiddle_bytes()
bool libdap::chunked_inbuf::twiddle_bytes |
( |
| ) |
const |
|
inline |
◆ underflow()
std::streambuf::int_type libdap::chunked_inbuf::underflow |
( |
| ) |
|
|
protectedvirtual |
Insert new characters into the buffer This specialization of underflow is called when the gptr() is advanced to the end of the input buffer. At that point it calls the underlying I/O stream to read the next chunk of data and transfers the data read to the internal buffer. If an error is found, EOF is returned. If an END chunk with zero bytes is found, an EOF is returned.
- Returns
- The character at the gptr() or EOF
Definition at line 83 of file chunked_istream.cc.
◆ xsgetn()
std::streamsize libdap::chunked_inbuf::xsgetn |
( |
char * | s, |
|
|
std::streamsize | num ) |
|
protectedvirtual |
Read a block of data This specialization of xsgetn() reads num
bytes and puts them in s
first reading from the internal beffer and then from the stream. Any characters read from the last chunk that won't fit in to s
are put in the buffer, otherwise all data are read directly into s
, bypassing the internal buffer (and the extra copy operation that would imply). If the END chunk is found EOF is not returned and the final read of the underlying stream is not made; the next call to read(), get(), ..., will return EOF.
- Parameters
-
s | Address of a buffer to hold the data |
num | Number of bytes to read |
- Returns
- NUmber of bytes actually transferred into
s
. Note that this number does not include the bytes read from the last chunk that won't fit into s
so this will never return a number greater than num.
Definition at line 183 of file chunked_istream.cc.
The documentation for this class was generated from the following files: