diff --git a/include/manager.h b/include/manager.h index 19f26d3bb..383d33a92 100644 --- a/include/manager.h +++ b/include/manager.h @@ -48,7 +48,7 @@ enum supportedListSortBy { TITLE, SIZE, DATE, CREATOR, PUBLISHER }; class Manager { public: - Manager(); + Manager(Library* library); ~Manager(); /** @@ -214,7 +214,7 @@ class Manager vector bookIdList; protected: - kiwix::Library library; + kiwix::Library* library; bool readBookFromPath(const string path, Book* book = NULL); bool parseXmlDom(const pugi::xml_document& doc, diff --git a/include/opds_dumper.h b/include/opds_dumper.h index 5c60b8c6a..7d3ae9b6a 100644 --- a/include/opds_dumper.h +++ b/include/opds_dumper.h @@ -45,7 +45,7 @@ class OPDSDumper { public: OPDSDumper() = default; - OPDSDumper(Library library); + OPDSDumper(Library* library); ~OPDSDumper(); /** @@ -89,10 +89,10 @@ class OPDSDumper * * @param library The library to dump. */ - void setLibrary(Library library) { this->library = library; } + void setLibrary(Library* library) { this->library = library; } protected: - kiwix::Library library; + kiwix::Library* library; std::string id; std::string title; std::string date; diff --git a/src/manager.cpp b/src/manager.cpp index 36bc56553..bd78edf16 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -23,7 +23,9 @@ namespace kiwix { /* Constructor */ -Manager::Manager() : writableLibraryPath("") +Manager::Manager(Library* library): + writableLibraryPath(""), + library(library) { } /* Destructor */ @@ -87,7 +89,7 @@ bool Manager::parseXmlDom(const pugi::xml_document& doc, } if (ok) { - library.addBook(book); + library->addBook(book); } } @@ -148,7 +150,7 @@ bool Manager::parseOpdsDom(const pugi::xml_document& doc, const std::string& url } /* Update the book properties with the new importer */ - library.addBook(book); + library->addBook(book); } return true; @@ -302,7 +304,7 @@ bool Manager::setBookIndex(const string id, const string path, const supportedIndexType type) try { - auto book = library.getBookById(id); + auto book = library->getBookById(id); book.setIndexPath(isRelativePath(path) ? computeAbsolutePath( removeLastPathElement(writableLibraryPath, true, false), @@ -316,7 +318,7 @@ try { bool Manager::setBookPath(const string id, const string path) try { - auto book = library.getBookById(id); + auto book = library->getBookById(id); book.setPath(isRelativePath(path) ? computeAbsolutePath( removeLastPathElement(writableLibraryPath, true, false), diff --git a/src/opds_dumper.cpp b/src/opds_dumper.cpp index a0f54cd29..d8a55069f 100644 --- a/src/opds_dumper.cpp +++ b/src/opds_dumper.cpp @@ -25,7 +25,7 @@ namespace kiwix { /* Constructor */ -OPDSDumper::OPDSDumper(Library library) +OPDSDumper::OPDSDumper(Library* library) : library(library) { } @@ -110,8 +110,10 @@ string OPDSDumper::dumpOPDSFeed() search_link.append_attribute("href") = searchDescriptionUrl.c_str(); } - for (auto& pair: library.books) { - handleBook(pair.second, root_node); + if (library) { + for (auto& pair: library->books) { + handleBook(pair.second, root_node); + } } return nodeToString(root_node);