mrpt.io
mrpt.io — File and memory stream bindings for MRPT.
- Provides:
CStream : Abstract base class for all streams
CFileInputStream : Read-only binary file stream
CFileOutputStream : Write-only binary file stream
CFileGZInputStream : Transparent gz-compressed input stream
CFileGZOutputStream : Transparent gz-compressed output stream
CCompressedInputStream : Reads plain, gzip or zstd files (auto-detected)
CCompressedOutputStream : Writes plain, gzip or zstd files
CMemoryStream : In-memory stream buffer
OpenMode : TRUNCATE / APPEND enum
SeekOrigin : sFromBeginning / sFromCurrent / sFromEnd enum
CompressionType, CompressionOptions, detect_compression()
archiveFrom() : CArchive over a stream, to read/write MRPT objects
zip : gzip compression of memory blocks and files
loadBinaryFile(), vectorToBinaryFile(), loadTextFile(), file_get_contents()
Package Contents
- class mrpt.io.CCompressedInputStream
C++ API: class mrpt::io::CCompressedInputStream
CCompressedInputStream(fileName: str)
Bases:
CStream- checkEOF() bool
- close() None
- fileOpenCorrectly() bool
- filePathAtUse() str
- getCompressionType() CompressionType
- getPosition() int
- getStreamDescription() str
- getTotalBytesCount() int
- is_open() bool
- open(fileName: str) bool
Open a plain, gzip or zstd file for reading. Returns true on success.
- class mrpt.io.CCompressedOutputStream
C++ API: class mrpt::io::CCompressedOutputStream
CCompressedOutputStream(fileName: str, mode: OpenMode = …, options: CompressionOptions = …)
Bases:
CStream- close() None
- fileOpenCorrectly() bool
- filePathAtUse() str
- getCompressionType() CompressionType
- getPosition() int
- getStreamDescription() str
- is_open() bool
- open(fileName: str, options: CompressionOptions = ..., mode: OpenMode = ...) bool
Open a file for writing (default: zstd). Returns true on success.
- class mrpt.io.CFileGZInputStream
C++ API: class mrpt::io::CFileGZInputStream
CFileGZInputStream(fileName: str)
Bases:
CStream- checkEOF() bool
- close() None
- fileOpenCorrectly() bool
- filePathAtUse() str
- getPosition() int
- getStreamDescription() str
- getTotalBytesCount() int
- is_open() bool
- open(fileName: str) bool
Open a .gz file for reading. Returns true on success.
- class mrpt.io.CFileGZOutputStream
C++ API: class mrpt::io::CFileGZOutputStream
CFileGZOutputStream(fileName: str, mode: OpenMode = …, compressionLevel: int = 1)
Bases:
CStream- close() None
- fileOpenCorrectly() bool
- filePathAtUse() str
- getPosition() int
- getStreamDescription() str
- is_open() bool
- class mrpt.io.CFileInputStream
C++ API: class mrpt::io::CFileInputStream
CFileInputStream(fileName: str)
Bases:
CStream- checkEOF() bool
- clearError() None
- close() None
- fileOpenCorrectly() bool
- getPosition() int
- getStreamDescription() str
- getTotalBytesCount() int
- is_open() bool
- open(fileName: str) bool
Open a file for reading. Returns true on success.
- readLine(arg0: str) bool
- class mrpt.io.CFileOutputStream
C++ API: class mrpt::io::CFileOutputStream
CFileOutputStream(fileName: str, mode: OpenMode = …)
Bases:
CStream- close() None
- fileOpenCorrectly() bool
- getPosition() int
- getStreamDescription() str
- getTotalBytesCount() int
- is_open() bool
- class mrpt.io.CMemoryStream
C++ API: class mrpt::io::CMemoryStream
Bases:
CStream- Seek(offset: int, origin: SeekOrigin = ...) int
- clear() None
- getContents() bytes
Return a copy of the stream buffer as a Python bytes object
- getPosition() int
- getTotalBytesCount() int
- loadBufferFromFile(arg0: str) bool
- saveBufferToFile(arg0: str) bool
- class mrpt.io.CStream
C++ API: class mrpt::io::CStream
- Seek(offset: int, origin: SeekOrigin = ...) int
- getPosition() int
- getStreamDescription() str
- getTotalBytesCount() int
- getline(arg0: str) bool
- read(count: int) bytes
Read up to count bytes from the stream, returns bytes object
- write(data: bytes) int
Write bytes to the stream, returns number of bytes written
- class mrpt.io.CompressionOptions
C++ API: struct mrpt::io::CompressionOptions
CompressionOptions(type: CompressionType, level: int = 1)
- level: int
- type: CompressionType
- class mrpt.io.CompressionType(value: int)
Members:
None_
Gzip
Zstd
- property name: str
- property value: int
- Gzip: ClassVar[CompressionType]
- None_: ClassVar[CompressionType]
- Zstd: ClassVar[CompressionType]
- class mrpt.io.OpenMode(value: int)
Members:
TRUNCATE
APPEND
- property name: str
- property value: int
- class mrpt.io.SeekOrigin(value: int)
Members:
sFromBeginning
sFromCurrent
sFromEnd
- property name: str
- property value: int
- sFromBeginning: ClassVar[SeekOrigin]
- sFromCurrent: ClassVar[SeekOrigin]
- sFromEnd: ClassVar[SeekOrigin]
- mrpt.io.archiveFrom(stream: CStream) mrpt.serialization.CArchive
Returns a CArchive to read/write MRPT objects from/to the given stream. The stream is kept alive while the archive exists.
- mrpt.io.detect_compression(filePath: str) CompressionType
Detects the compression of a file from its magic bytes (not its extension).
- mrpt.io.file_get_contents(fileName: str) str
Load an entire text file as a single string. Raises on error.
- mrpt.io.loadBinaryFile(fileName: str) list[int] | None
Load an entire binary file. Returns None (nullopt) on error, or a bytes-like list of uint8.
- mrpt.io.loadTextFile(fileName: str) list[str] | None
Load a text file as a list of string lines. Returns None (nullopt) on error.
- mrpt.io.vectorToBinaryFile(data: bytes, fileName: str) bool
Save a bytes object to a binary file. Returns False on error.