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 : public std::enable_shared_from_this<FIFOBuffer> {}
}}}

Methods

Return Type Name Summary
[none] FIFOBuffer Constructor.
void setBufferPosition Set read and write positions in buffer.
data::v_io_size availableToRead Amount of bytes currently available to read from buffer.
data::v_io_size availableToWrite Amount of buffer space currently available for data writes.
data::v_io_size getBufferSize Get FIFOBuffer size.
data::v_io_size read read up to count bytes from the buffer to data
data::v_io_size write write up to count bytes from data to buffer
data::v_io_size readAndWriteToStream call read and then write bytes read to output stream
data::v_io_size readFromStreamAndWrite call stream.read() and then write bytes read to buffer
data::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_io_size bufferSize,
           data::v_io_size readPosition = 0, data::v_io_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(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead)

FIFOBuffer::availableToRead

Amount of bytes currently available to read from buffer.

data::v_io_size availableToRead() const

FIFOBuffer::availableToWrite

Amount of buffer space currently available for data writes.

data::v_io_size availableToWrite() const

FIFOBuffer::getBufferSize

Get FIFOBuffer size.

  • @return - FIFOBuffer size.

data::v_io_size getBufferSize() const

FIFOBuffer::read

read up to count bytes from the buffer to data

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

data::v_io_size read(void *data, data::v_io_size count)

FIFOBuffer::write

write up to count bytes from data to buffer

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

data::v_io_size write(const void *data, data::v_io_size count)

FIFOBuffer::readAndWriteToStream

call read and then write bytes read to output stream

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

data::v_io_size readAndWriteToStream(data::stream::OutputStream* stream, data::v_io_size count)

FIFOBuffer::readFromStreamAndWrite

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

  • @param stream
  • @param count
  • @return

data::v_io_size readFromStreamAndWrite(data::stream::InputStream* stream, data::v_io_size count)

FIFOBuffer::flushToStream

flush all availableToRead bytes to stream

  • @param stream
  • @return

data::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.
data::v_io_size availableToRead Amount of bytes currently available to read from buffer.
data::v_io_size availableToWrite Amount of buffer space currently available for data writes.
data::v_io_size read read up to count bytes from the buffer to data
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_io_size bufferSize,
                       data::v_io_size readPosition = 0, data::v_io_size writePosition = 0,
                       bool canRead = false)

SynchronizedFIFOBuffer::setBufferPosition

Set read and write positions in buffer.

void setBufferPosition(data::v_io_size readPosition, data::v_io_size writePosition, bool canRead)

SynchronizedFIFOBuffer::availableToRead

Amount of bytes currently available to read from buffer.

data::v_io_size availableToRead()

SynchronizedFIFOBuffer::availableToWrite

Amount of buffer space currently available for data writes.

data::v_io_size availableToWrite()

SynchronizedFIFOBuffer::read

read up to count bytes from the buffer to data

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

data::v_io_size read(void *data, data::v_io_size count)

SynchronizedFIFOBuffer::write

write up to count bytes from data to buffer

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

data::v_io_size write(const void *data, data::v_io_size count)