From d2a280289788ed27c5c519ac41010b6a32321751 Mon Sep 17 00:00:00 2001 From: renaud gaudin Date: Sat, 10 Aug 2013 22:14:18 +0800 Subject: [PATCH] ctpp2 as external lib on unix --- src/common/kiwix/searcher.cpp | 34 ++++----- static/results.tmpl | 130 +--------------------------------- 2 files changed, 18 insertions(+), 146 deletions(-) diff --git a/src/common/kiwix/searcher.cpp b/src/common/kiwix/searcher.cpp index b480e06d7..b02ea7e41 100644 --- a/src/common/kiwix/searcher.cpp +++ b/src/common/kiwix/searcher.cpp @@ -32,13 +32,13 @@ namespace kiwix { resultEnd(0), resultRange(20) { } - + /* Search strings in the database */ - void Searcher::search(std::string &search, const unsigned int resultStart, + void Searcher::search(std::string &search, const unsigned int resultStart, const unsigned int resultEnd, const bool verbose) { - + this->reset(); - + if (verbose == true) { cout << "Performing query `" << search << "'" << endl; } @@ -53,7 +53,7 @@ namespace kiwix { return; } - + /* Reset the results */ void Searcher::reset() { this->results.clear(); @@ -67,25 +67,25 @@ namespace kiwix { unsigned int Searcher::getEstimatedResultCount() { return this->estimatedResultCount; } - + /* Get next result */ bool Searcher::getNextResult(string &url, string &title, unsigned int &score) { bool retVal = false; - + if (this->resultOffset != this->results.end()) { - + /* url */ url = this->resultOffset->url; - + /* title */ title = this->resultOffset->title; - + /* score */ score = this->resultOffset->score; - + /* increment the cursor for the next call */ this->resultOffset++; - + retVal = true; } @@ -107,20 +107,20 @@ namespace kiwix { } string Searcher::getHtml() { - + VMOpcodeCollector oVMOpcodeCollector; StaticText oSyscalls; StaticData oStaticData; StaticText oStaticText; HashTable oHashTable; CTPP2Compiler oCompiler(oVMOpcodeCollector, oSyscalls, oStaticData, oStaticText, oHashTable); - + /* Load template & create template parser */ // cout << getResourceAsString("results.tmpl") << endl; /* Parse template */ const STLW::string & sSourceFile = getResourceAsString("results.tmpl"); - CTPP2TextLoader oSourceLoader; + CTPP2TextLoader oSourceLoader; oSourceLoader.LoadTemplate(sSourceFile.c_str()); CTPP2Parser oCTPP2Parser(&oSourceLoader, &oCompiler, "template"); oCTPP2Parser.Compile(); @@ -180,7 +180,7 @@ namespace kiwix { pageCount = 10; else if (pageCount == 1) pageCount = 0; - + for (unsigned int i=pageStart; i - - - - - Search: <TMPL_var searchPattern> - - -
- - Results - of for No result were found for -
- -
-
    - - -
  • - - ... -
    words
    -
  • -
    -
-
- - - - +SALUT \ No newline at end of file