SF #3544720: AbstractConfigurator to support 64bit values

This commit is contained in:
Aleksandar Fabijanic
2012-08-21 02:42:57 +00:00
parent 7a177a0d79
commit 2b2a362926
6 changed files with 159 additions and 23 deletions

View File

@@ -174,6 +174,18 @@ Int64 AbstractConfiguration::getInt64(const std::string& key) const
}
UInt64 AbstractConfiguration::getUInt64(const std::string& key) const
{
FastMutex::ScopedLock lock(_mutex);
std::string value;
if (getRaw(key, value))
return NumberParser::parseUnsigned64(internalExpand(value));
else
throw NotFoundException(key);
}
Int64 AbstractConfiguration::getInt64(const std::string& key, Int64 defaultValue) const
{
FastMutex::ScopedLock lock(_mutex);
@@ -185,6 +197,18 @@ Int64 AbstractConfiguration::getInt64(const std::string& key, Int64 defaultValue
return defaultValue;
}
UInt64 AbstractConfiguration::getUInt64(const std::string& key, UInt64 defaultValue) const
{
FastMutex::ScopedLock lock(_mutex);
std::string value;
if (getRaw(key, value))
return NumberParser::parseUnsigned64(internalExpand(value));
else
return defaultValue;
}
#endif // defined(POCO_HAVE_INT64)
@@ -247,6 +271,12 @@ void AbstractConfiguration::setInt(const std::string& key, int value)
setRawWithEvent(key, NumberFormatter::format(value));
}
void AbstractConfiguration::setUInt(const std::string& key, unsigned int value)
{
setRawWithEvent(key, NumberFormatter::format(value));
}
#if defined(POCO_HAVE_INT64)
@@ -254,7 +284,15 @@ void AbstractConfiguration::setInt64(const std::string& key, Int64 value)
{
FastMutex::ScopedLock lock(_mutex);
setRaw(key, NumberFormatter::format(value));
setRawWithEvent(key, NumberFormatter::format(value));
}
void AbstractConfiguration::setUInt64(const std::string& key, UInt64 value)
{
FastMutex::ScopedLock lock(_mutex);
setRawWithEvent(key, NumberFormatter::format(value));
}
#endif // defined(POCO_HAVE_INT64)
@@ -419,6 +457,33 @@ int AbstractConfiguration::parseInt(const std::string& value)
}
int AbstractConfiguration::parseUInt(const std::string& value)
{
if (value.compare(0, 2, "0x") == 0)
return NumberParser::parseHex(value.substr(2));
else
return NumberParser::parseUnsigned(value);
}
Int64 AbstractConfiguration::parseInt64(const std::string& value)
{
if (value.compare(0, 2, "0x") == 0)
return NumberParser::parseHex64(value.substr(2));
else
return NumberParser::parse64(value);
}
UInt64 AbstractConfiguration::parseUInt64(const std::string& value)
{
if (value.compare(0, 2, "0x") == 0)
return NumberParser::parseHex64(value.substr(2));
else
return NumberParser::parseUnsigned64(value);
}
bool AbstractConfiguration::parseBool(const std::string& value)
{
int n;