ClickHouse/base/poco/Util/src/ConfigurationView.cpp
Robert Schulze b79ead9c84
Move poco to base/poco/ (#46075)
* Replicate poco into base/poco/

* De-register poco submodule

* Build poco from ClickHouse

* Exclude poco from stylecheck

* Exclude poco from whitespace check

* Exclude poco from typo check

* Remove x bit from sources/headers (the style check complained)

* Exclude poco from duplicate include check

* Fix fasttest

* Remove contrib/poco-cmake/*

* Simplify poco build descriptions

* Remove poco stuff not used by ClickHouse

* Glob poco sources

* Exclude poco from clang-tidy
2023-02-08 12:04:11 +01:00

76 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* pConfig):
_prefix(prefix),
_pConfig(pConfig)
{
poco_check_ptr (pConfig);
_pConfig->duplicate();
}
ConfigurationView::~ConfigurationView()
{
_pConfig->release();
}
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