From a541156cec3191657c9359f1c7b854a97fc137af Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 22 Jun 2015 14:48:17 -0400 Subject: [PATCH] =?UTF-8?q?CLI2:=20Added=20support=20for=20write=20command?= =?UTF-8?q?s=20specif=D1=97gin=20ID/UUID=20*after*=20CMD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CLI2.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 6297b0fe4..4c64fd1e1 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -1165,6 +1165,47 @@ void CLI2::findIDs () } } + // If no IDs were found, look for number/set listed as a MODIFICATION for a + // WRITECMD. + if (! _id_ranges.size ()) + { + for (auto& a : _args) + { + if (a.hasTag ("MODIFICATION")) + { + if (a._lextype == Lexer::Type::number) + { + a.unTag ("MODIFICATION"); + a.tag ("FILTER"); + std::string number = a.attribute ("raw"); + _id_ranges.push_back (std::pair (number, number)); + } + else if (a._lextype == Lexer::Type::set) + { + a.unTag ("MODIFICATION"); + a.tag ("FILTER"); + + // Split the ID list into elements. + std::vector elements; + split (elements, a.attribute ("raw"), ','); + + for (auto& element : elements) + { + auto hyphen = element.find ("-"); + if (hyphen != std::string::npos) + { + _id_ranges.push_back (std::pair (element.substr (0, hyphen), element.substr (hyphen + 1))); + } + else + { + _id_ranges.push_back (std::pair (element, element)); + } + } + } + } + } + } + if (_id_ranges.size ()) if (context.config.getInteger ("debug.parser") >= 3) context.debug (dump ("CLI2::prepareFilter findIDs")); @@ -1178,11 +1219,24 @@ void CLI2::findUUIDs () if (a.hasTag ("FILTER") && a._lextype == Lexer::Type::uuid) { - a.tag ("UUID"); _uuid_list.push_back (a.attribute ("raw")); } } + if (! _uuid_list.size ()) + { + for (auto& a : _args) + { + if (a.hasTag ("MODIFICATION") && + a._lextype == Lexer::Type::uuid) + { + a.unTag ("MODIFICATION"); + a.tag ("FILTER"); + _uuid_list.push_back (a.attribute ("raw")); + } + } + } + if (_uuid_list.size ()) if (context.config.getInteger ("debug.parser") >= 3) context.debug (dump ("CLI2::prepareFilter findUUIDs"));