mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-26 18:11:29 +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 enumerate(const std::string& key, Keys& range) const;
|
||||||
void removeRaw(const std::string& key);
|
void removeRaw(const std::string& key);
|
||||||
|
|
||||||
std::string ConvertToRegFormat(const std::string& key, std::string& keyName) const;
|
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
|
/// 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
|
/// registry format A\B\C, the last entry is the keyName, the rest is returned as path
|
||||||
|
|
||||||
|
friend class WinConfigurationTest;
|
||||||
private:
|
private:
|
||||||
std::string _rootPath;
|
std::string _rootPath;
|
||||||
REGSAM _extraSam;
|
REGSAM _extraSam;
|
||||||
|
@ -65,7 +65,7 @@ WinRegistryConfiguration::~WinRegistryConfiguration()
|
|||||||
bool WinRegistryConfiguration::getRaw(const std::string& key, std::string& value) const
|
bool WinRegistryConfiguration::getRaw(const std::string& key, std::string& value) const
|
||||||
{
|
{
|
||||||
std::string keyName;
|
std::string keyName;
|
||||||
std::string fullPath = _rootPath + ConvertToRegFormat(key, keyName);
|
std::string fullPath = _rootPath + convertToRegFormat(key, keyName);
|
||||||
WinRegistryKey aKey(fullPath, true, _extraSam);
|
WinRegistryKey aKey(fullPath, true, _extraSam);
|
||||||
bool exists = aKey.exists(keyName);
|
bool exists = aKey.exists(keyName);
|
||||||
if (exists)
|
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)
|
void WinRegistryConfiguration::setRaw(const std::string& key, const std::string& value)
|
||||||
{
|
{
|
||||||
std::string keyName;
|
std::string keyName;
|
||||||
std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName);
|
std::string fullPath = _rootPath + convertToRegFormat(key, keyName);
|
||||||
WinRegistryKey aKey(fullPath, false, _extraSam);
|
WinRegistryKey aKey(fullPath, false, _extraSam);
|
||||||
aKey.setString(keyName, value);
|
aKey.setString(keyName, value);
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ void WinRegistryConfiguration::enumerate(const std::string& key, Keys& range) co
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string keyName;
|
std::string keyName;
|
||||||
std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName);
|
std::string fullPath = _rootPath + convertToRegFormat(key, keyName);
|
||||||
WinRegistryKey aKey(fullPath, true, _extraSam);
|
WinRegistryKey aKey(fullPath, true, _extraSam);
|
||||||
aKey.values(range);
|
aKey.values(range);
|
||||||
aKey.subKeys(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('.');
|
std::size_t pos = key.rfind('.');
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
|
@ -74,6 +74,10 @@ void WinConfigurationTest::testConfiguration()
|
|||||||
|
|
||||||
pView->setString("sub.foo", "bar");
|
pView->setString("sub.foo", "bar");
|
||||||
assert (pView->getString("sub.foo", "default") == "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