Very Simple Cross-Platform Library
Public Member Functions | List of all members
hu::varadiistvan::scpl::io::WritingBuffer Class Reference

#include <WritingBuffer.h>

Inheritance diagram for hu::varadiistvan::scpl::io::WritingBuffer:
hu::varadiistvan::scpl::io::Buffer hu::varadiistvan::scpl::io::FailableReference< WritingBuffer >

Public Member Functions

void reset ()
 
bool write ()
 
- Public Member Functions inherited from hu::varadiistvan::scpl::io::Buffer
 Buffer (size_t capacity)
 
 ~Buffer ()
 
size_t getCapacity () const
 
const unsigned char * getData () const
 
unsigned char * getData ()
 
size_t getLength () const
 
bool isEmpty () const
 
size_t getAvailable () const
 
void reset ()
 
size_t addLength (size_t n)
 
size_t append (const void *src, size_t size)
 
size_t extract (void *dest, size_t size, size_t offset=0) const
 
- Public Member Functions inherited from hu::varadiistvan::scpl::io::FailableReference< WritingBuffer >
bool failed () const
 
errorCode_t getErrorCode () const
 
void repair ()
 

Detailed Description

A buffer used for writing into a buffered stream. It cannot be created directly, only acquired from the stream.

The data to write should be stored in the buffer. Then write() should be called. If it returns true, it indicates that all data has been written. In that case the buffer is automatically emptied.

Definition at line 49 of file WritingBuffer.h.

Member Function Documentation

◆ reset()

void hu::varadiistvan::scpl::io::WritingBuffer::reset ( )

Reset the buffer. It resets the offset too.

◆ write()

bool hu::varadiistvan::scpl::io::WritingBuffer::write ( )

Write the contents of the buffer using the associated buffered stream.

If the buffer is empty, the function returns indicating success.

If the complete remaining contents could be written, it also indicates success, and the buffer is reset, ready to be used again.

If not everything can be written and the write operation indicates that it would block, this function returns failure after the stream has been set up to handle the corresponding poll events.

Otherwise, if the writing operation fails for some other reason, the buffer's error code is set to the error's code and false is returned.


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