Class ov::util::NativeIfstream#
-
class NativeIfstream : public std::istream#
A read-only std::istream backed by NativeStreamBuf.
Uses native OS file handles and the platform io_read_into backend instead of C-runtime stdio, making it a drop-in replacement for std::ifstream for binary sequential and random-access reads.
Three construction modes:
default constructor: stream not associated with any file; behaves like a default-constructed std::ifstream — reads immediately return EOF.
path constructor (owning): opens a read-only native handle from a path; closes it on destruction.
handle constructor (non-owning): borrows a caller-provided handle for a sub-region [
offset,offset+size); the handle is never closed by this class.
Supports move construction and move assignment (via swap). Copy is deleted.
ov::util::NativeIfstream empty; // default — not associated with any file ov::util::NativeIfstream file(path); // owning — whole file from offset 0 ov::util::NativeIfstream view(handle, off, size); // non-owning — sub-region [off, off+size) file.seekg(blob_offset); file.read(dst, n);
Public Functions
-
NativeIfstream() noexcept#
Constructs a stream not associated with any file. Any read immediately returns EOF.
-
explicit NativeIfstream(const std::filesystem::path &path)#
Opens a read-only native handle from
pathand takes ownership of it.The stream is positioned at the beginning of the file. Use
seekg()to reposition.- Parameters:
path – Path to the file to open.
-
explicit NativeIfstream(FileHandle handle, std::streamoff offset, std::streamoff size)#
Builds a stream over a caller-owned native handle. The handle is never closed by this class.
The caller must keep
handlevalid for the entire lifetime of the stream.- Parameters:
handle – Read-only native handle. Ownership remains with the caller.
offset – Absolute file offset that maps to logical stream position 0.
size – Number of readable bytes from
offset.