mirror of https://github.com/kiwix/libkiwix.git
+ kiwix-manage new devs.
This commit is contained in:
parent
93d5daeb94
commit
08bcb43afb
|
@ -47,4 +47,9 @@ namespace kiwix {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Library::removeBookByIndex(const unsigned int bookIndex) {
|
||||
books.erase(books.begin()+bookIndex-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace kiwix {
|
|||
|
||||
string current;
|
||||
bool addBook(const Book &book);
|
||||
bool removeBookByIndex(const unsigned int bookIndex);
|
||||
vector <kiwix::Book> books;
|
||||
|
||||
};
|
||||
|
|
|
@ -53,6 +53,25 @@ namespace kiwix {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool Manager::writeFile(const string path) {
|
||||
pugi::xml_document doc;
|
||||
|
||||
/* Add the library node */
|
||||
pugi::xml_node libraryNode = doc.append_child("library");
|
||||
libraryNode.append_attribute("current") = library.current.c_str();
|
||||
|
||||
/* Add each book */
|
||||
|
||||
/* saving file */
|
||||
doc.save_file(path.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Manager::removeBookByIndex(const unsigned int bookIndex) {
|
||||
return this->library.removeBookByIndex(bookIndex);
|
||||
}
|
||||
|
||||
kiwix::Library Manager::cloneLibrary() {
|
||||
return this->library;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace kiwix {
|
|||
~Manager();
|
||||
|
||||
bool readFile(const string path);
|
||||
bool writeFile(const string path);
|
||||
bool removeBookByIndex(const unsigned int bookIndex);
|
||||
kiwix::Library cloneLibrary();
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue