mirror of https://github.com/kiwix/libkiwix.git
Get information about the total number of book of a search.
When we do a search and paging the result, we need to display to the user the total number of book, not only the `itemsPerPage`. So, we need to parse correctly the xml to keep information of the total number of book.
This commit is contained in:
parent
5f4c04e79e
commit
9ab44e6a5f
|
@ -196,7 +196,10 @@ class Manager
|
|||
|
||||
std::string writableLibraryPath;
|
||||
|
||||
std::vector<std::string> bookIdList;
|
||||
bool m_hasSearchResult = false;
|
||||
uint64_t m_totalBooks = 0;
|
||||
uint64_t m_startIndex = 0;
|
||||
uint64_t m_itemsPerPage = 0;
|
||||
|
||||
protected:
|
||||
kiwix::LibraryManipulator* manipulator;
|
||||
|
|
|
@ -95,6 +95,15 @@ bool Manager::parseOpdsDom(const pugi::xml_document& doc, const std::string& url
|
|||
{
|
||||
pugi::xml_node libraryNode = doc.child("feed");
|
||||
|
||||
try {
|
||||
m_totalBooks = strtoull(libraryNode.child("totalResults").child_value(), 0, 0);
|
||||
m_startIndex = strtoull(libraryNode.child("startIndex").child_value(), 0, 0);
|
||||
m_itemsPerPage = strtoull(libraryNode.child("itemsPerPage").child_value(), 0, 0);
|
||||
m_hasSearchResult = true;
|
||||
} catch(...) {
|
||||
m_hasSearchResult = false;
|
||||
}
|
||||
|
||||
for (pugi::xml_node entryNode = libraryNode.child("entry"); entryNode;
|
||||
entryNode = entryNode.next_sibling("entry")) {
|
||||
kiwix::Book book;
|
||||
|
|
Loading…
Reference in New Issue