+ change call of function appendToFirstOccurence() and replaceRegex()

This commit is contained in:
kelson42 2012-06-28 12:53:06 +00:00
parent 084af011dd
commit 28138e7ff9
3 changed files with 12 additions and 10 deletions

View File

@ -63,10 +63,10 @@ namespace kiwix {
std::string id = path;
if (!id.empty()) {
removeAccents(id);
replaceRegex(id, "", "^.*/");
replaceRegex(id, "", "\\.zim[a-z]*$");
replaceRegex(id, "_", " ");
replaceRegex(id, "plus", "\\+");
id = replaceRegex(id, "", "^.*/");
id = replaceRegex(id, "", "\\.zim[a-z]*$");
id = replaceRegex(id, "_", " ");
id = replaceRegex(id, "plus", "\\+");
}
return id;
}

View File

@ -53,7 +53,7 @@ bool matchRegex(const std::string &content, const std::string &regex) {
return matcher->find();
}
void replaceRegex(std::string &content, const std::string &replacement, const std::string &regex) {
std::string replaceRegex(const std::string &content, const std::string &replacement, const std::string &regex) {
ucnv_setDefaultName("UTF-8");
UnicodeString ucontent = UnicodeString(content.c_str());
UnicodeString ureplacement = UnicodeString(replacement.c_str());
@ -63,10 +63,10 @@ void replaceRegex(std::string &content, const std::string &replacement, const st
UnicodeString uresult = matcher->replaceAll(ureplacement, status);
std::string tmp;
uresult.toUTF8String(tmp);
content=tmp;
return tmp;
}
void appendToFirstOccurence(std::string &content, const std::string regex, const std::string &replacement) {
std::string appendToFirstOccurence(const std::string &content, const std::string regex, const std::string &replacement) {
ucnv_setDefaultName("UTF-8");
UnicodeString ucontent = UnicodeString(content.c_str());
UnicodeString ureplacement = UnicodeString(replacement.c_str());
@ -78,7 +78,9 @@ void appendToFirstOccurence(std::string &content, const std::string regex, cons
ucontent.insert(matcher->end(status), ureplacement);
std::string tmp;
ucontent.toUTF8String(tmp);
content=tmp;
return tmp;
}
return content;
}

View File

@ -26,7 +26,7 @@
#include <map>
bool matchRegex(const std::string &content, const std::string &regex);
void replaceRegex(std::string &content, const std::string &replacement, const std::string &regex);
void appendToFirstOccurence(std::string &content, const std::string regex, const std::string &replacement);
std::string replaceRegex(const std::string &content, const std::string &replacement, const std::string &regex);
std::string appendToFirstOccurence(const std::string &content, const std::string regex, const std::string &replacement);
#endif