From ce4584b3d82f48a7a5b9669046a23bef49397876 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Thu, 4 Mar 2021 23:16:22 +0100 Subject: [PATCH] Provide a better syntax for --channel-config The current syntax is ambiguous because it treats assignments (like address=127.0.0.1) and selectors (name=my-channel) using the symbol equal `"`. This allows: my-channel:address=127.0.0.1 as alternative syntax, which clearly separates the role of my-channel from the associated properties. --- fairmq/SuboptParser.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fairmq/SuboptParser.cxx b/fairmq/SuboptParser.cxx index 3745a327..959b8541 100644 --- a/fairmq/SuboptParser.cxx +++ b/fairmq/SuboptParser.cxx @@ -17,8 +17,9 @@ #include #include - -#include // make_pair +#include +#include // make_pair +#include using boost::property_tree::ptree; using namespace std; @@ -83,6 +84,14 @@ Properties SuboptParser(const vector& channelConfig, const string& devic string argString(token); char* subopts = &argString[0]; char* value = nullptr; + // Find either a : or a =. If we find the former first, we consider what is before it + // the channel name + char* firstSep = strpbrk(subopts, ":="); + if (firstSep && *firstSep == ':') { + channelName = std::string_view(subopts, firstSep - subopts); + channelProperties.put("name", channelName); + subopts = firstSep + 1; + } while (subopts && *subopts != 0 && *subopts != ' ') { char* cur = subopts; int subopt = getsubopt(&subopts, (char**)channelOptionKeys, &value);