From 698c801dbc24eba096c4fb8777b7dd00292dd75f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 15 Oct 2014 01:43:27 -0400 Subject: [PATCH] CLI - Converted _command from std::string to A. --- src/CLI.cpp | 17 +++++++++++------ src/CLI.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index 9e46f5cdc..8f3dd0548 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -205,7 +205,6 @@ const std::string A::dump () const //////////////////////////////////////////////////////////////////////////////// CLI::CLI () : _rc ("") -, _command ("") , _readOnly (false) { } @@ -237,7 +236,7 @@ void CLI::initialize (int argc, const char** argv) _args.clear (); _rc = ""; _overrides.clear (); - _command = ""; + _command.clear (); _readOnly = false; _filter.clear (); _modifications.clear (); @@ -272,7 +271,7 @@ void CLI::add (const std::string& arg) _args.clear (); _rc = ""; _overrides.clear (); - _command = ""; + _command.clear (); _readOnly = false; _filter.clear (); _modifications.clear (); @@ -411,10 +410,15 @@ void CLI::categorize () for (i = _args.begin (); i != _args.end (); ++i) { std::string raw = i->attribute ("raw"); - if (canonicalize (_command, "cmd", raw)) + std::string command; + if (canonicalize (command, "cmd", raw)) { + _command._name = "argCmd"; + _command.attribute ("raw", raw); + _command.attribute ("canonical", command); + _readOnly = ! exactMatch ("writecmd", command); + _command.tag (_readOnly ? "READCMD" : "WRITECMD"); foundCommand = true; - _readOnly = ! exactMatch ("writecmd", _command); } else if (foundCommand && ! _readOnly) { @@ -564,7 +568,8 @@ void CLI::dump (const std::string& label) const std::cout << " " << a->dump () << "\n"; } - std::cout << " _command " << _command << " " << (_readOnly ? "(read)" : "(write)") << "\n"; + std::cout << " _command\n" + << " " << _command.dump () << "\n"; if (_modifications.size ()) { diff --git a/src/CLI.h b/src/CLI.h index 9aeb1d541..b1dc2da78 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -87,7 +87,7 @@ public: std::vector _args; std::string _rc; std::map _overrides; - std::string _command; + A _command; bool _readOnly; std::vector _filter; std::vector _modifications;