summaryrefslogtreecommitdiff
path: root/cpp/src/IcePack/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IcePack/Parser.cpp')
-rw-r--r--cpp/src/IcePack/Parser.cpp85
1 files changed, 66 insertions, 19 deletions
diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp
index 55f1c56f612..39ea972cd86 100644
--- a/cpp/src/IcePack/Parser.cpp
+++ b/cpp/src/IcePack/Parser.cpp
@@ -45,37 +45,85 @@ IcePack::Parser::createParser(const CommunicatorPtr& communicator, const AdminPr
}
void
-IcePack::Parser::add(const list<string>& references)
+IcePack::Parser::add(const list<string>& args)
{
- for (list<string>::const_iterator p = references.begin(); p != references.end(); ++p)
+ if (args.empty())
{
- try
- {
- ServerDescriptionPtr desc = new ServerDescription;
- desc->object = _communicator->stringToProxy(*p);
- _admin->add(desc);
- }
- catch(const LocalException& ex)
+ error("`add' requires at least an object reference as argument");
+ return;
+ }
+
+ try
+ {
+ ServerDescriptionPtr desc = new ServerDescription;
+ list<string>::const_iterator p = args.begin();
+ desc->object = _communicator->stringToProxy(*p);
+ desc->regex = false;
+ if (++p != args.end())
{
- error(ex.toString());
+ desc->path = *p;
+ while (++p != args.end())
+ {
+ desc->args.push_back(*p);
+ }
}
+ _admin->add(desc);
+
+ }
+ catch(const LocalException& ex)
+ {
+ error(ex.toString());
}
}
void
-IcePack::Parser::remove(const list<string>& references)
+IcePack::Parser::remove(const list<string>& args)
{
- for (list<string>::const_iterator p = references.begin(); p != references.end(); ++p)
+ if (args.size() != 1)
{
- try
- {
- _admin->remove(_communicator->stringToProxy(*p));
- }
- catch(const LocalException& ex)
+ error("`remove' takes exactly one object reference as argument");
+ return;
+ }
+
+ try
+ {
+ _admin->remove(_communicator->stringToProxy(args.front()));
+ }
+ catch(const LocalException& ex)
+ {
+ error(ex.toString());
+ }
+}
+
+void
+IcePack::Parser::getAll()
+{
+ try
+ {
+ ServerDescriptions descriptions = _admin->getAll();
+ ServerDescriptions::iterator p = descriptions.begin();
+ while(p != descriptions.end())
{
- error(ex.toString());
+ cout << "object = " << _communicator->proxyToString((*p)->object) << endl;
+ cout << "regex = " << boolalpha << (*p)->regex << endl;
+ cout << "host = " << (*p)->host << endl;
+ cout << "path = " << (*p)->path << endl;
+ cout << "args =";
+ for (Args::iterator q = (*p)->args.begin(); q != (*p)->args.end(); ++q)
+ {
+ cout << ' ' << *q;
+ }
+ cout << endl;
+ if (++p != descriptions.end())
+ {
+ cout << endl;
+ }
}
}
+ catch(const LocalException& ex)
+ {
+ error(ex.toString());
+ }
}
void
@@ -89,7 +137,6 @@ IcePack::Parser::shutdown()
{
error(ex.toString());
}
-
}
void