ClickHouse/dbms/src/Common/Macros.h

33 lines
662 B
C++
Raw Normal View History

2014-08-11 15:59:01 +00:00
#pragma once
#include <Core/Types.h>
2014-08-11 15:59:01 +00:00
#include <Poco/Util/AbstractConfiguration.h>
#include <map>
2014-08-11 15:59:01 +00:00
namespace DB
{
/** Apply substitutions from the macros in config to the string.
2014-08-11 15:59:01 +00:00
*/
class Macros
{
public:
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.
*/
String expand(const String & s, size_t level = 0) const;
2014-08-11 15:59:01 +00:00
private:
using MacroMap = std::map<String, String>;
2014-08-11 15:59:01 +00:00
MacroMap macros;
2014-08-11 15:59:01 +00:00
};
using MacrosPtr = std::shared_ptr<Macros>;
2014-08-11 15:59:01 +00:00
}