double-conversion floating-point conversions

- using double-conversion library for floating-point numeric/string
conversions
- added string replace[InPlace], remove[InPlace]
- reverted overwritten FileChannel purge age and count features
- file size value checks in SMTPClient
This commit is contained in:
aleks-f
2012-12-01 14:02:51 -06:00
parent 9dd1482a02
commit 134558f926
13 changed files with 372 additions and 293 deletions

View File

@@ -165,6 +165,22 @@ std::string replace(const std::string& str, const std::string::value_type* from,
return result;
}
std::string replace(const std::string& str, const std::string::value_type from, const std::string::value_type to, std::string::size_type start)
{
std::string result(str);
replaceInPlace(result, from, to, start);
return result;
}
std::string remove(const std::string& str, const std::string::value_type ch, std::string::size_type start)
{
std::string result(str);
replaceInPlace(result, ch, 0, start);
return result;
}
std::string& replaceInPlace(std::string& str, const std::string& from, const std::string& to, std::string::size_type start)
{
@@ -215,6 +231,31 @@ std::string& replaceInPlace(std::string& str, const std::string::value_type* fro
}
std::string& replaceInPlace(std::string& str, const std::string::value_type from, const std::string::value_type to, std::string::size_type start)
{
if (from == to) return str;
std::string::size_type pos = 0;
do
{
pos = str.find(from, start);
if (pos != std::string::npos)
{
if (to) str[pos] = to;
else str.erase(pos, 1);
}
} while (pos != std::string::npos);
return str;
}
std::string& removeInPlace(std::string& str, const std::string::value_type ch, std::string::size_type start)
{
return replaceInPlace(str, ch, 0, start);
}
#endif