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

@@ -327,12 +327,23 @@ void FileChannel::setCompress(const std::string& compress)
void FileChannel::setPurgeAge(const std::string& age)
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_purgeAge = "none";
if (age.empty() || 0 == icompare(age, "none"))
return;
std::string::const_iterator it = age.begin();
std::string::const_iterator end = age.end();
int n = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
if (0 == n)
throw InvalidArgumentException("Zero is not valid purge age.");
while (it != end && Ascii::isSpace(*it)) ++it;
std::string unit;
while (it != end && Ascii::isAlpha(*it)) unit += *it++;
@@ -349,8 +360,7 @@ void FileChannel::setPurgeAge(const std::string& age)
factor = 30*Timespan::DAYS;
else if (unit != "seconds")
throw InvalidArgumentException("purgeAge", age);
delete _pPurgeStrategy;
_pPurgeStrategy = new PurgeByAgeStrategy(Timespan(factor*n));
_purgeAge = age;
}
@@ -358,11 +368,20 @@ void FileChannel::setPurgeAge(const std::string& age)
void FileChannel::setPurgeCount(const std::string& count)
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_purgeAge = "none";
if (count.empty() || 0 == icompare(count, "none"))
return;
std::string::const_iterator it = count.begin();
std::string::const_iterator end = count.end();
int n = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
if (0 == n)
throw InvalidArgumentException("Zero is not valid purge count.");
while (it != end && Ascii::isSpace(*it)) ++it;
delete _pPurgeStrategy;