fixed map issue

This commit is contained in:
yariks5s 2023-09-28 17:16:37 +00:00
parent e4e23d73ea
commit 61e7054f1f
3 changed files with 5 additions and 13 deletions

View File

@ -1,3 +1,4 @@
#include <algorithm>
#include <unordered_map>
#include <Poco/Util/AbstractConfiguration.h>
#include <Common/Macros.h>
@ -37,16 +38,9 @@ Macros::Macros(const Poco::Util::AbstractConfiguration & config, const String &
}
}
Macros::Macros(std::map<const String, const String> map)
Macros::Macros(std::map<String, String> map)
{
for (const auto& pair : map) {
const String& key = pair.first;
const String& value = pair.second;
macros[key] = value;
if (key == "database" || key == "table" || key == "uuid")
enable_special_macros = false;
}
macros = std::move(map);
}
String Macros::expand(const String & s,

View File

@ -27,7 +27,7 @@ class Macros
public:
Macros() = default;
Macros(const Poco::Util::AbstractConfiguration & config, const String & key, Poco::Logger * log = nullptr);
explicit Macros(std::map<const String, const String> map);
explicit Macros(std::map<String, String> map);
struct MacroExpansionInfo
{

View File

@ -25,9 +25,7 @@ struct URIConverter
{
static void modifyURI(Poco::URI & uri, std::unordered_map<std::string, std::string> mapper)
{
std::map<const String, const String> macros_map;
macros_map.try_emplace("bucket", uri.getHost());
Macros macros(macros_map);
Macros macros({{"bucket", uri.getHost()}});
uri = macros.expand(mapper[uri.getScheme()]).empty()? uri : Poco::URI(macros.expand(mapper[uri.getScheme()]) + "/" + uri.getPathAndQuery());
}
};