ClickHouse/dbms/src/Common/getMultipleKeysFromConfig.cpp
proller d97b2edc7c Make separate libs Common/ZooKeeper and Common/ConfigProcessor (#1749)
* Make separate libs Common/ZooKeeper and Common/ConfigProcessor
renamed:    dbms/src/Common/StringUtils.h -> dbms/src/Common/StringUtils/StringUtils.h

* Fix space

* Fix data in system.build_options

* merge

* merge
2018-01-15 22:07:47 +03:00

32 lines
1013 B
C++

#include <Common/getMultipleKeysFromConfig.h>
#include <Poco/Util/AbstractConfiguration.h>
#include <Common/StringUtils/StringUtils.h>
namespace DB
{
std::vector<std::string> getMultipleKeysFromConfig(const Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name)
{
std::vector<std::string> values;
Poco::Util::AbstractConfiguration::Keys config_keys;
config.keys(root, config_keys);
for (const auto & key : config_keys)
{
if (key != name && !(startsWith(key.data(), name + "[") && endsWith(key.data(), "]")))
continue;
values.emplace_back(key);
}
return values;
}
std::vector<std::string> getMultipleValuesFromConfig(const Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name)
{
std::vector<std::string> values;
for (const auto & key : DB::getMultipleKeysFromConfig(config, root, name))
values.emplace_back(config.getString(key));
return values;
}
}