/ lib / PageCache / EpubChapterParser.h
EpubChapterParser.h
 1  #pragma once
 2  
 3  #include <Epub.h>
 4  #include <Epub/RenderConfig.h>
 5  
 6  #include <memory>
 7  #include <string>
 8  
 9  #include "ContentParser.h"
10  
11  class GfxRenderer;
12  
13  /**
14   * Content parser for EPUB chapters.
15   * Wraps ChapterHtmlSlimParser to implement ContentParser interface.
16   */
17  class EpubChapterParser : public ContentParser {
18    std::shared_ptr<Epub> epub_;
19    int spineIndex_;
20    GfxRenderer& renderer_;
21    RenderConfig config_;
22    std::string imageCachePath_;
23    bool hasMore_ = true;
24  
25   public:
26    EpubChapterParser(std::shared_ptr<Epub> epub, int spineIndex, GfxRenderer& renderer, const RenderConfig& config,
27                      const std::string& imageCachePath = "");
28    ~EpubChapterParser() override = default;
29  
30    bool parsePages(const std::function<void(std::unique_ptr<Page>)>& onPageComplete, uint16_t maxPages = 0,
31                    const AbortCallback& shouldAbort = nullptr) override;
32    bool hasMoreContent() const override { return hasMore_; }
33    void reset() override;
34  };