41 #ifdef CHECK_MEMORY_LEAKS
43 #endif // CHECK_MEMORY_LEAKS
57 const size_t endpos = str.find_last_not_of(
" \t\n\r");
58 if (std::string::npos != endpos) {
59 const size_t startpos = str.find_first_not_of(
" \t\n\r");
60 return str.substr(startpos, endpos - startpos + 1);
68 for (
size_t i = 0; i < str.length(); i++) {
69 if (str[i] >=
'A' && str[i] <=
'Z') {
70 str[i] = str[i] +
'a' -
'A';
79 str =
replace(str,
"ä , "ae");
str = replace(str, "Ä", "Ae");
str = replace(str, "ö", "oe");
str = replace(str, "Ö", "Oe");
str = replace(str, "ü", "ue");
str = replace(str, "Ü", "Ue");
str = replace(str, "ß", "ss");
str = replace(str, "É", "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"ae");
80 str =
replace(str,
"Ä , "Ae");
str = replace(str, "ö", "oe");
str = replace(str, "Ö", "Oe");
str = replace(str, "ü", "ue");
str = replace(str, "Ü", "Ue");
str = replace(str, "ß", "ss");
str = replace(str, "É", "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"Ae");
81 str =
replace(str,
"ö , "oe");
str = replace(str, "Ö", "Oe");
str = replace(str, "ü", "ue");
str = replace(str, "Ü", "Ue");
str = replace(str, "ß", "ss");
str = replace(str, "É", "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"oe");
82 str =
replace(str,
"Ö , "Oe");
str = replace(str, "ü", "ue");
str = replace(str, "Ü", "Ue");
str = replace(str, "ß", "ss");
str = replace(str, "É", "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"Oe");
83 str =
replace(str,
"ü , "ue");
str = replace(str, "Ü", "Ue");
str = replace(str, "ß", "ss");
str = replace(str, "É", "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"ue");
84 str =
replace(str,
"Ü , "Ue");
str = replace(str, "ß", "ss");
str = replace(str, "É", "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"Ue");
85 str =
replace(str,
"ß , "ss");
str = replace(str, "É", "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"ss");
86 str =
replace(str,
"É , "E");
str = replace(str, "é", "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"E");
87 str =
replace(str,
"é , "e");
str = replace(str, "È", "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"e");
88 str =
replace(str,
"È , "E");
str = replace(str, "è", "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"E");
89 str =
replace(str,
"è , "e");
return str;
}
std::string
StringUtils::replace(std::string str, const char* what,
const char* by) {
const std::string what_tmp(what);
const std::string by_tmp(by);
size_t idx = str.find(what);
const size_t what_len = what_tmp.length();
if (what_len > 0) {
const size_t by_len = by_tmp.length();
while (idx != std::string::npos) {
str = str.replace(idx, what_len, by);
idx = str.find(what, idx + by_len);
}
}
return str;
}
std::string
StringUtils::toTimeString(int time) {
std::ostringstream oss;
if (time < 0) {
oss << "-";
time = -time;
}
char buffer[10];
sprintf(buffer, "%02i:", (time / 3600));
oss << buffer;
time = time % 3600;
sprintf(buffer, "%02i:", (time / 60));
oss << buffer;
time = time % 60;
sprintf(buffer, "%02i", time);
oss << buffer;
return oss.str();
}
std::string
StringUtils::escapeXML(const std::string& orig) {
std::string result = replace(orig, "&", "&");
result = replace(result, ">", ">");
result = replace(result, "<", "<");
result = replace(result, "\"", """);
for (char invalid = '\1'; invalid < ' '; invalid++) {
result = replace(result, std::string(1, invalid).c_str(), "");
}
return replace(result, "'", "'");
}
/****************************************************************************/
",
"e");
98 const std::string what_tmp(what);
99 const std::string by_tmp(by);
100 size_t idx = str.find(what);
101 const size_t what_len = what_tmp.length();
103 const size_t by_len = by_tmp.length();
104 while (idx != std::string::npos) {
105 str = str.replace(idx, what_len, by);
106 idx = str.find(what, idx + by_len);
115 std::ostringstream oss;
121 sprintf(buffer,
"%02i:", (time / 3600));
124 sprintf(buffer,
"%02i:", (time / 60));
127 sprintf(buffer,
"%02i", time);
135 std::string result =
replace(orig,
"&",
"&");
136 result =
replace(result,
">",
">");
137 result =
replace(result,
"<",
"<");
138 result =
replace(result,
"\"",
""");
139 for (
char invalid =
'\1'; invalid <
' '; invalid++) {
140 result =
replace(result, std::string(1, invalid).c_str(),
"");
142 return replace(result,
"'",
"'");
static std::string escapeXML(const std::string &orig)
Replaces the standard escapes by their XML entities.
static std::string toTimeString(int time)
Builds a time string (hh:mm:ss) from the given seconds.
static std::string convertUmlaute(std::string str)
Converts german "Umlaute" to their latin-version.
static std::string emptyString
An empty string.
static std::string replace(std::string str, const char *what, const char *by)
static std::string to_lower_case(std::string str)
Transfers the content to lower case.
static std::string prune(std::string str)
Removes trailing and leading whitechars.