#pragma once #include #include class Library { public: bool loadLastOrFirst(String& path, String& contents) const; bool load(const String& path, String& contents) const; bool loadSidecar(const String& chapterPath, std::vector& bytes) const; bool selectBook(const String& currentPath, int direction, String& chapterPath) const; bool selectChapter(const String& currentPath, int direction, String& chapterPath) const; bool previousChapter(const String& currentPath, String& chapterPath) const; bool nextChapter(const String& currentPath, String& chapterPath) const; String bookName(const String& chapterPath) const; String chapterName(const String& chapterPath) const; private: bool ensureBooks() const; bool ensureChapters(const String& directoryPath) const; bool isListedChapter(const String& chapterPath) const; bool firstChapter(const String& directoryPath, String& chapterPath) const; bool loadFile(const String& path, String& contents) const; bool firstBook(String& path) const; mutable bool booksCached_ = false; mutable std::vector books_; mutable std::vector firstChapters_; mutable String chapterDirectory_; mutable std::vector chapters_; mutable std::vector chapterTitles_; };