summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2007-03-08 17:25:39 +0000
committerMark Spruiell <mes@zeroc.com>2007-03-08 17:25:39 +0000
commitdd59fd95f15cb43113cf6955da3ec8c9ceab1152 (patch)
tree6545fef0423de3461f4eadcb46aaed341d4b3ea2 /cpp/src
parentFixed install target (diff)
downloadice-dd59fd95f15cb43113cf6955da3ec8c9ceab1152.tar.bz2
ice-dd59fd95f15cb43113cf6955da3ec8c9ceab1152.tar.xz
ice-dd59fd95f15cb43113cf6955da3ec8c9ceab1152.zip
bug 1992
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceStorm/Grammar.y23
-rw-r--r--cpp/src/IceStorm/Parser.cpp137
-rw-r--r--cpp/src/IceStorm/Parser.h5
-rw-r--r--cpp/src/IceStorm/Scanner.l16
4 files changed, 89 insertions, 92 deletions
diff --git a/cpp/src/IceStorm/Grammar.y b/cpp/src/IceStorm/Grammar.y
index ef2eca13478..75cd235ffcf 100644
--- a/cpp/src/IceStorm/Grammar.y
+++ b/cpp/src/IceStorm/Grammar.y
@@ -39,13 +39,11 @@ yyerror(const char* s)
%token ICE_STORM_CURRENT
%token ICE_STORM_CREATE
%token ICE_STORM_DESTROY
-%token ICE_STORM_LIST
%token ICE_STORM_LINK
%token ICE_STORM_UNLINK
+%token ICE_STORM_LINKS
+%token ICE_STORM_TOPICS
%token ICE_STORM_STRING
-%token ICE_STORM_SHOW
-%token ICE_STORM_COPYING
-%token ICE_STORM_WARRANTY
%%
@@ -107,22 +105,23 @@ command
{
parser->unlink($2);
}
-| ICE_STORM_LIST ';'
+| ICE_STORM_LINKS ';'
{
std::list<std::string> args;
- parser->dolist(args);
+ parser->links(args);
}
-| ICE_STORM_LIST strings ';'
+| ICE_STORM_LINKS strings ';'
{
- parser->dolist($2);
+ parser->links($2);
}
-| ICE_STORM_SHOW ICE_STORM_COPYING ';'
+| ICE_STORM_TOPICS ';'
{
- parser->showCopying();
+ std::list<std::string> args;
+ parser->topics(args);
}
-| ICE_STORM_SHOW ICE_STORM_WARRANTY ';'
+| ICE_STORM_TOPICS strings ';'
{
- parser->showWarranty();
+ parser->topics($2);
}
| error ';'
{
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
diff --git a/cpp/src/IceStorm/Parser.h b/cpp/src/IceStorm/Parser.h
index df8d77c0ea4..18d79de51ab 100644
--- a/cpp/src/IceStorm/Parser.h
+++ b/cpp/src/IceStorm/Parser.h
@@ -70,14 +70,13 @@ public:
void create(const std::list<std::string>&);
void destroy(const std::list<std::string>&);
- void dolist(const std::list<std::string>&); // Don't name list - conflicts with std::list
void link(const std::list<std::string>&);
void unlink(const std::list<std::string>&);
+ void links(const std::list<std::string>&);
+ void topics(const std::list<std::string>&);
void current(const std::list<std::string>&);
void showBanner();
- void showCopying();
- void showWarranty();
void getInput(char*, int&, int);
void nextLine();
diff --git a/cpp/src/IceStorm/Scanner.l b/cpp/src/IceStorm/Scanner.l
index f4232427972..c095652d2ef 100644
--- a/cpp/src/IceStorm/Scanner.l
+++ b/cpp/src/IceStorm/Scanner.l
@@ -116,10 +116,6 @@ NL [\n]
return ICE_STORM_DESTROY;
}
-"list" {
- return ICE_STORM_LIST;
-}
-
"link" {
return ICE_STORM_LINK;
}
@@ -128,16 +124,12 @@ NL [\n]
return ICE_STORM_UNLINK;
}
-"show" {
- return ICE_STORM_SHOW;
-}
-
-"copying" {
- return ICE_STORM_COPYING;
+"links" {
+ return ICE_STORM_LINKS;
}
-"warranty" {
- return ICE_STORM_WARRANTY;
+"topics" {
+ return ICE_STORM_TOPICS;
}
{WS}*(\\{WS}*{NL})? {