PlainTextParser.h
1 #pragma once 2 3 #include <Epub/RenderConfig.h> 4 #include <SdFat.h> 5 6 #include <string> 7 8 #include "ContentParser.h" 9 10 class GfxRenderer; 11 12 /** 13 * Content parser for plain text files (TXT, Markdown). 14 * Reads text, wraps into lines, and creates Page objects. 15 */ 16 class PlainTextParser : public ContentParser { 17 std::string filepath_; 18 GfxRenderer& renderer_; 19 RenderConfig config_; 20 size_t fileSize_ = 0; 21 size_t currentOffset_ = 0; 22 bool hasMore_ = true; 23 24 public: 25 PlainTextParser(std::string filepath, GfxRenderer& renderer, const RenderConfig& config); 26 ~PlainTextParser() override = default; 27 28 bool parsePages(const std::function<void(std::unique_ptr<Page>)>& onPageComplete, uint16_t maxPages = 0, 29 const AbortCallback& shouldAbort = nullptr) override; 30 bool hasMoreContent() const override { return hasMore_; } 31 void reset() override; 32 };