mirror of https://github.com/kiwix/libkiwix.git
Library::BookIdCollection typedef
This commit is contained in:
parent
a20f9e2ce1
commit
db06b2c7ca
|
@ -122,6 +122,9 @@ class Library
|
||||||
std::map<std::string, std::shared_ptr<Reader>> m_readers;
|
std::map<std::string, std::shared_ptr<Reader>> m_readers;
|
||||||
std::vector<kiwix::Bookmark> m_bookmarks;
|
std::vector<kiwix::Bookmark> m_bookmarks;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef std::vector<std::string> BookIdCollection;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Library();
|
Library();
|
||||||
~Library();
|
~Library();
|
||||||
|
@ -224,7 +227,7 @@ class Library
|
||||||
*
|
*
|
||||||
* @return A list of book ids.
|
* @return A list of book ids.
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> getBooksIds();
|
BookIdCollection getBooksIds();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the library and generate a new one with the keep elements.
|
* Filter the library and generate a new one with the keep elements.
|
||||||
|
@ -234,7 +237,7 @@ class Library
|
||||||
* @param search List only books with search in the title or description.
|
* @param search List only books with search in the title or description.
|
||||||
* @return The list of bookIds corresponding to the query.
|
* @return The list of bookIds corresponding to the query.
|
||||||
*/
|
*/
|
||||||
DEPRECATED std::vector<std::string> filter(const std::string& search);
|
DEPRECATED BookIdCollection filter(const std::string& search);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,7 +246,7 @@ class Library
|
||||||
* @param filter The filter to use.
|
* @param filter The filter to use.
|
||||||
* @return The list of bookIds corresponding to the filter.
|
* @return The list of bookIds corresponding to the filter.
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> filter(const Filter& filter);
|
BookIdCollection filter(const Filter& filter);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -253,7 +256,7 @@ class Library
|
||||||
* @param comparator how to sort the books
|
* @param comparator how to sort the books
|
||||||
* @return The sorted list of books
|
* @return The sorted list of books
|
||||||
*/
|
*/
|
||||||
void sort(std::vector<std::string>& bookIds, supportedListSortBy sortBy, bool ascending);
|
void sort(BookIdCollection& bookIds, supportedListSortBy sortBy, bool ascending);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List books in the library.
|
* List books in the library.
|
||||||
|
@ -277,7 +280,7 @@ class Library
|
||||||
* Set to 0 to cancel this filter.
|
* Set to 0 to cancel this filter.
|
||||||
* @return The list of bookIds corresponding to the query.
|
* @return The list of bookIds corresponding to the query.
|
||||||
*/
|
*/
|
||||||
DEPRECATED std::vector<std::string> listBooksIds(
|
DEPRECATED BookIdCollection listBooksIds(
|
||||||
int supportedListMode = ALL,
|
int supportedListMode = ALL,
|
||||||
supportedListSortBy sortBy = UNSORTED,
|
supportedListSortBy sortBy = UNSORTED,
|
||||||
const std::string& search = "",
|
const std::string& search = "",
|
||||||
|
|
|
@ -211,9 +211,9 @@ const std::vector<kiwix::Bookmark> Library::getBookmarks(bool onlyValidBookmarks
|
||||||
return validBookmarks;
|
return validBookmarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> Library::getBooksIds()
|
Library::BookIdCollection Library::getBooksIds()
|
||||||
{
|
{
|
||||||
std::vector<std::string> bookIds;
|
BookIdCollection bookIds;
|
||||||
|
|
||||||
for (auto& pair: m_books) {
|
for (auto& pair: m_books) {
|
||||||
bookIds.push_back(pair.first);
|
bookIds.push_back(pair.first);
|
||||||
|
@ -222,7 +222,7 @@ std::vector<std::string> Library::getBooksIds()
|
||||||
return bookIds;
|
return bookIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> Library::filter(const std::string& search)
|
Library::BookIdCollection Library::filter(const std::string& search)
|
||||||
{
|
{
|
||||||
if (search.empty()) {
|
if (search.empty()) {
|
||||||
return getBooksIds();
|
return getBooksIds();
|
||||||
|
@ -232,16 +232,16 @@ std::vector<std::string> Library::filter(const std::string& search)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> Library::filter(const Filter& filter)
|
Library::BookIdCollection Library::filter(const Filter& filter)
|
||||||
{
|
{
|
||||||
std::vector<std::string> bookIds;
|
BookIdCollection bookIds;
|
||||||
for(auto& pair:m_books) {
|
for(auto& pair:m_books) {
|
||||||
if(filter.acceptByQueryOnly(pair.second)) {
|
if(filter.acceptByQueryOnly(pair.second)) {
|
||||||
bookIds.push_back(pair.first);
|
bookIds.push_back(pair.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> result;
|
BookIdCollection result;
|
||||||
for(auto id : bookIds) {
|
for(auto id : bookIds) {
|
||||||
if(filter.acceptByNonQueryCriteria(m_books[id])) {
|
if(filter.acceptByNonQueryCriteria(m_books[id])) {
|
||||||
result.push_back(id);
|
result.push_back(id);
|
||||||
|
@ -309,7 +309,7 @@ std::string Comparator<PUBLISHER>::get_key(const std::string& id)
|
||||||
return lib->getBookById(id).getPublisher();
|
return lib->getBookById(id).getPublisher();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Library::sort(std::vector<std::string>& bookIds, supportedListSortBy sort, bool ascending)
|
void Library::sort(BookIdCollection& bookIds, supportedListSortBy sort, bool ascending)
|
||||||
{
|
{
|
||||||
switch(sort) {
|
switch(sort) {
|
||||||
case TITLE:
|
case TITLE:
|
||||||
|
@ -333,7 +333,7 @@ void Library::sort(std::vector<std::string>& bookIds, supportedListSortBy sort,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> Library::listBooksIds(
|
Library::BookIdCollection Library::listBooksIds(
|
||||||
int mode,
|
int mode,
|
||||||
supportedListSortBy sortBy,
|
supportedListSortBy sortBy,
|
||||||
const std::string& search,
|
const std::string& search,
|
||||||
|
|
Loading…
Reference in New Issue