#ifndef ARCHIVE_HPP #define ARCHIVE_HPP #include "result.hpp" #include #include #include #include #include namespace getsuyomi { enum class ArchiveError { BadIndex, ZipError, BadData, Unimplemented }; using ArchiveResult = Result, ArchiveError>; class Archive { public: virtual ~Archive() = default; virtual ArchiveResult getPage(size_t page) = 0; virtual size_t numPages() const = 0; }; class ZipArchive : public Archive { public: explicit ZipArchive(const QString& filename); virtual ~ZipArchive() override; virtual ArchiveResult getPage(size_t page) override; virtual size_t numPages() const override; private: void populate(); zip_t* m_archive{nullptr}; std::vector m_sortedIndices{}; std::vector m_filenames{}; std::vector m_fileSizes{}; std::vector> m_pages{}; }; } // namespace getsuyomi #endif