mirror of https://github.com/kiwix/libkiwix.git
+ beautifyInteger()
This commit is contained in:
parent
5e5eb61fd2
commit
8b291cd219
|
@ -21,6 +21,20 @@
|
|||
|
||||
namespace kiwix {
|
||||
|
||||
/* Count word */
|
||||
std::string Searcher::beautifyInteger(const unsigned int number) {
|
||||
stringstream numberStream;
|
||||
numberStream << number;
|
||||
std::string numberString = numberStream.str();
|
||||
|
||||
signed int offset = numberString.size() - 3;
|
||||
while (offset > 0) {
|
||||
numberString.insert(offset, ".");
|
||||
offset -= 3;
|
||||
}
|
||||
return numberString;
|
||||
}
|
||||
|
||||
/* Constructor */
|
||||
Searcher::Searcher() :
|
||||
estimatedResultCount(0),
|
||||
|
@ -54,7 +68,7 @@ namespace kiwix {
|
|||
}
|
||||
|
||||
/* Return the result count estimation */
|
||||
const unsigned int Searcher::getEstimatedResultCount() {
|
||||
unsigned int Searcher::getEstimatedResultCount() {
|
||||
return this->estimatedResultCount;
|
||||
}
|
||||
|
||||
|
@ -82,12 +96,12 @@ namespace kiwix {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
const bool Searcher::setResultTemplatePath(const std::string path) {
|
||||
bool Searcher::setResultTemplatePath(const std::string path) {
|
||||
this->resultTemplatePath = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
const string Searcher::getHtml() {
|
||||
string Searcher::getHtml() {
|
||||
|
||||
const STLW::string & sSourceFile = this->resultTemplatePath;
|
||||
VMOpcodeCollector oVMOpcodeCollector;
|
||||
|
@ -139,8 +153,8 @@ namespace kiwix {
|
|||
result["title"] = this->resultOffset->title;
|
||||
result["url"] = this->resultOffset->url;
|
||||
result["snippet"] = this->resultOffset->snippet;
|
||||
result["size"] = this->resultOffset->size;
|
||||
result["wordCount"] = this->resultOffset->wordCount;
|
||||
result["size"] = this->beautifyInteger(this->resultOffset->size);
|
||||
result["wordCount"] = this->beautifyInteger(this->resultOffset->wordCount);
|
||||
resultsCDT.PushBack(result);
|
||||
this->resultOffset++;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <locale>
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
|
@ -64,12 +67,13 @@ namespace kiwix {
|
|||
|
||||
void search(std::string &search, const unsigned int resultsCount, const bool verbose=false);
|
||||
bool getNextResult(string &url, string &title, unsigned int &score);
|
||||
const unsigned int getEstimatedResultCount();
|
||||
const bool setResultTemplatePath(const std::string path);
|
||||
const string getHtml();
|
||||
unsigned int getEstimatedResultCount();
|
||||
bool setResultTemplatePath(const std::string path);
|
||||
string getHtml();
|
||||
void reset();
|
||||
|
||||
protected:
|
||||
std::string beautifyInteger(const unsigned int number);
|
||||
virtual void closeIndex() = 0;
|
||||
virtual void searchInIndex(string &search, const unsigned int resultsCount, const bool verbose=false) = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue