| 1 | #include <Common/getMultipleKeysFromConfig.h> |
|---|---|
| 2 | |
| 3 | #include <Poco/Util/AbstractConfiguration.h> |
| 4 | #include <Common/StringUtils/StringUtils.h> |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | std::vector<std::string> getMultipleKeysFromConfig(const Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name) |
| 9 | { |
| 10 | std::vector<std::string> values; |
| 11 | Poco::Util::AbstractConfiguration::Keys config_keys; |
| 12 | config.keys(root, config_keys); |
| 13 | for (const auto & key : config_keys) |
| 14 | { |
| 15 | if (key != name && !(startsWith(key.data(), name + "[") && endsWith(key.data(), "]"))) |
| 16 | continue; |
| 17 | values.emplace_back(key); |
| 18 | } |
| 19 | return values; |
| 20 | } |
| 21 | |
| 22 | |
| 23 | std::vector<std::string> getMultipleValuesFromConfig(const Poco::Util::AbstractConfiguration & config, const std::string & root, const std::string & name) |
| 24 | { |
| 25 | std::vector<std::string> values; |
| 26 | for (const auto & key : DB::getMultipleKeysFromConfig(config, root, name)) |
| 27 | values.emplace_back(config.getString(root.empty() ? key : root + "."+ key)); |
| 28 | return values; |
| 29 | } |
| 30 | |
| 31 | } |
| 32 |