|
roo_io
API Documentation for roo_io
|
Virtualizes access to writable sinks (files, memory, devices). More...
#include <output_stream.h>
Public Member Functions | |
| virtual | ~OutputStream () |
| bool | isOpen () const |
| Returns whether stream is considered open. | |
| virtual void | close () |
| Flushes and closes this stream. | |
| virtual size_t | write (const byte *buf, size_t count)=0 |
Attempts to write up to count bytes from buf. | |
| virtual size_t | tryWrite (const byte *buf, size_t count) |
| Attempts to write without indefinite blocking. | |
| virtual size_t | writeFully (const byte *buf, size_t count) |
Attempts to write count bytes from buf. | |
| virtual void | flush () |
| Flushes buffered data to the underlying sink. | |
| virtual Status | status () const =0 |
| Returns underlying stream status. | |
Virtualizes access to writable sinks (files, memory, devices).
Represents an open writable resource.
For iterator-style writes, prefer BufferedOutputStreamIterator to reduce virtual-call overhead per byte.
Definition at line 16 of file output_stream.h.
|
inlinevirtual |
Definition at line 18 of file output_stream.h.
References close().
Flushes and closes this stream.
On success, if status was kOk, status transitions to kClosed. On failure, status reflects encountered error.
Reimplemented in roo_io::NullOutputStream, roo_io::MemoryOutputStream< PtrType >, and roo_io::RingPipeOutputStream.
Definition at line 29 of file output_stream.h.
References flush().
Referenced by roo_io::OutputStreamWriter::close(), roo_io::OutputStreamWriter::reset(), roo_io::OutputStreamWriter::reset(), and ~OutputStream().
Flushes buffered data to the underlying sink.
May update status(). Stream is also flushed on destruction.
Definition at line 92 of file output_stream.h.
Referenced by close(), and roo_io::BufferedOutputStreamIterator::flush().
|
inline |
Returns whether stream is considered open.
true when status() is kOk. Definition at line 23 of file output_stream.h.
References roo_io::kOk, and status().
Returns underlying stream status.
Updated by write/flush operations. Status is either kOk or an error (never kEndOfStream).
Implemented in roo_io::NullOutputStream, roo_io::MemoryOutputStream< PtrType >, and roo_io::RingPipeOutputStream.
Referenced by roo_io::BufferedOutputStreamIterator::flush(), isOpen(), and roo_io::BufferedOutputStreamIterator::write().
Attempts to write without indefinite blocking.
Updates status.
Similar to write(), but may return zero on success if forward progress would require unacceptable blocking.
Repeated tryWrite() calls make forward progress without requiring fallback to write().
Reimplemented in roo_io::RingPipeOutputStream.
Definition at line 59 of file output_stream.h.
References roo_io::count, and write().
Attempts to write up to count bytes from buf.
Updates status.
Contract:
status() == kOk), returns at least one byte.If pre-call status is not kOk, call should have no effect and return zero.
Successful return does not guarantee data reached final sink until flush() succeeds.
Implemented in roo_io::NullOutputStream, roo_io::MemoryOutputStream< PtrType >, and roo_io::RingPipeOutputStream.
Referenced by tryWrite(), roo_io::BufferedOutputStreamIterator::write(), and writeFully().
Attempts to write count bytes from buf.
Updates status via write() calls.
Unlike write(), this method keeps writing until either:
count bytes are written, orIf pre-call status is not kOk, this method returns zero and leaves status unchanged.
Successful write still may be buffered; call flush() to force sink I/O.
Definition at line 77 of file output_stream.h.
References roo_io::count, and write().