diff options
author | Mark Spruiell <mes@zeroc.com> | 2007-03-08 17:25:39 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2007-03-08 17:25:39 +0000 |
commit | dd59fd95f15cb43113cf6955da3ec8c9ceab1152 (patch) | |
tree | 6545fef0423de3461f4eadcb46aaed341d4b3ea2 /cpp/src/IceStorm/Parser.cpp | |
parent | Fixed install target (diff) | |
download | ice-dd59fd95f15cb43113cf6955da3ec8c9ceab1152.tar.bz2 ice-dd59fd95f15cb43113cf6955da3ec8c9ceab1152.tar.xz ice-dd59fd95f15cb43113cf6955da3ec8c9ceab1152.zip |
bug 1992
Diffstat (limited to 'cpp/src/IceStorm/Parser.cpp')
-rw-r--r-- | cpp/src/IceStorm/Parser.cpp | 137 |
1 files changed, 72 insertions, 65 deletions
diff --git a/cpp/src/IceStorm/Parser.cpp b/cpp/src/IceStorm/Parser.cpp index dc8261820a7..cf4858dd00e 100644 --- a/cpp/src/IceStorm/Parser.cpp +++ b/cpp/src/IceStorm/Parser.cpp @@ -80,15 +80,18 @@ void Parser::usage() { cout << - "help Print this message.\n" - "exit, quit Exit this program.\n" - "create TOPICS Add TOPICS.\n" - "destroy TOPICS Remove TOPICS.\n" - "link FROM TO [COST] Link FROM to TO with the optional given COST.\n" - "unlink FROM TO Unlink TO from FROM.\n" - "list [INSTANCE-NAME [TOPICS]] Display link information for TOPICS, or list\n" - " all topics for the given topic manager.\n" - "current [INSTANCE-NAME] Set the current topic manager.\n" + "help Print this message.\n" + "exit, quit Exit this program.\n" + "create TOPICS Add TOPICS.\n" + "destroy TOPICS Remove TOPICS.\n" + "link FROM TO [COST] Link FROM to TO with the optional given COST.\n" + "unlink FROM TO Unlink TO from FROM.\n" + "links [INSTANCE-NAME] Display all links for the topics in the current topic\n" + " manager, or in the given INSTANCE-NAME.\n" + "topics [INSTANCE-NAME] Display the names of all topics in the current topic\n" + " manager, or in the given INSTANCE-NAME.\n" + "current [INSTANCE-NAME] Display the current topic manager, or change it to\n" + " INSTANCE-NAME.\n" ; } @@ -255,77 +258,67 @@ Parser::unlink(const list<string>& _args) } void -Parser::current(const list<string>& _args) +Parser::links(const list<string>& args) { - list<string> args = _args; - - if(args.size() == 0) + if(args.size() > 1) { - cout << _communicator->identityToString(_defaultManager->ice_getIdentity()) << endl; + error("`links' requires at most one argument (type `help' for more info)"); return; } try { - IceStorm::TopicManagerPrx manager = findManagerByCategory(args.front()); - manager->ice_ping(); - _defaultManager = manager; + IceStorm::TopicManagerPrx manager; + if(args.size() == 0) + { + manager = _defaultManager; + } + else + { + manager = findManagerByCategory(args.front()); + } + TopicDict d = manager->retrieveAll(); + for(TopicDict::iterator i = d.begin(); i != d.end(); ++i) + { + LinkInfoSeq links = i->second->getLinkInfoSeq(); + for(LinkInfoSeq::const_iterator p = links.begin(); p != links.end(); ++p) + { + cout << i->first << " to " << (*p).name << " with cost " << (*p).cost << endl; + } + } } catch(const Exception& ex) { ostringstream s; - s << args.front() << ": " << ex; + s << ex; error(s.str()); - return; } } void -Parser::dolist(const list<string>& _args) +Parser::topics(const list<string>& args) { - list<string> args = _args; + if(args.size() > 1) + { + error("`topics' requires at most one argument (type `help' for more info)"); + return; + } try { - if(args.size() <= 1) + IceStorm::TopicManagerPrx manager; + if(args.size() == 0) { - IceStorm::TopicManagerPrx manager; - if(args.size() == 1) - { - manager = findManagerByCategory(args.front()); - } - else - { - manager = _defaultManager; - } - TopicDict d = manager->retrieveAll(); - for(TopicDict::iterator i = d.begin(); i != d.end(); ++i) - { - cout << i->first << endl; - } + manager = _defaultManager; } else { - IceStorm::TopicManagerPrx manager = findManagerByCategory(args.front()); - args.pop_front(); - while(!args.empty()) - { - try - { - string arg = args.front(); - args.pop_front(); - TopicPrx topic = manager->retrieve(arg); - LinkInfoSeq links = topic->getLinkInfoSeq(); - for(LinkInfoSeq::const_iterator p = links.begin(); p != links.end(); ++p) - { - cout << arg << " to " << (*p).name << " with cost " << (*p).cost << endl; - } - } - catch(const NoSuchTopic& ex) - { - cout << "Topic `" << ex.name << "' not found" << endl; - } - } + manager = findManagerByCategory(args.front()); + } + TopicDict d = manager->retrieveAll(); + for(TopicDict::iterator i = d.begin(); i != d.end(); ++i) + { + cout << i->first << endl; } } catch(const Exception& ex) @@ -337,21 +330,35 @@ Parser::dolist(const list<string>& _args) } void -Parser::showBanner() +Parser::current(const list<string>& _args) { - cout << "Ice " << ICE_STRING_VERSION << " Copyright 2003-2007 ZeroC, Inc." << endl; -} + list<string> args = _args; -void -Parser::showCopying() -{ - cout << "This command is not implemented." << endl; + if(args.size() == 0) + { + cout << _communicator->identityToString(_defaultManager->ice_getIdentity()) << endl; + return; + } + + try + { + IceStorm::TopicManagerPrx manager = findManagerByCategory(args.front()); + manager->ice_ping(); + _defaultManager = manager; + } + catch(const Exception& ex) + { + ostringstream s; + s << args.front() << ": " << ex; + error(s.str()); + return; + } } void -Parser::showWarranty() +Parser::showBanner() { - cout << "This command is not implemented." << endl; + cout << "Ice " << ICE_STRING_VERSION << " Copyright 2003-2007 ZeroC, Inc." << endl; } void |