mirror of https://github.com/kiwix/libkiwix.git
Remove old deprecated methods.
This commit is contained in:
parent
ac6f91798f
commit
e5eeb08206
|
@ -325,17 +325,6 @@ class Library : private LibraryBase
|
||||||
*/
|
*/
|
||||||
BookIdCollection getBooksIds() const;
|
BookIdCollection getBooksIds() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter the library and generate a new one with the keep elements.
|
|
||||||
*
|
|
||||||
* This is equivalent to `listBookIds(ALL, UNSORTED, search)`.
|
|
||||||
*
|
|
||||||
* @param search List only books with search in the title or description.
|
|
||||||
* @return The list of bookIds corresponding to the query.
|
|
||||||
*/
|
|
||||||
DEPRECATED BookIdCollection filter(const std::string& search) const;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the library and return the id of the keep elements.
|
* Filter the library and return the id of the keep elements.
|
||||||
*
|
*
|
||||||
|
@ -354,38 +343,6 @@ class Library : private LibraryBase
|
||||||
*/
|
*/
|
||||||
void sort(BookIdCollection& bookIds, supportedListSortBy sortBy, bool ascending) const;
|
void sort(BookIdCollection& bookIds, supportedListSortBy sortBy, bool ascending) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* List books in the library.
|
|
||||||
*
|
|
||||||
* @param mode The mode of listing :
|
|
||||||
* - LOCAL : list only local books (with a path).
|
|
||||||
* - REMOTE : list only remote books (with an url).
|
|
||||||
* - VALID : list only valid books (without a path or with a
|
|
||||||
* path pointing to a valid zim file).
|
|
||||||
* - NOLOCAL : list only books without valid path.
|
|
||||||
* - NOREMOTE : list only books without url.
|
|
||||||
* - NOVALID : list only books not valid.
|
|
||||||
* - ALL : Do not do any filter (LOCAL or REMOTE)
|
|
||||||
* - Flags can be combined.
|
|
||||||
* @param sortBy Attribute to sort by the book list.
|
|
||||||
* @param search List only books with search in the title, description.
|
|
||||||
* @param language List only books in this language.
|
|
||||||
* @param creator List only books of this creator.
|
|
||||||
* @param publisher List only books of this publisher.
|
|
||||||
* @param maxSize Do not list book bigger than maxSize.
|
|
||||||
* Set to 0 to cancel this filter.
|
|
||||||
* @return The list of bookIds corresponding to the query.
|
|
||||||
*/
|
|
||||||
DEPRECATED BookIdCollection listBooksIds(
|
|
||||||
int supportedListMode = ALL,
|
|
||||||
supportedListSortBy sortBy = UNSORTED,
|
|
||||||
const std::string& search = "",
|
|
||||||
const std::string& language = "",
|
|
||||||
const std::string& creator = "",
|
|
||||||
const std::string& publisher = "",
|
|
||||||
const std::vector<std::string>& tags = {},
|
|
||||||
size_t maxSize = 0) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current revision of the library.
|
* Return the current revision of the library.
|
||||||
*
|
*
|
||||||
|
|
|
@ -329,28 +329,6 @@ class Reader
|
||||||
*/
|
*/
|
||||||
Entry getEntryFromTitle(const std::string& title) const;
|
Entry getEntryFromTitle(const std::string& title) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Search for entries with title starting with prefix (case sensitive).
|
|
||||||
*
|
|
||||||
* Suggestions are stored in an internal vector and can be retrieved using
|
|
||||||
* `getNextSuggestion` method.
|
|
||||||
* This method is not thread safe and is deprecated. Use :
|
|
||||||
* bool searchSuggestions(const string& prefix,
|
|
||||||
* unsigned int suggestionsCount,
|
|
||||||
* SuggestionsList_t& results);
|
|
||||||
*
|
|
||||||
* @param prefix The prefix to search.
|
|
||||||
* @param suggestionsCount How many suggestions to search for.
|
|
||||||
* @param reset If true, remove previous suggestions in the internal vector.
|
|
||||||
* If false, add suggestions to the internal vector
|
|
||||||
* (until internal vector size is suggestionCount (or no more
|
|
||||||
* suggestion))
|
|
||||||
* @return True if some suggestions have been added to the internal vector.
|
|
||||||
*/
|
|
||||||
DEPRECATED bool searchSuggestions(const string& prefix,
|
|
||||||
unsigned int suggestionsCount,
|
|
||||||
const bool reset = true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for entries with title starting with prefix (case sensitive).
|
* Search for entries with title starting with prefix (case sensitive).
|
||||||
*
|
*
|
||||||
|
@ -366,28 +344,6 @@ class Reader
|
||||||
unsigned int suggestionsCount,
|
unsigned int suggestionsCount,
|
||||||
SuggestionsList_t& resuls);
|
SuggestionsList_t& resuls);
|
||||||
|
|
||||||
/**
|
|
||||||
* Search for entries for the given prefix.
|
|
||||||
*
|
|
||||||
* If the zim file has a internal fulltext index, the suggestions will be
|
|
||||||
* searched using it.
|
|
||||||
* Else the suggestions will be search using `searchSuggestions` while trying
|
|
||||||
* to be smart about case sensitivity (using `getTitleVariants`).
|
|
||||||
*
|
|
||||||
* In any case, suggestions are stored in an internal vector and can be
|
|
||||||
* retrieved using `getNextSuggestion` method.
|
|
||||||
* The internal vector will be reset.
|
|
||||||
* This method is not thread safe and is deprecated. Use :
|
|
||||||
* bool searchSuggestionsSmart(const string& prefix,
|
|
||||||
* unsigned int suggestionsCount,
|
|
||||||
* SuggestionsList_t& results);
|
|
||||||
*
|
|
||||||
* @param prefix The prefix to search for.
|
|
||||||
* @param suggestionsCount How many suggestions to search for.
|
|
||||||
*/
|
|
||||||
DEPRECATED bool searchSuggestionsSmart(const string& prefix,
|
|
||||||
unsigned int suggestionsCount);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for entries for the given prefix.
|
* Search for entries for the given prefix.
|
||||||
*
|
*
|
||||||
|
@ -434,22 +390,6 @@ class Reader
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> getTitleVariants(const std::string& title) const;
|
std::vector<std::string> getTitleVariants(const std::string& title) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the next suggestion title.
|
|
||||||
*
|
|
||||||
* @param[out] title the title of the suggestion.
|
|
||||||
* @return True if title has been set.
|
|
||||||
*/
|
|
||||||
DEPRECATED bool getNextSuggestion(string& title);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the next suggestion title and url.
|
|
||||||
*
|
|
||||||
* @param[out] title the title of the suggestion.
|
|
||||||
* @param[out] url the url of the suggestion.
|
|
||||||
* @return True if title and url have been set.
|
|
||||||
*/
|
|
||||||
DEPRECATED bool getNextSuggestion(string& title, string& url);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if we can check zim file integrity (has a checksum).
|
* Get if we can check zim file integrity (has a checksum).
|
||||||
|
@ -485,9 +425,6 @@ class Reader
|
||||||
std::shared_ptr<zim::Archive> zimArchive;
|
std::shared_ptr<zim::Archive> zimArchive;
|
||||||
std::string zimFilePath;
|
std::string zimFilePath;
|
||||||
|
|
||||||
SuggestionsList_t suggestions;
|
|
||||||
SuggestionsList_t::iterator suggestionsOffset;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<const std::string, unsigned int> parseCounterMetadata() const;
|
std::map<const std::string, unsigned int> parseCounterMetadata() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -366,15 +366,6 @@ Library::BookIdCollection Library::getBooksIds() const
|
||||||
return bookIds;
|
return bookIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
Library::BookIdCollection Library::filter(const std::string& search) const
|
|
||||||
{
|
|
||||||
if (search.empty()) {
|
|
||||||
return getBooksIds();
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter(Filter().query(search));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Library::updateBookDB(const Book& book)
|
void Library::updateBookDB(const Book& book)
|
||||||
{
|
{
|
||||||
|
@ -658,48 +649,6 @@ void Library::sort(BookIdCollection& bookIds, supportedListSortBy sort, bool asc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Library::BookIdCollection Library::listBooksIds(
|
|
||||||
int mode,
|
|
||||||
supportedListSortBy sortBy,
|
|
||||||
const std::string& search,
|
|
||||||
const std::string& language,
|
|
||||||
const std::string& creator,
|
|
||||||
const std::string& publisher,
|
|
||||||
const std::vector<std::string>& tags,
|
|
||||||
size_t maxSize) const {
|
|
||||||
|
|
||||||
Filter _filter;
|
|
||||||
if (mode & LOCAL)
|
|
||||||
_filter.local(true);
|
|
||||||
if (mode & NOLOCAL)
|
|
||||||
_filter.local(false);
|
|
||||||
if (mode & VALID)
|
|
||||||
_filter.valid(true);
|
|
||||||
if (mode & NOVALID)
|
|
||||||
_filter.valid(false);
|
|
||||||
if (mode & REMOTE)
|
|
||||||
_filter.remote(true);
|
|
||||||
if (mode & NOREMOTE)
|
|
||||||
_filter.remote(false);
|
|
||||||
if (!tags.empty())
|
|
||||||
_filter.acceptTags(tags);
|
|
||||||
if (maxSize != 0)
|
|
||||||
_filter.maxSize(maxSize);
|
|
||||||
if (!language.empty())
|
|
||||||
_filter.lang(language);
|
|
||||||
if (!publisher.empty())
|
|
||||||
_filter.publisher(publisher);
|
|
||||||
if (!creator.empty())
|
|
||||||
_filter.creator(creator);
|
|
||||||
if (!search.empty())
|
|
||||||
_filter.query(search);
|
|
||||||
|
|
||||||
auto bookIds = filter(_filter);
|
|
||||||
|
|
||||||
sort(bookIds, sortBy, true);
|
|
||||||
return bookIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
Filter::Filter()
|
Filter::Filter()
|
||||||
: activeFilters(0),
|
: activeFilters(0),
|
||||||
_maxSize(0)
|
_maxSize(0)
|
||||||
|
|
|
@ -273,32 +273,6 @@ bool Reader::hasFulltextIndex() const
|
||||||
return zimArchive->hasFulltextIndex();
|
return zimArchive->hasFulltextIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search titles by prefix */
|
|
||||||
|
|
||||||
bool Reader::searchSuggestions(const string& prefix,
|
|
||||||
unsigned int suggestionsCount,
|
|
||||||
const bool reset)
|
|
||||||
{
|
|
||||||
/* Reset the suggestions otherwise check if the suggestions number is less
|
|
||||||
* than the suggestionsCount */
|
|
||||||
if (reset) {
|
|
||||||
this->suggestions.clear();
|
|
||||||
this->suggestionsOffset = this->suggestions.begin();
|
|
||||||
} else {
|
|
||||||
if (this->suggestions.size() > suggestionsCount) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ret = searchSuggestions(prefix, suggestionsCount, this->suggestions);
|
|
||||||
|
|
||||||
/* Set the cursor to the begining */
|
|
||||||
this->suggestionsOffset = this->suggestions.begin();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Reader::searchSuggestions(const string& prefix,
|
bool Reader::searchSuggestions(const string& prefix,
|
||||||
unsigned int suggestionsCount,
|
unsigned int suggestionsCount,
|
||||||
SuggestionsList_t& results)
|
SuggestionsList_t& results)
|
||||||
|
@ -359,19 +333,6 @@ std::vector<std::string> Reader::getTitleVariants(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Reader::searchSuggestionsSmart(const string& prefix,
|
|
||||||
unsigned int suggestionsCount)
|
|
||||||
{
|
|
||||||
this->suggestions.clear();
|
|
||||||
this->suggestionsOffset = this->suggestions.begin();
|
|
||||||
|
|
||||||
auto ret = searchSuggestionsSmart(prefix, suggestionsCount, this->suggestions);
|
|
||||||
|
|
||||||
this->suggestionsOffset = this->suggestions.begin();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try also a few variations of the prefix to have better results */
|
/* Try also a few variations of the prefix to have better results */
|
||||||
bool Reader::searchSuggestionsSmart(const string& prefix,
|
bool Reader::searchSuggestionsSmart(const string& prefix,
|
||||||
unsigned int suggestionsCount,
|
unsigned int suggestionsCount,
|
||||||
|
@ -410,38 +371,6 @@ bool Reader::searchSuggestionsSmart(const string& prefix,
|
||||||
return results.size() > 0;
|
return results.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get next suggestion */
|
|
||||||
bool Reader::getNextSuggestion(string& title)
|
|
||||||
{
|
|
||||||
if (this->suggestionsOffset != this->suggestions.end()) {
|
|
||||||
/* title */
|
|
||||||
title = (*(this->suggestionsOffset)).getTitle();
|
|
||||||
|
|
||||||
/* increment the cursor for the next call */
|
|
||||||
this->suggestionsOffset++;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Reader::getNextSuggestion(string& title, string& url)
|
|
||||||
{
|
|
||||||
if (this->suggestionsOffset != this->suggestions.end()) {
|
|
||||||
/* title */
|
|
||||||
title = (*(this->suggestionsOffset)).getTitle();
|
|
||||||
url = (*(this->suggestionsOffset)).getPath();
|
|
||||||
|
|
||||||
/* increment the cursor for the next call */
|
|
||||||
this->suggestionsOffset++;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the file has as checksum */
|
/* Check if the file has as checksum */
|
||||||
bool Reader::canCheckIntegrity() const
|
bool Reader::canCheckIntegrity() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue