BufferStream.hpp

This File On Github
Ask A Question

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

BufferOutputStream

BufferOutputStream

namespace oatpp { namespace data { namespace stream { 
  class BufferOutputStream : public ConsistentOutputStream {}
}}}

Methods

Return Type Name Summary
[none] BufferOutputStream Constructor.
[none] ~BufferOutputStream Virtual destructor.
data::v_io_size write Write count of bytes to stream.
void setOutputStreamIOMode Set stream I/O mode.
IOMode getOutputStreamIOMode Get stream I/O mode.
void reserveBytesUpfront Reserve bytes for future writes.
p_char8 getData Get pointer to data.
v_io_size getCapacity Get current capacity.
v_io_size getCurrentPosition Get current data write position.
void setCurrentPosition Set current data write position.
oatpp::String toString Copy data to oatpp::String.
oatpp::String getSubstring Create oatpp::String from part of buffer.
oatpp::data::v_io_size flushToStream Write all bytes from buffer to stream.
oatpp::async::CoroutineStarter flushToStreamAsync Write all bytes from buffer to stream in async manner.

BufferOutputStream::BufferOutputStream

Constructor.

  • @param growBytes

BufferOutputStream(v_io_size initialCapacity = 2048, v_io_size growBytes = 2048)

BufferOutputStream::~BufferOutputStream

Virtual destructor.

~BufferOutputStream()

BufferOutputStream::write

Write count of bytes to stream.

  • @param data - data to write.
  • @param count - number of bytes to write.
  • @return - actual number of bytes written. oatpp::data::v_io_size.

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

BufferOutputStream::setOutputStreamIOMode

Set stream I/O mode.

  • @throws

void setOutputStreamIOMode(IOMode ioMode) override

BufferOutputStream::getOutputStreamIOMode

Get stream I/O mode.

  • @return

IOMode getOutputStreamIOMode() override

BufferOutputStream::reserveBytesUpfront

Reserve bytes for future writes.

void reserveBytesUpfront(v_io_size count)

BufferOutputStream::getData

Get pointer to data.

  • @return - pointer to data.

p_char8 getData()

BufferOutputStream::getCapacity

Get current capacity. Capacity may change.

  • @return

v_io_size getCapacity()

BufferOutputStream::getCurrentPosition

Get current data write position.

  • @return - current data write position.

v_io_size getCurrentPosition()

BufferOutputStream::setCurrentPosition

Set current data write position.

  • @param position - data write position.

void setCurrentPosition(v_io_size position)

BufferOutputStream::toString

Copy data to oatpp::String.

  • @return

oatpp::String toString()

BufferOutputStream::getSubstring

Create oatpp::String from part of buffer.

  • @param pos - starting position in buffer.
  • @param count - size of bytes to write to substring.
  • @return - oatpp::String

oatpp::String getSubstring(data::v_io_size pos, data::v_io_size count)

BufferOutputStream::flushToStream

Write all bytes from buffer to stream.

  • @param stream - stream to flush all data to.
  • @return - actual amount of bytes flushed.

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

BufferOutputStream::flushToStreamAsync

Write all bytes from buffer to stream in async manner.

static oatpp::async::CoroutineStarter flushToStreamAsync(const std::shared_ptr<BufferOutputStream>& _this, const std::shared_ptr<OutputStream>& stream)

BufferInputStream

BufferInputStream

namespace oatpp { namespace data { namespace stream { 
  class BufferInputStream : public InputStream {}
}}}

Methods

Return Type Name Summary
[none] BufferInputStream Multiple implementations:
  1. Constructor.
  2. Constructor.
void reset Multiple implementations:
  1. Reset stream data and set position to 0.
  2. Same as reset(nullptr, nullptr, 0);.
data::v_io_size read Read data from stream.
oatpp::async::Action suggestInputStreamAction In case of a BufferInputStream suggested Action is always oatpp::async::Action::TYPE_REPEAT if ioResult is greater then zero.
void setInputStreamIOMode Set stream I/O mode.
IOMode getInputStreamIOMode Get stream I/O mode.
std::shared_ptr<base::StrBuffer> getDataMemoryHandle Get data memory handle.
p_char8 getData Get pointer to data.
v_io_size getDataSize Get data size.
v_io_size getCurrentPosition Get current data read position.
void setCurrentPosition Set current data read position.

BufferInputStream::BufferInputStream

  1. Constructor.
    • @param memoryHandle - buffer memory handle. May be nullptr.
    • @param data - pointer to buffer data.
    • @param size - size of the buffer.
    BufferInputStream(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_io_size size)
    
  2. Constructor.
    • @param data - buffer.
    BufferInputStream(const oatpp::String& data)
    

BufferInputStream::reset

  1. Reset stream data and set position to 0.
    • @param memoryHandle - buffer memory handle. May be nullptr.
    • @param data - pointer to buffer data.
    • @param size - size of the buffer.
    void reset(const std::shared_ptr<base::StrBuffer>& memoryHandle, p_char8 data, v_io_size size)
    
  2. Same as reset(nullptr, nullptr, 0);.
    void reset()
    

BufferInputStream::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.
  • @return - actual number of bytes read. 0 - designates end of the buffer.

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

BufferInputStream::suggestInputStreamAction

In case of a BufferInputStream suggested Action is always oatpp::async::Action::TYPE_REPEAT if ioResult is greater then zero.

oatpp::async::Action suggestInputStreamAction(data::v_io_size ioResult) override

BufferInputStream::setInputStreamIOMode

Set stream I/O mode.

  • @throws

void setInputStreamIOMode(IOMode ioMode) override

BufferInputStream::getInputStreamIOMode

Get stream I/O mode.

  • @return

IOMode getInputStreamIOMode() override

BufferInputStream::getDataMemoryHandle

Get data memory handle.

  • @return - data memory handle.

std::shared_ptr<base::StrBuffer> getDataMemoryHandle()

BufferInputStream::getData

Get pointer to data.

  • @return - pointer to data.

p_char8 getData()

BufferInputStream::getDataSize

Get data size.

  • @return - data size.

v_io_size getDataSize()

BufferInputStream::getCurrentPosition

Get current data read position.

  • @return - current data read position.

v_io_size getCurrentPosition()

BufferInputStream::setCurrentPosition

Set current data read position.

  • @param position - data read position.

void setCurrentPosition(v_io_size position)