# FIFOStream.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/data/stream/FIFOStream.hpp"

# FIFOInputStream

FIFOInputStream

namespace oatpp { namespace data { namespace stream { 
  class FIFOInputStream : public BufferedInputStream, public WriteCallback {}
}}}

# Methods

Return Type Name Summary
[none] FIFOInputStream Constructor.
void reset Discards all data in the buffer and resets it to an empty state
v_io_size read Read data from stream.
void setInputStreamIOMode Set stream I/O mode.
IOMode getInputStreamIOMode Get stream I/O mode.
Context& getInputStreamContext Get stream context.
std::shared_ptr<std::string> getDataMemoryHandle Get data memory handle.
v_io_size write Write operation callback.
v_io_size peek Peek up to count of bytes int he buffer
v_io_size availableToRead Amount of bytes currently available to read from buffer.
v_io_size commitReadOffset Commit read offset
void reserveBytesUpfront Reserve bytes for future writes. Check oatpp::data::stream::FIFOStream::availableToWrite for the capacity.
v_io_size readAndWriteToStream call read and then write bytes read to output stream
v_io_size readFromStreamAndWrite call stream.read() and then write bytes read to buffer
v_io_size flushToStream flush all availableToRead bytes to stream
async::CoroutineStarter flushToStreamAsync flush all availableToRead bytes to stream in asynchronous manner
v_io_size availableToWrite Amount of buffer space currently available for data writes.

# FIFOInputStream::FIFOInputStream

Constructor.

  • @param data - buffer.

FIFOInputStream(v_buff_size initialSize = 4096)

# FIFOInputStream::reset

Discards all data in the buffer and resets it to an empty state

void reset()

# FIFOInputStream::read

Read data from stream.
It is a legal case if return result < count. Caller should handle this! Calls to this method are always NON-BLOCKING

  • @param data - buffer to read data to.
  • @param count - size of the buffer.
  • @param action - async specific action. If action is NOT oatpp::async::Action::TYPE_NONE, then caller MUST return this action on coroutine iteration.
  • @return - actual number of bytes read. 0 - designates end of the buffer.

v_io_size read(void *data, v_buff_size count, async::Action& action) override

# FIFOInputStream::setInputStreamIOMode

Set stream I/O mode.

  • @throws

void setInputStreamIOMode(IOMode ioMode) override

# FIFOInputStream::getInputStreamIOMode

Get stream I/O mode.

  • @return

IOMode getInputStreamIOMode() override

# FIFOInputStream::getInputStreamContext

Get stream context.

  • @return

Context& getInputStreamContext() override

# FIFOInputStream::getDataMemoryHandle

Get data memory handle.

  • @return - data memory handle.

std::shared_ptr<std::string> getDataMemoryHandle()

# FIFOInputStream::write

Write operation callback.

  • @param data - pointer to data.
  • @param count - size of the data in bytes.
  • @param action - async specific action. If action is NOT oatpp::async::Action::TYPE_NONE, then caller MUST return this action on coroutine iteration.
  • @return - actual number of bytes written. 0 - to indicate end-of-file.

v_io_size write(const void *data, v_buff_size count, async::Action &action) override

# FIFOInputStream::peek

Peek up to count of bytes int he buffer

  • @param data
  • @param count
  • @return [1..count], IOErrors.

v_io_size peek(void *data, v_buff_size count, async::Action& action) override

# FIFOInputStream::availableToRead

Amount of bytes currently available to read from buffer.

v_io_size availableToRead() const override

# FIFOInputStream::commitReadOffset

Commit read offset

  • @param count
  • @return [1..count], IOErrors.

v_io_size commitReadOffset(v_buff_size count) override

# FIFOInputStream::reserveBytesUpfront

Reserve bytes for future writes. Check oatpp::data::stream::FIFOStream::availableToWrite for the capacity.

void reserveBytesUpfront(v_buff_size count)

# FIFOInputStream::readAndWriteToStream

call read and then write bytes read to output stream

  • @param stream
  • @param count
  • @param action
  • @return [1..count], IOErrors.

v_io_size readAndWriteToStream(data::stream::OutputStream* stream, v_buff_size count, async::Action& action)

# FIFOInputStream::readFromStreamAndWrite

call stream.read() and then write bytes read to buffer

  • @param stream
  • @param count
  • @param action
  • @return

v_io_size readFromStreamAndWrite(data::stream::InputStream* stream, v_buff_size count, async::Action& action)

# FIFOInputStream::flushToStream

flush all availableToRead bytes to stream

  • @param stream
  • @return

v_io_size flushToStream(data::stream::OutputStream* stream)

# FIFOInputStream::flushToStreamAsync

flush all availableToRead bytes to stream in asynchronous manner

  • @param stream - data::stream::OutputStream.
  • @return - async::CoroutineStarter.

async::CoroutineStarter flushToStreamAsync(const std::shared_ptr<data::stream::OutputStream>& stream)

# FIFOInputStream::availableToWrite

Amount of buffer space currently available for data writes.

v_io_size availableToWrite()