+ Move beautifyInteger() to stringTools.[h|cpp]

This commit is contained in:
kelson42 2012-04-28 16:16:54 +00:00
parent f48df4a960
commit 4dd4d510c9
4 changed files with 23 additions and 20 deletions

View File

@ -21,20 +21,6 @@
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() :
searchPattern(""),
@ -173,10 +159,10 @@ namespace kiwix {
result["snippet"] = this->resultOffset->snippet;
if (this->resultOffset->size >= 0)
result["size"] = this->beautifyInteger(this->resultOffset->size);
result["size"] = ::beautifyInteger(this->resultOffset->size);
if (this->resultOffset->wordCount >= 0)
result["wordCount"] = this->beautifyInteger(this->resultOffset->wordCount);
result["wordCount"] = ::beautifyInteger(this->resultOffset->wordCount);
resultsCDT.PushBack(result);
this->resultOffset++;
@ -208,7 +194,7 @@ namespace kiwix {
}
oData["pages"] = pagesCDT;
oData["count"] = this->beautifyInteger(this->estimatedResultCount);
oData["count"] = ::beautifyInteger(this->estimatedResultCount);
oData["searchPattern"] = this->searchPattern;
oData["resultStart"] = this->resultStart + 1;
oData["resultEnd"] = (this->resultEnd > this->estimatedResultCount ? this->estimatedResultCount : this->resultEnd);

View File

@ -24,15 +24,13 @@
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <locale>
#include <cctype>
#include <vector>
#include <unaccent.h>
#include <resourceTools.h>
#include <stringTools.h>
#include <CTPP2Parser.hpp>
#include <CTPP2FileSourceLoader.hpp>

View File

@ -19,6 +19,22 @@
#include "stringTools.h"
/* Prepare integer for display */
std::string 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;
}
/* Split string in a token array */
std::vector<std::string> split(const std::string & str,
const std::string & delims=" *-")
{

View File

@ -20,9 +20,12 @@
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
std::string beautifyInteger(const unsigned int number);
std::vector<std::string> split(const std::string&, const std::string&);
std::vector<std::string> split(const char*, const char*);
std::vector<std::string> split(const std::string&, const char*);