Make fulltext searcher Android compatible

This commit is contained in:
Kelson 2016-10-14 13:12:26 +02:00
parent 01794e6e91
commit 2889d7c651
3 changed files with 18 additions and 15 deletions

View File

@ -34,9 +34,11 @@ namespace kiwix {
{ {
template_ct2 = getResourceAsString("results.ct2"); template_ct2 = getResourceAsString("results.ct2");
loadICUExternalTables(); loadICUExternalTables();
} }
/* Destructor */
Searcher::~Searcher() {}
/* Search strings in the database */ /* Search strings in the database */
void Searcher::search(std::string &search, unsigned int resultStart, void Searcher::search(std::string &search, unsigned int resultStart,
unsigned int resultEnd, const bool verbose) { unsigned int resultEnd, const bool verbose) {
@ -127,6 +129,8 @@ namespace kiwix {
this->contentHumanReadableId = contentHumanReadableId; this->contentHumanReadableId = contentHumanReadableId;
} }
#ifndef __ANDROID__
string Searcher::getHtml() { string Searcher::getHtml() {
SimpleVM oSimpleVM; SimpleVM oSimpleVM;
@ -203,9 +207,6 @@ namespace kiwix {
} }
/* Destructor */ #endif
Searcher::~Searcher() {
}
} }

View File

@ -33,14 +33,16 @@
#include <stringTools.h> #include <stringTools.h>
#include "unicode/putil.h" #include "unicode/putil.h"
#ifndef __ANDROID__
#include <ctpp2/CDT.hpp> #include <ctpp2/CDT.hpp>
#include <ctpp2/CTPP2FileLogger.hpp> #include <ctpp2/CTPP2FileLogger.hpp>
#include <ctpp2/CTPP2SimpleVM.hpp> #include <ctpp2/CTPP2SimpleVM.hpp>
#include "kiwix/ctpp2/CTPP2VMStringLoader.hpp" #include "kiwix/ctpp2/CTPP2VMStringLoader.hpp"
using namespace std;
using namespace CTPP; using namespace CTPP;
#endif
using namespace std;
struct Result struct Result
{ {
@ -58,6 +60,7 @@ namespace kiwix {
public: public:
Searcher(); Searcher();
~Searcher();
void search(std::string &search, unsigned int resultStart, void search(std::string &search, unsigned int resultStart,
unsigned int resultEnd, const bool verbose=false); unsigned int resultEnd, const bool verbose=false);
@ -65,10 +68,12 @@ namespace kiwix {
unsigned int getEstimatedResultCount(); unsigned int getEstimatedResultCount();
bool setProtocolPrefix(const std::string prefix); bool setProtocolPrefix(const std::string prefix);
bool setSearchProtocolPrefix(const std::string prefix); bool setSearchProtocolPrefix(const std::string prefix);
string getHtml();
void reset(); void reset();
void setContentHumanReadableId(const string &contentHumanReadableId); void setContentHumanReadableId(const string &contentHumanReadableId);
~Searcher();
#ifndef __ANDROID__
string getHtml();
#endif
protected: protected:
std::string beautifyInteger(const unsigned int number); std::string beautifyInteger(const unsigned int number);

View File

@ -27,10 +27,8 @@ using namespace std;
namespace kiwix { namespace kiwix {
class NoXapianIndexInZim: public exception class NoXapianIndexInZim: public exception {
{ virtual const char* what() const throw() {
virtual const char* what() const throw()
{
return "There is no fulltext index in the zim file"; return "There is no fulltext index in the zim file";
} }
}; };
@ -39,7 +37,6 @@ namespace kiwix {
public: public:
XapianSearcher(const string &xapianDirectoryPath); XapianSearcher(const string &xapianDirectoryPath);
void searchInIndex(string &search, const unsigned int resultStart, const unsigned int resultEnd, void searchInIndex(string &search, const unsigned int resultStart, const unsigned int resultEnd,
const bool verbose=false); const bool verbose=false);