mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-16 23:12:57 +02:00
updated convertToRegFormat name to begin with lowercase and added test
This commit is contained in:
parent
f5bb43f9d3
commit
e5e3a57baf
@ -76,10 +76,11 @@ protected:
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
|
||||
std::string ConvertToRegFormat(const std::string& key, std::string& keyName) const;
|
||||
/// takes a key in the format of A.B.C and converts it to
|
||||
std::string convertToRegFormat(const std::string& key, std::string& keyName) const;
|
||||
/// Takes a key in the format of A.B.C and converts it to
|
||||
/// registry format A\B\C, the last entry is the keyName, the rest is returned as path
|
||||
|
||||
friend class WinConfigurationTest;
|
||||
private:
|
||||
std::string _rootPath;
|
||||
REGSAM _extraSam;
|
||||
|
@ -65,7 +65,7 @@ WinRegistryConfiguration::~WinRegistryConfiguration()
|
||||
bool WinRegistryConfiguration::getRaw(const std::string& key, std::string& value) const
|
||||
{
|
||||
std::string keyName;
|
||||
std::string fullPath = _rootPath + ConvertToRegFormat(key, keyName);
|
||||
std::string fullPath = _rootPath + convertToRegFormat(key, keyName);
|
||||
WinRegistryKey aKey(fullPath, true, _extraSam);
|
||||
bool exists = aKey.exists(keyName);
|
||||
if (exists)
|
||||
@ -94,7 +94,7 @@ bool WinRegistryConfiguration::getRaw(const std::string& key, std::string& value
|
||||
void WinRegistryConfiguration::setRaw(const std::string& key, const std::string& value)
|
||||
{
|
||||
std::string keyName;
|
||||
std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName);
|
||||
std::string fullPath = _rootPath + convertToRegFormat(key, keyName);
|
||||
WinRegistryKey aKey(fullPath, false, _extraSam);
|
||||
aKey.setString(keyName, value);
|
||||
}
|
||||
@ -115,7 +115,7 @@ void WinRegistryConfiguration::enumerate(const std::string& key, Keys& range) co
|
||||
else
|
||||
{
|
||||
std::string keyName;
|
||||
std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName);
|
||||
std::string fullPath = _rootPath + convertToRegFormat(key, keyName);
|
||||
WinRegistryKey aKey(fullPath, true, _extraSam);
|
||||
aKey.values(range);
|
||||
aKey.subKeys(range);
|
||||
@ -129,7 +129,7 @@ void WinRegistryConfiguration::removeRaw(const std::string& key)
|
||||
}
|
||||
|
||||
|
||||
std::string WinRegistryConfiguration::ConvertToRegFormat(const std::string& key, std::string& value) const
|
||||
std::string WinRegistryConfiguration::convertToRegFormat(const std::string& key, std::string& value) const
|
||||
{
|
||||
std::size_t pos = key.rfind('.');
|
||||
if (pos == std::string::npos)
|
||||
|
@ -74,6 +74,10 @@ void WinConfigurationTest::testConfiguration()
|
||||
|
||||
pView->setString("sub.foo", "bar");
|
||||
assert (pView->getString("sub.foo", "default") == "bar");
|
||||
|
||||
std::string value;
|
||||
assert (pReg->convertToRegFormat("A.B.C", value) == "A\\B");
|
||||
assert (value == "C");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user