mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Migrate setting the flux sink to Config.
This commit is contained in:
@@ -33,60 +33,3 @@ std::unique_ptr<FluxSink> FluxSink::create(const FluxSinkProto& config)
|
||||
return std::unique_ptr<FluxSink>();
|
||||
}
|
||||
}
|
||||
|
||||
void FluxSink::updateConfigForFilename(
|
||||
FluxSinkProto* proto, const std::string& filename)
|
||||
{
|
||||
static const std::vector<std::pair<std::regex,
|
||||
std::function<void(const std::string&, FluxSinkProto*)>>>
|
||||
formats = {
|
||||
{std::regex("^(.*\\.a2r)$"),
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSinkProto::A2R);
|
||||
proto->mutable_a2r()->set_filename(s);
|
||||
}},
|
||||
{std::regex("^(.*\\.flux)$"),
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSinkProto::FLUX);
|
||||
proto->mutable_fl2()->set_filename(s);
|
||||
}},
|
||||
{std::regex("^(.*\\.scp)$"),
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSinkProto::SCP);
|
||||
proto->mutable_scp()->set_filename(s);
|
||||
}},
|
||||
{std::regex("^vcd:(.*)$"),
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSinkProto::VCD);
|
||||
proto->mutable_vcd()->set_directory(s);
|
||||
}},
|
||||
{std::regex("^au:(.*)$"),
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSinkProto::AU);
|
||||
proto->mutable_au()->set_directory(s);
|
||||
}},
|
||||
{std::regex("^drive:(.*)"),
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSinkProto::DRIVE);
|
||||
globalConfig()->mutable_drive()->set_drive(std::stoi(s));
|
||||
}},
|
||||
};
|
||||
|
||||
for (const auto& it : formats)
|
||||
{
|
||||
std::smatch match;
|
||||
if (std::regex_match(filename, match, it.first))
|
||||
{
|
||||
it.second(match[1], proto);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
error("unrecognised flux filename '{}'", filename);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user