Stream.hpp

This File On Github
Ask A Question

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

OutputStream

Output Stream.

namespace oatpp { namespace data { namespace stream { 
  class OutputStream {}
}}}

Methods

Return Type Name Summary
[none] ~OutputStream Default virtual destructor.
data::v_io_size write Multiple implementations:
  1. Write data to stream up to count bytes, and return number of bytes actually written
  2. Same as write((p_char8)data, std::strlen(data));.
  3. Same as write(str->getData(), str->getSize());
data::v_io_size writeChar Same as write(c, 1);.
data::v_io_size writeAsString Multiple implementations:
  1. Convert value to string and write to stream.
  2. Convert value to string and write to stream.
  3. Convert value to string and write to stream.
  4. Convert value to string and write to stream.
  5. Convert value to string and write to stream.

OutputStream::~OutputStream

Default virtual destructor.

virtual ~OutputStream() = default

OutputStream::write

  1. Write data to stream up to count bytes, and return number of bytes actually written It is a legal case if return result < count. Caller should handle this!
    • @param data - data to write.
    • @param count - number of bytes to write.
    • @return - actual number of bytes written. oatpp::data::v_io_size.
    virtual data::v_io_size write(const void *data, data::v_io_size count) = 0
    
  2. Same as write((p_char8)data, std::strlen(data));.
    data::v_io_size write(const char* data)
    
  3. Same as write(str->getData(), str->getSize());
    data::v_io_size write(const oatpp::String& str)
    

OutputStream::writeChar

Same as write(c, 1);.

data::v_io_size writeChar(v_char8 c)

OutputStream::writeAsString

  1. Convert value to string and write to stream.
    • @param value
    • @return - actual number of bytes written. oatpp::data::v_io_size.
      Careful!!! - use this method on your own risk as it's hard to understand if all data was written to stream.
    data::v_io_size writeAsString(v_int32 value)
    
  2. Convert value to string and write to stream.
    • @param value
    • @return - actual number of bytes written. oatpp::data::v_io_size.
      Careful!!! - use this method on your own risk as it's hard to understand if all data was written to stream.
    data::v_io_size writeAsString(v_int64 value)
    
  3. Convert value to string and write to stream.
    • @param value
    • @return - actual number of bytes written. oatpp::data::v_io_size.
      Careful!!! - use this method on your own risk as it's hard to understand if all data was written to stream.
    data::v_io_size writeAsString(v_float32 value)
    
  4. Convert value to string and write to stream.
    • @param value
    • @return - actual number of bytes written. oatpp::data::v_io_size.
      Careful!!! - use this method on your own risk as it's hard to understand if all data was written to stream.
    data::v_io_size writeAsString(v_float64 value)
    
  5. Convert value to string and write to stream.
    • @param value
    • @return - actual number of bytes written. oatpp::data::v_io_size.
      Careful!!! - use this method on your own risk as it's hard to understand if all data was written to stream.
    data::v_io_size writeAsString(bool value)
    

InputStream

Input Stream.

namespace oatpp { namespace data { namespace stream { 
  class InputStream {}
}}}

Methods

Return Type Name Summary
[none] ~InputStream Default virtual destructor.
data::v_io_size read Read data from stream up to count bytes, and return number of bytes actually read

InputStream::~InputStream

Default virtual destructor.

virtual ~InputStream() = default

InputStream::read

Read data from stream up to count bytes, and return number of bytes actually read It is a legal case if return result < count. Caller should handle this!

  • @param data - buffer to read dat to.
  • @param count - size of the buffer.
  • @return - actual number of bytes read.

virtual data::v_io_size read(void *data, data::v_io_size count) = 0

IOStream

I/O Stream.

namespace oatpp { namespace data { namespace stream { 
  class IOStream : public InputStream, public OutputStream {}
}}}

transfer

Namespace: oatpp::data::stream

Read bytes from fromStream" and write to toStream" using buffer of size bufferSize transfer up to transferSize or until error if transferSize == 0 throws in case readCount != writeCount

oatpp::data::v_io_size transfer(const std::shared_ptr<InputStream>& fromStream,
                                        const std::shared_ptr<OutputStream>& toStream,
                                        oatpp::data::v_io_size transferSize,
                                        void* buffer,
                                        oatpp::data::v_io_size bufferSize)

transferAsync

Namespace: oatpp::data::stream

Same as transfer but asynchronous

oatpp::async::CoroutineStarter transferAsync(const std::shared_ptr<InputStream>& fromStream,
                                     const std::shared_ptr<OutputStream>& toStream,
                                     oatpp::data::v_io_size transferSize,
                                     const std::shared_ptr<oatpp::data::buffer::IOBuffer>& buffer)

readExactSizeData

Namespace: oatpp::data::stream

Read exact amount of bytes to stream returns exact amount of bytes was read. return result can be < size only in case of some disaster like connection reset by peer

oatpp::data::v_io_size readExactSizeData(oatpp::data::stream::InputStream* stream, void* data, data::v_io_size size)

writeExactSizeData

Namespace: oatpp::data::stream

Write exact amount of bytes to stream. returns exact amount of bytes was written. return result can be < size only in case of some disaster like broken pipe

oatpp::data::v_io_size writeExactSizeData(oatpp::data::stream::OutputStream* stream, const void* data, data::v_io_size size)