C++ edjLibrary SDK
Loading...
Searching...
No Matches
Public Member Functions | List of all members
edjx::stream::WriteStream Class Reference

This class represents a write stream. More...

#include <stream.hpp>

Inheritance diagram for edjx::stream::WriteStream:
edjx::stream::BaseStream

Public Member Functions

 WriteStream ()
 Constructs a new empty Write Stream object. More...
 
 WriteStream (uint32_t sd)
 Constructs a new initilized Write Stream object. More...
 
edjx::error::StreamError write_chunk (const std::string &text)
 Write a chunk of text into the write stream. More...
 
edjx::error::StreamError write_chunk (const std::vector< uint8_t > &bytes)
 Write a chunk of binary data into the write stream. More...
 
edjx::error::StreamError abort ()
 Aborts sending data and closes the stream. More...
 
- Public Member Functions inherited from edjx::stream::BaseStream
 BaseStream ()
 Constructs a new empty Base Stream object. More...
 
 BaseStream (uint32_t sd)
 Constructs a new initilized Base Stream object. More...
 
uint32_t get_sd () const
 Get the stream descriptor of the stream. More...
 
bool is_initialized () const
 Check whether the stream object has been initialized or not. More...
 
edjx::error::StreamError close ()
 Close the stream. More...
 

Additional Inherited Members

- Protected Attributes inherited from edjx::stream::BaseStream
uint32_t sd
 The stream descriptor. More...
 
bool initialized
 True if the stream is initialized, false if it is closed. More...
 

Detailed Description

This class represents a write stream.

Constructor & Destructor Documentation

◆ WriteStream() [1/2]

edjx::stream::WriteStream::WriteStream ( )
inline

Constructs a new empty Write Stream object.

◆ WriteStream() [2/2]

edjx::stream::WriteStream::WriteStream ( uint32_t  sd)
inline

Constructs a new initilized Write Stream object.

Parameters
sdStream descriptor

Member Function Documentation

◆ abort()

edjx::error::StreamError edjx::stream::WriteStream::abort ( )

Aborts sending data and closes the stream.

This method abruptly ends the streaming.

Difference between close() and abort():

  • When HTTP/1.1 is used:
    • close() sends a terminating chunk of size zero to signalize the end of the stream
    • abort() stops streaming without sending the terminating chunk

Note that close() is not available after abort() is called.

Returns
Returns edjx::error::StreamError::Success on success, some other value on failure.

◆ write_chunk() [1/2]

edjx::error::StreamError edjx::stream::WriteStream::write_chunk ( const std::string &  text)

Write a chunk of text into the write stream.

Parameters
textA chunk of text
Returns
Returns edjx::error::StreamError::Success on success, some other value on failure.

◆ write_chunk() [2/2]

edjx::error::StreamError edjx::stream::WriteStream::write_chunk ( const std::vector< uint8_t > &  bytes)

Write a chunk of binary data into the write stream.

Parameters
bytesA chunk of binary data
Returns
Returns edjx::error::StreamError::Success on success, some other value on failure.

The documentation for this class was generated from the following file: