libdap::chunked_outbuf Class Reference

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>`

Inheritance diagram for libdap::chunked_outbuf:

## Public Member Functions

| chunked_outbuf (std::ostream &os, unsigned int buf_size)

## Protected Member Functions

int_type | data_chunk ()
| Write out the contents of the buffer as a chunk.
int_type | end_chunk ()
| Send an end chunk.
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.
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.
virtual int_type | sync ()
| Synchronize the stream with its data sink.
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.

## Protected Attributes

bool | d_big_endian
unsigned int | d_buf_size
char * | d_buffer
std::ostream & | d_os

## Friends

class | chunked_ostream

## Detailed Description

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.

## Constructor & Destructor Documentation

## chunked_outbuf()

libdap::chunked_outbuf::chunked_outbuf | ( | std::ostream & | os,
|  | unsigned int | buf_size )

inline

Definition at line 63 of file chunked_ostream.h.

## ~chunked_outbuf()

virtual libdap::chunked_outbuf::~chunked_outbuf | ( |  | ) |

inline virtual

Definition at line 76 of file chunked_ostream.h.

## Member Function Documentation

## 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 53 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 106 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 146 of file chunked_ostream.cc.

## overflow()

std::streambuf::int_type libdap::chunked_outbuf::overflow | ( | int | c | ) |

protected virtual

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 199 of file chunked_ostream.cc.

## sync()

std::streambuf::int_type libdap::chunked_outbuf::sync | ( |  | ) |

protected virtual

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 321 of file chunked_ostream.cc.

## xsputn()

std::streamsize libdap::chunked_outbuf::xsputn | ( | const char * | s,
|  | std::streamsize | num )

protected virtual

Write bytes to the chunked stream Write the bytes in `s` to the chunked stream.

Parameters

  s |
  num |

Returns
  The number of bytes written

Definition at line 239 of file chunked_ostream.cc.

## Friends And Related Symbol Documentation

## chunked_ostream

friend class chunked_ostream

friend

Definition at line 54 of file chunked_ostream.h.

## Member Data Documentation

## d_big_endian

bool libdap::chunked_outbuf::d_big_endian

protected

Definition at line 60 of file chunked_ostream.h.

## d_buf_size

unsigned int libdap::chunked_outbuf::d_buf_size

protected

Definition at line 58 of file chunked_ostream.h.

## d_buffer

char* libdap::chunked_outbuf::d_buffer

protected

Definition at line 59 of file chunked_ostream.h.

## d_os

std::ostream& libdap::chunked_outbuf::d_os

protected

Definition at line 57 of file chunked_ostream.h.

The documentation for this class was generated from the following files:

- chunked_ostream.h
- chunked_ostream.cc