2014-08-11 15:59:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/Types.h>
|
2014-08-11 15:59:01 +00:00
|
|
|
#include <map>
|
2018-03-13 23:44:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
}
|
2014-08-11 15:59:01 +00:00
|
|
|
|
2017-05-10 04:00:19 +00:00
|
|
|
|
2014-08-11 15:59:01 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-05-10 04:00:19 +00:00
|
|
|
/** Apply substitutions from the macros in config to the string.
|
2014-08-11 15:59:01 +00:00
|
|
|
*/
|
|
|
|
class Macros
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
Macros();
|
|
|
|
Macros(const Poco::Util::AbstractConfiguration & config, const String & key);
|
2014-08-11 15:59:01 +00:00
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
/** Replace the substring of the form {macro_name} with the value for macro_name, obtained from the config file.
|
|
|
|
* level - the level of recursion.
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
|
|
|
String expand(const String & s, size_t level = 0) const;
|
2014-08-11 15:59:01 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
using MacroMap = std::map<String, String>;
|
2018-03-12 18:38:00 +00:00
|
|
|
const MacroMap getMacroMap() const { return macros; }
|
2014-08-11 15:59:01 +00:00
|
|
|
|
2018-03-12 18:38:00 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
MacroMap macros;
|
2014-08-11 15:59:01 +00:00
|
|
|
};
|
|
|
|
|
2018-03-12 18:16:51 +00:00
|
|
|
|
2014-08-11 15:59:01 +00:00
|
|
|
}
|