#ifndef ARCHIVE_HPP #define ARCHIVE_HPP #include "result.hpp" #include #include #include #include #include #include namespace bookmouse { 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 std::string& filename); virtual ~ZipArchive() override; ZipArchive(const ZipArchive& rhs) = delete; ZipArchive(ZipArchive&& rhs); ZipArchive& operator=(const ZipArchive& rhs) = delete; ZipArchive& operator=(ZipArchive&& rhs); 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 bookmouse #endif