+ replace in the searcher the usage of dynamic loaded template file by the usage of a resource

This commit is contained in:
kelson42 2012-04-23 21:20:25 +00:00
parent 359f386ebe
commit 040ace5091
2 changed files with 10 additions and 16 deletions

View File

@ -37,7 +37,6 @@ namespace kiwix {
/* Constructor */
Searcher::Searcher() :
resultTemplatePath(""),
searchPattern(""),
resultCountPerPage(0),
estimatedResultCount(0),
@ -106,11 +105,6 @@ namespace kiwix {
return retVal;
}
bool Searcher::setResultTemplatePath(const std::string path) {
this->resultTemplatePath = path;
return true;
}
bool Searcher::setProtocolPrefix(const std::string prefix) {
this->protocolPrefix = prefix;
return true;
@ -127,7 +121,6 @@ namespace kiwix {
string Searcher::getHtml() {
const STLW::string & sSourceFile = this->resultTemplatePath;
VMOpcodeCollector oVMOpcodeCollector;
StaticText oSyscalls;
StaticData oStaticData;
@ -135,14 +128,15 @@ namespace kiwix {
HashTable oHashTable;
CTPP2Compiler oCompiler(oVMOpcodeCollector, oSyscalls, oStaticData, oStaticText, oHashTable);
// Load template
CTPP2FileSourceLoader oSourceLoader;
// Load template & create template parser
//cout << getResourceAsString("results.tmpl") << endl;
/* Parse template */
const STLW::string & sSourceFile = getResourceAsString("results.tmpl");
CTPP2TextLoader oSourceLoader;
oSourceLoader.LoadTemplate(sSourceFile.c_str());
// Create template parser
CTPP2Parser oCTPP2Parser(&oSourceLoader, &oCompiler, sSourceFile);
// Compile template
CTPP2Parser oCTPP2Parser(&oSourceLoader, &oCompiler, "template");
oCTPP2Parser.Compile();
// Get program core

View File

@ -32,9 +32,11 @@
#include <cctype>
#include <vector>
#include <unaccent.h>
#include <resourceTools.h>
#include <CTPP2Parser.hpp>
#include <CTPP2FileSourceLoader.hpp>
#include <CTPP2TextLoader.hpp>
#include <CTPP2ParserException.hpp>
#include <CTPP2HashTable.hpp>
#include <CTPP2VMDumper.hpp>
@ -69,7 +71,6 @@ namespace kiwix {
const unsigned int resultEnd, const bool verbose=false);
bool getNextResult(string &url, string &title, unsigned int &score);
unsigned int getEstimatedResultCount();
bool setResultTemplatePath(const std::string path);
bool setProtocolPrefix(const std::string prefix);
bool setSearchProtocolPrefix(const std::string prefix);
string getHtml();
@ -84,7 +85,6 @@ namespace kiwix {
std::vector<Result> results;
std::vector<Result>::iterator resultOffset;
std::string resultTemplatePath;
std::string searchPattern;
unsigned int resultCountPerPage;
unsigned int estimatedResultCount;