Class Manager
Defined in File manager.h
Class Documentation
-
class Manager
A tool to manage a
Library.Public Types
-
typedef std::vector<std::string> Paths
Public Functions
-
explicit Manager(LibraryManipulator manipulator)
-
explicit Manager(LibraryPtr library)
-
bool readFile(const std::string &path, bool readOnly = true, bool trustLibrary = true)
Read a
library.xmland add book in the file to the library.- Parameters:
path – The (utf8) path to the
library.xml.readOnly – Set if the libray path could be overwritten latter with updated content.
trustLibrary – use book metadata coming from XML.
- Returns:
True if file has been properly parsed.
-
void reload(const Paths &paths)
Sync the contents of the library with one or more
library.xmlfiles.The metadata of the library files is trusted unconditionally. Any books not present in the input library.xml files are removed from the library.
- Parameters:
paths – The (utf8) paths to the
library.xmlfiles.
-
bool readXml(const std::string &xml, const bool readOnly = true, const std::string &libraryPath = "", bool trustLibrary = true)
Load a library content store in the string.
- Parameters:
xml – The content corresponding of the library xml
readOnly – Set if the libray path could be overwritten latter with updated content.
libraryPath – The library path (used to resolve relative path)
- Returns:
True if the content has been properly parsed.
-
bool readOpds(const std::string &content, const std::string &urlHost)
Load a library content stored in a OPDSstream.
- Parameters:
content – The content of the OPDS stream.
readOnly – Set if the library path could be overwritten later with updated content.
libraryPath – The library path (used to resolve relative path)
- Returns:
True if the content has been properly parsed.
-
bool readBookmarkFile(const std::string &path)
Load a bookmark file.
- Parameters:
path – The path of the file to read.
- Returns:
True if the content has been properly parsed.
-
std::string addBookFromPathAndGetId(const std::string &pathToOpen, const std::string &pathToSave = "", const std::string &url = "", const bool checkMetaData = false)
Add a book to the library.
- Parameters:
pathToOpen – The path to the zim file to add.
pathToSave – The path to store in the library in place of pathToOpen.
url – The url of the book to store in the library.
checMetaData – Tell if we check metadata before adding book to the library.
- Returns:
The id of the book if the book has been added to the library. Else, an empty string.
-
bool addBookFromPath(const std::string &pathToOpen, const std::string &pathToSave = "", const std::string &url = "", const bool checkMetaData = false)
Add a book to the library.
- Parameters:
pathToOpen – The path to the zim file to add.
pathToSave – The path to store in the library in place of pathToOpen.
url – The url of the book to store in the library.
checMetaData – Tell if we check metadata before adding book to the library.
- Returns:
True if the book has been added to the library.
-
void addBooksFromDirectory(const std::string &path, const bool verboseFlag = false)
Add all books from the directory tree into the library.
- Parameters:
path – The path of the directory to scan.
verboseFlag – Verbose logs flag.
Public Members
-
std::string writableLibraryPath
-
bool m_hasSearchResult = false
-
uint64_t m_totalBooks = 0
-
uint64_t m_startIndex = 0
-
uint64_t m_itemsPerPage = 0
Protected Functions
-
bool parseXmlDom(const pugi::xml_document &doc, bool readOnly, const std::string &libraryPath, bool trustLibrary)
-
bool parseOpdsDom(const pugi::xml_document &doc, const std::string &urlHost)
Protected Attributes
-
kiwix::LibraryManipulator manipulator
-
typedef std::vector<std::string> Paths