roo_io
API Documentation for roo_io
Loading...
Searching...
No Matches
output_iterator.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#include "roo_io/base/byte.h"
6#include "roo_io/status.h"
7
8/// Output iterator contract for byte sinks.
9///
10/// Use this in performance-critical paths where byte-level writes are inlined.
11///
12/// Baseline contract:
13/// @code
14/// class MyOutputIterator {
15/// public:
16/// // Iterator is movable.
17/// // MyOutputIterator(MyOutputIterator&& other);
18///
19/// // Writes one byte and updates status().
20/// // If pre-call status != kOk, call has no effect.
21/// // On success, status remains kOk.
22/// void write(byte v);
23///
24/// // Writes up to count bytes and updates status().
25/// // Returns >0 on success (kOk), 0 or more on error (bytes written before
26/// // failure).
27/// // If pre-call status != kOk, call has no effect and return value is 0.
28/// size_t write(const byte* buf, size_t count);
29///
30/// // Flushes buffered data to sink and updates status().
31/// // If pre-call status != kOk, call may be treated as no-op.
32/// void flush();
33///
34/// // Returns current status.
35/// // Value is kOk or an error (never kEndOfStream).
36/// Status status() const;
37/// };
38/// @endcode