mirror of https://github.com/kiwix/libkiwix.git
Manager is now safe to copy
This commit is contained in:
parent
913a368a12
commit
571e417d1e
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace pugi {
|
namespace pugi {
|
||||||
class xml_document;
|
class xml_document;
|
||||||
|
@ -64,7 +65,6 @@ class Manager
|
||||||
public:
|
public:
|
||||||
explicit Manager(LibraryManipulator* manipulator);
|
explicit Manager(LibraryManipulator* manipulator);
|
||||||
explicit Manager(Library* library);
|
explicit Manager(Library* library);
|
||||||
~Manager();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a `library.xml` and add book in the file to the library.
|
* Read a `library.xml` and add book in the file to the library.
|
||||||
|
@ -150,8 +150,7 @@ class Manager
|
||||||
uint64_t m_itemsPerPage = 0;
|
uint64_t m_itemsPerPage = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
kiwix::LibraryManipulator* manipulator;
|
std::shared_ptr<kiwix::LibraryManipulator> manipulator;
|
||||||
bool mustDeleteManipulator;
|
|
||||||
|
|
||||||
bool readBookFromPath(const std::string& path, Book* book);
|
bool readBookFromPath(const std::string& path, Book* book);
|
||||||
bool parseXmlDom(const pugi::xml_document& doc,
|
bool parseXmlDom(const pugi::xml_document& doc,
|
||||||
|
|
|
@ -26,28 +26,30 @@
|
||||||
|
|
||||||
namespace kiwix
|
namespace kiwix
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
struct NoDelete
|
||||||
|
{
|
||||||
|
template<class T> void operator()(T*) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // unnamed namespace
|
||||||
|
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
Manager::Manager(LibraryManipulator* manipulator):
|
Manager::Manager(LibraryManipulator* manipulator):
|
||||||
writableLibraryPath(""),
|
writableLibraryPath(""),
|
||||||
manipulator(manipulator),
|
manipulator(manipulator, NoDelete())
|
||||||
mustDeleteManipulator(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Manager::Manager(Library* library) :
|
Manager::Manager(Library* library) :
|
||||||
writableLibraryPath(""),
|
writableLibraryPath(""),
|
||||||
manipulator(new DefaultLibraryManipulator(library)),
|
manipulator(new DefaultLibraryManipulator(library))
|
||||||
mustDeleteManipulator(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destructor */
|
|
||||||
Manager::~Manager()
|
|
||||||
{
|
|
||||||
if (mustDeleteManipulator) {
|
|
||||||
delete manipulator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool Manager::parseXmlDom(const pugi::xml_document& doc,
|
bool Manager::parseXmlDom(const pugi::xml_document& doc,
|
||||||
bool readOnly,
|
bool readOnly,
|
||||||
const std::string& libraryPath,
|
const std::string& libraryPath,
|
||||||
|
|
Loading…
Reference in New Issue