Class Stream#
Defined in File io.h
Inheritance Relationships#
Derived Types#
public tvm::support::BytesInStream(Class BytesInStream)public tvm::support::BytesOutStream(Class BytesOutStream)
Class Documentation#
-
class Stream#
Abstract binary stream for serialization.
Subclasses implement the raw Read/Write byte methods. The template Write/Read methods delegate to Serializer for endian-aware, type-safe binary I/O.
Note
Subclasses that override Read(void*, size_t) or Write(const void*, size_t) must add
using Stream::Read;andusing Stream::Write;to make the template overloads visible (C++ name-hiding rule).Subclassed by tvm::support::BytesInStream, tvm::support::BytesOutStream
Public Functions
-
virtual size_t Read(void *ptr, size_t size) = 0#
Read raw bytes from the stream.
- Parameters:
ptr – Destination buffer.
size – Number of bytes to read.
- Returns:
Number of bytes actually read.
-
virtual size_t Write(const void *ptr, size_t size) = 0#
Write raw bytes to the stream.
- Parameters:
ptr – Source buffer.
size – Number of bytes to write.
- Returns:
Number of bytes actually written.
-
virtual ~Stream() = default#
Virtual destructor.
-
template<typename T>
inline void Write(const T &data)# Write a typed value using Serializer<T>.
- Template Parameters:
T – The data type (must have a Serializer<T> specialization).
- Parameters:
data – The value to write.
-
template<typename T>
inline bool Read(T *out_data)# Read a typed value using Serializer<T>.
- Template Parameters:
T – The data type (must have a Serializer<T> specialization).
- Parameters:
out_data – Pointer to receive the value.
- Returns:
true on success.
-
virtual size_t Read(void *ptr, size_t size) = 0#