Class Library¶
Defined in File library.h
Class Documentation¶
-
class Library¶
A Library store several books.
Public Types
-
typedef uint64_t Revision¶
-
typedef std::vector<std::string> BookIdCollection¶
-
typedef std::map<std::string, int> AttributeCounts¶
-
typedef std::set<std::string> BookIdSet¶
Public Functions
-
Library()¶
-
~Library()¶
-
bool addBook(const Book &book)¶
Add a book to the library.
If a book already exist in the library with the same id, update the existing book instead of adding a new one.
- Parameters
book – The book to add.
- Returns
True if the book has been added. False if a book has been updated.
-
void addBookmark(const Bookmark &bookmark)¶
Add a bookmark to the library.
- Parameters
bookmark – the book to add.
-
bool removeBookmark(const std::string &zimId, const std::string &url)¶
Remove a bookmarkk
- Parameters
zimId – The zimId of the bookmark.
url – The url of the bookmark.
- Returns
True if the bookmark has been removed.
-
std::shared_ptr<zim::Archive> getArchiveById(const std::string &id)¶
-
inline std::shared_ptr<ZimSearcher> getSearcherById(const std::string &id)¶
-
std::shared_ptr<ZimSearcher> getSearcherByIds(const BookIdSet &ids)¶
-
bool removeBookById(const std::string &id)¶
Remove a book from the library.
- Parameters
id – the id of the book to remove.
- Returns
True if the book were in the lirbrary and has been removed.
-
bool writeToFile(const std::string &path) const¶
Write the library to a file.
- Parameters
path – the path of the file to write to.
- Returns
True if the library has been correctly saved.
-
bool writeBookmarksToFile(const std::string &path) const¶
Write the library bookmarks to a file.
- Parameters
path – the path of the file to write to.
- Returns
True if the library has been correctly saved.
-
unsigned int getBookCount(const bool localBooks, const bool remoteBooks) const¶
Get the number of book in the library.
- Parameters
localBooks – If we must count local books (books with a path).
remoteBooks – If we must count remote books (books with an url)
- Returns
The number of books.
-
std::vector<std::string> getBooksLanguages() const¶
Get all languagues of the books in the library.
- Returns
A list of languages.
-
AttributeCounts getBooksLanguagesWithCounts() const¶
Get all languagues of the books in the library with counts.
- Returns
A list of languages with the count of books in each language.
-
std::vector<std::string> getBooksCategories() const¶
Get all categories of the books in the library.
- Returns
A list of categories.
-
std::vector<std::string> getBooksCreators() const¶
Get all book creators of the books in the library.
- Returns
A list of book creators.
-
std::vector<std::string> getBooksPublishers() const¶
Get all book publishers of the books in the library.
- Returns
A list of book publishers.
-
const std::vector<kiwix::Bookmark> getBookmarks(bool onlyValidBookmarks = true) const¶
Get all bookmarks.
- Returns
A list of bookmarks
-
BookIdCollection getBooksIds() const¶
Get all book ids of the books in the library.
- Returns
A list of book ids.
-
BookIdCollection filter(const Filter &filter) const¶
Filter the library and return the id of the keep elements.
- Parameters
filter – The filter to use.
- Returns
The list of bookIds corresponding to the filter.
-
void sort(BookIdCollection &bookIds, supportedListSortBy sortBy, bool ascending) const¶
Sort (in place) bookIds using the given comparator.
- Parameters
bookIds – the list of book Ids to sort
comparator – how to sort the books
- Returns
The sorted list of books
Friends
- friend class OPDSDumper
- friend class libXMLDumper
-
typedef uint64_t Revision¶