From fe2ea795ee111fe0894182ef3555e32f2e6dd6bb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 29 Oct 2014 23:08:31 -0400 Subject: [PATCH] CLI - Implemented ::isUUIDList. --- src/CLI.cpp | 35 ++++++++++++++++++++++++++++++----- src/CLI.h | 1 + 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index 485cc4603..59a263f39 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -481,11 +481,12 @@ const std::string CLI::dump () const void CLI::addArg (const std::string& arg) { // Do not lex RC overrides, UUIDs, patterns, substitutions. - if (isRCOverride (arg) || + if (isRCOverride (arg) || isConfigOverride (arg) || - isUUID (arg) || - isPattern (arg) || - isSubstitution (arg)) + isUUIDList (arg) || + isUUID (arg) || + isPattern (arg) || + isSubstitution (arg)) { _original_args.push_back (arg); } @@ -1701,10 +1702,34 @@ bool CLI::isConfigOverride (const std::string& raw) const } //////////////////////////////////////////////////////////////////////////////// -bool CLI::isUUID (const std::string& raw) const +bool CLI::isUUIDList (const std::string& raw) const { // UUIDs have a limited character set. if (raw.find_first_not_of ("0123456789abcdefABCDEF-,") == std::string::npos) + { + Nibbler n (raw); + std::string token; + if (n.getUUID (token) || + n.getPartialUUID (token)) + { + while (n.skip (',')) + if (! n.getUUID (token) && + ! n.getPartialUUID (token)) + return false; + + if (n.depleted ()) + return true; + } + } + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +bool CLI::isUUID (const std::string& raw) const +{ + // UUIDs have a limited character set. + if (raw.find_first_not_of ("0123456789abcdefABCDEF-") == std::string::npos) { Nibbler n (raw); std::string token; diff --git a/src/CLI.h b/src/CLI.h index 4ec1c1dc3..6bedceea5 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -100,6 +100,7 @@ private: bool isRCOverride (const std::string&) const; bool isConfigOverride (const std::string&) const; + bool isUUIDList (const std::string&) const; bool isUUID (const std::string&) const; bool isPattern (const std::string&) const; bool isSubstitution (const std::string&) const;