roo_io
API Documentation for roo_io
Loading...
Searching...
No Matches
multipass_input_stream.h
Go to the documentation of this file.
1#pragma once
2
3#include <inttypes.h>
4
6
7namespace roo_io {
8
9/// Virtualizes access to files, memory, and other readable sources.
10///
11/// Represents an open resource with a seekable read cursor.
12///
13/// For iterator-style use, prefer `BufferedMultipassInputStreamIterator` to
14/// avoid virtual-call overhead per byte.
16 public:
17 /// Returns stream size in bytes from beginning.
18 ///
19 /// Value may differ across calls when underlying source mutates.
20 ///
21 /// If pre-call status is neither `kOk` nor `kEndOfStream`, status is
22 /// unchanged and return value is 0.
23 ///
24 /// On error, status updates accordingly and return value is 0.
25 virtual uint64_t size() = 0;
26
27 /// Returns current byte offset from beginning of stream.
28 ///
29 /// If status is neither `kOk` nor `kEndOfStream`, return value is
30 /// unspecified.
31 virtual uint64_t position() const = 0;
32
33 /// Resets stream to starting position.
34 ///
35 /// Updates status.
36 ///
37 /// If pre-call status is neither `kOk` nor `kEndOfStream`, status is
38 /// unchanged.
39 ///
40 /// On success, status becomes `kOk` (clearing EOS if present) and
41 /// `position()` becomes 0.
42 virtual void rewind() { seek(0); }
43
44 /// Seeks to byte offset from beginning.
45 ///
46 /// Offset may be greater than current `size()`.
47 ///
48 /// If pre-call status is neither `kOk` nor `kEndOfStream`, status is
49 /// unchanged.
50 ///
51 /// On success, status becomes `kOk` and `position()` equals `offset`.
52 /// On error, status updates accordingly.
53 virtual void seek(uint64_t offset) = 0;
54};
55
56} // namespace roo_io
Virtualizes access to files, memory, and other readable sources.
Virtualizes access to files, memory, and other readable sources.
virtual uint64_t position() const =0
Returns current byte offset from beginning of stream.
virtual uint64_t size()=0
Returns stream size in bytes from beginning.
virtual void seek(uint64_t offset)=0
Seeks to byte offset from beginning.
virtual void rewind()
Resets stream to starting position.
Definition byte.h:6
roo::basic_string_view< CharT, Traits > basic_string_view
Definition string_view.h:8