|
Mila
Deep Neural Network Library
|
ZIP archive serializer built on miniz. More...
Public Member Functions | |
| ZipSerializer () noexcept | |
| Construct an empty, closed ZipSerializer. | |
| ZipSerializer (const ZipSerializer &)=delete | |
| ZipSerializer (ZipSerializer &&other) noexcept | |
| ~ZipSerializer () | |
| Destructor ensures underlying archive is closed. | |
| bool | addData (const std::string &path, const void *data, size_t size) override |
| Add a binary blob to the archive at the given internal path. | |
| bool | addData (const std::string &path, std::span< const std::byte > data) |
| Add a binary blob using std::span (C++23 style). | |
| bool | addMetadata (const std::string &key, const std::string &value) override |
| Store small textual metadata under the "metadata/" prefix. | |
| bool | close () override |
| Finalize and close the archive. | |
| size_t | extractData (const std::string &path, std::span< std::byte > buffer) |
| Extract a file using std::span (C++23 style). | |
| size_t | extractData (const std::string &path, void *data, size_t size) override |
| Extract a file from the archive into a caller-provided buffer. | |
| const std::string & | getFilename () const noexcept override |
| Get the filename of the currently open archive. | |
| size_t | getFileSize (const std::string &path) const override |
| Get the uncompressed size of the file stored at path. | |
| std::string | getMetadata (const std::string &key) const override |
| Retrieve textual metadata previously stored with addMetadata(). | |
| bool | hasFile (const std::string &path) const override |
| Check whether the archive contains the given path. | |
| bool | isOpen () const noexcept override |
| Check if the serializer is currently open. | |
| bool | isOpenForRead () const noexcept override |
| Check if the serializer is open for reading. | |
| bool | isOpenForWrite () const noexcept override |
| Check if the serializer is open for writing. | |
| std::vector< std::string > | listFiles () const override |
| List all files contained in the open archive. | |
| bool | open (const std::string &filename, OpenMode mode) override |
| Open an archive for read or write (create/overwrite). | |
| ZipSerializer & | operator= (const ZipSerializer &)=delete |
| ZipSerializer & | operator= (ZipSerializer &&other) noexcept |
ZIP archive serializer built on miniz.
Responsibilities:
Notes:
|
inlinenoexcept |
Construct an empty, closed ZipSerializer.
The underlying miniz archive structure is zero-initialized.
|
inline |
Destructor ensures underlying archive is closed.
Best-effort cleanup is performed and exceptions are suppressed.
|
inlinenodiscardoverridevirtual |
Add a binary blob to the archive at the given internal path.
Paths are normalized to use forward slashes and stripped of leading './' or '/'.
| path | Archive-internal path (e.g., "network/weights.bin"). |
| data | Pointer to source bytes (may be null if size == 0). |
| size | Number of bytes to write. |
Implements Mila::Dnn::Serialization::ArchiveSerializer.
|
inlinenodiscard |
Add a binary blob using std::span (C++23 style).
| path | Archive-internal path. |
| data | Span of bytes to write. |
|
inlinenodiscardoverridevirtual |
Store small textual metadata under the "metadata/" prefix.
| key | Metadata key (will be stored as "metadata/<key>"). |
| value | Metadata value bytes. |
Implements Mila::Dnn::Serialization::ArchiveSerializer.
|
inlinenodiscardoverridevirtual |
Finalize and close the archive.
For write mode this ensures the archive is finalized and internal miniz state is released. For read mode releases reader resources.
Implements Mila::Dnn::Serialization::Serializer.
|
inlinenodiscard |
Extract a file using std::span (C++23 style).
| path | Archive-internal path to extract. |
| buffer | Span to receive file contents. |
|
inlinenodiscardoverridevirtual |
Extract a file from the archive into a caller-provided buffer.
| path | Archive-internal path to extract. |
| data | Pre-allocated buffer to receive file contents. |
| size | Size of the provided buffer in bytes. |
Implements Mila::Dnn::Serialization::ArchiveSerializer.
|
inlinenodiscardoverridevirtualnoexcept |
Get the filename of the currently open archive.
Implements Mila::Dnn::Serialization::Serializer.
|
inlinenodiscardoverridevirtual |
Get the uncompressed size of the file stored at path.
| path | Archive-internal path. |
Implements Mila::Dnn::Serialization::ArchiveSerializer.
|
inlinenodiscardoverridevirtual |
Retrieve textual metadata previously stored with addMetadata().
| key | Metadata key. |
Implements Mila::Dnn::Serialization::ArchiveSerializer.
|
inlinenodiscardoverridevirtual |
Check whether the archive contains the given path.
| path | Archive-internal path to query. |
Implements Mila::Dnn::Serialization::ArchiveSerializer.
|
inlinenodiscardoverridevirtualnoexcept |
Check if the serializer is currently open.
Implements Mila::Dnn::Serialization::Serializer.
|
inlinenodiscardoverridevirtualnoexcept |
Check if the serializer is open for reading.
Implements Mila::Dnn::Serialization::Serializer.
|
inlinenodiscardoverridevirtualnoexcept |
Check if the serializer is open for writing.
Implements Mila::Dnn::Serialization::Serializer.
|
inlinenodiscardoverridevirtual |
List all files contained in the open archive.
Implements Mila::Dnn::Serialization::ArchiveSerializer.
|
inlinenodiscardoverridevirtual |
Open an archive for read or write (create/overwrite).
Combines previous openForRead/openForWrite into one API using ModelSerializer::OpenMode to select the behavior.
| filename | Filesystem path to open. |
| mode | OpenMode::Read or OpenMode::Write. |
Implements Mila::Dnn::Serialization::Serializer.