From fa4b4097d3283e1d6e6376c70910e245f0b1f6ec Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Wed, 18 Sep 2024 21:59:54 -0500 Subject: Save progress of qt6 implementation. --- src/archive.hpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/archive.hpp (limited to 'src/archive.hpp') diff --git a/src/archive.hpp b/src/archive.hpp new file mode 100644 index 0000000..d8464e5 --- /dev/null +++ b/src/archive.hpp @@ -0,0 +1,52 @@ +#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 -- cgit v1.2.3