mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
4a6bfc086c
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
73 lines
1.5 KiB
C++
73 lines
1.5 KiB
C++
//
|
|
// ConfigurationView.cpp
|
|
//
|
|
// Library: Util
|
|
// Package: Configuration
|
|
// Module: ConfigurationView
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/Util/ConfigurationView.h"
|
|
|
|
|
|
namespace Poco {
|
|
namespace Util {
|
|
|
|
|
|
ConfigurationView::ConfigurationView(const std::string& prefix, AbstractConfiguration::Ptr pConfig):
|
|
_prefix(prefix),
|
|
_pConfig(pConfig)
|
|
{
|
|
poco_check_ptr (pConfig);
|
|
}
|
|
|
|
|
|
ConfigurationView::~ConfigurationView()
|
|
{
|
|
}
|
|
|
|
|
|
bool ConfigurationView::getRaw(const std::string& key, std::string& value) const
|
|
{
|
|
std::string translatedKey = translateKey(key);
|
|
return _pConfig->getRaw(translatedKey, value) || _pConfig->getRaw(key, value);
|
|
}
|
|
|
|
|
|
void ConfigurationView::setRaw(const std::string& key, const std::string& value)
|
|
{
|
|
std::string translatedKey = translateKey(key);
|
|
_pConfig->setRaw(translatedKey, value);
|
|
}
|
|
|
|
|
|
void ConfigurationView::enumerate(const std::string& key, Keys& range) const
|
|
{
|
|
std::string translatedKey = translateKey(key);
|
|
_pConfig->enumerate(translatedKey, range);
|
|
}
|
|
|
|
|
|
void ConfigurationView::removeRaw(const std::string& key)
|
|
{
|
|
std::string translatedKey = translateKey(key);
|
|
_pConfig->remove(translatedKey);
|
|
}
|
|
|
|
|
|
std::string ConfigurationView::translateKey(const std::string& key) const
|
|
{
|
|
std::string result = _prefix;
|
|
if (!result.empty() && !key.empty() && key[0] != '[') result += '.';
|
|
result += key;
|
|
return result;
|
|
}
|
|
|
|
|
|
} } // namespace Poco::Util
|