FIFOBuffer.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/data/buffer/FIFOBuffer.hpp"

FIFOBuffer

FIFO operations over the buffer !FIFOBuffer is NOT an IOStream despite having similar APIs!

namespace oatpp { namespace data { namespace buffer { 
  class FIFOBuffer {}
}}}

Methods

Return Type Name Summary
[none] FIFOBuffer Constructor.
void setBufferPosition Set read and write positions in buffer.
v_io_size availableToRead Amount of bytes currently available to read from buffer.
v_io_size availableToWrite Amount of buffer space currently available for data writes.
v_buff_size getBufferSize Get FIFOBuffer size.
v_io_size read read up to count bytes from the buffer to data
v_io_size peek Peek up to count of bytes int he buffer
v_io_size commitReadOffset Commit read offset
v_io_size write write up to count bytes from data to buffer
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

FIFOBuffer::FIFOBuffer

Constructor.

  • @param buffer - pointer to buffer used for reads/writes.
  • @param bufferSize - buffer size.
  • @param readPosition - initial read position in buffer.
  • @param writePosition - initial write position in buffer.
  • @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition canRead) then FIFOBuffer::availableToRead() returns buffer size, and FIFOBuffer::availableToWrite() returns 0.

FIFOBuffer(void* buffer, v_buff_size bufferSize,
           v_buff_size readPosition = 0, v_buff_size writePosition = 0,
           bool canRead = false)

FIFOBuffer::setBufferPosition

Set read and write positions in buffer.

  • @param readPosition - read position in buffer.
  • @param writePosition - write position in buffer.
  • @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition canRead) then FIFOBuffer::availableToRead() returns buffer size, and FIFOBuffer::availableToWrite() returns 0.

void setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead)

FIFOBuffer::availableToRead

Amount of bytes currently available to read from buffer.

v_io_size availableToRead() const

FIFOBuffer::availableToWrite

Amount of buffer space currently available for data writes.

v_io_size availableToWrite() const

FIFOBuffer::getBufferSize

Get FIFOBuffer size.

  • @return - FIFOBuffer size.

v_buff_size getBufferSize() const

FIFOBuffer::read

read up to count bytes from the buffer to data

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

v_io_size read(void *data, v_buff_size count)

FIFOBuffer::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)

FIFOBuffer::commitReadOffset

Commit read offset

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

v_io_size commitReadOffset(v_buff_size count)

FIFOBuffer::write

write up to count bytes from data to buffer

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

v_io_size write(const void *data, v_buff_size count)

FIFOBuffer::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)

FIFOBuffer::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)

FIFOBuffer::flushToStream

flush all availableToRead bytes to stream

  • @param stream
  • @return

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

FIFOBuffer::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)

SynchronizedFIFOBuffer

Same as FIFOBuffer + synchronization with SpinLock

namespace oatpp { namespace data { namespace buffer { 
  class SynchronizedFIFOBuffer {}
}}}

Methods

Return Type Name Summary
[none] SynchronizedFIFOBuffer Constructor.
void setBufferPosition Set read and write positions in buffer.
v_io_size availableToRead Amount of bytes currently available to read from buffer.
v_io_size availableToWrite Amount of buffer space currently available for data writes.
v_io_size read read up to count bytes from the buffer to data
v_io_size write write up to count bytes from data to buffer

SynchronizedFIFOBuffer::SynchronizedFIFOBuffer

Constructor.

  • @param buffer - pointer to buffer used for reads/writes.
  • @param bufferSize - buffer size.
  • @param readPosition - initial read position in buffer.
  • @param writePosition - initial write position in buffer.
  • @param canRead - flag to resolve ambiguity when readPosition == writePosition. If(readPosition == writePosition canRead) then SynchronizedFIFOBuffer::availableToRead() returns buffer size, and SynchronizedFIFOBuffer::availableToWrite() returns 0.

SynchronizedFIFOBuffer(void* buffer, v_buff_size bufferSize,
                       v_buff_size readPosition = 0, v_buff_size writePosition = 0,
                       bool canRead = false)

SynchronizedFIFOBuffer::setBufferPosition

Set read and write positions in buffer.

void setBufferPosition(v_buff_size readPosition, v_buff_size writePosition, bool canRead)

SynchronizedFIFOBuffer::availableToRead

Amount of bytes currently available to read from buffer.

v_io_size availableToRead()

SynchronizedFIFOBuffer::availableToWrite

Amount of buffer space currently available for data writes.

v_io_size availableToWrite()

SynchronizedFIFOBuffer::read

read up to count bytes from the buffer to data

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

v_io_size read(void *data, v_buff_size count)

SynchronizedFIFOBuffer::write

write up to count bytes from data to buffer

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

v_io_size write(const void *data, v_buff_size count)