本文整理汇总了C++中iceutilinternal::Options::optArg方法的典型用法代码示例。如果您正苦于以下问题:C++ Options::optArg方法的具体用法?C++ Options::optArg怎么用?C++ Options::optArg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iceutilinternal::Options
的用法示例。
在下文中一共展示了Options::optArg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
int
run(int argc, char* argv[], const CommunicatorPtr& communicator)
{
IceUtilInternal::Options opts;
opts.addOpt("", "count", IceUtilInternal::Options::NeedArg);
try
{
opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
return EXIT_FAILURE;
}
PropertiesPtr properties = communicator->getProperties();
const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default";
string managerProxy = properties->getProperty(managerProxyProperty);
if(managerProxy.empty())
{
cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
ObjectPrx base = communicator->stringToProxy(managerProxy);
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base);
if(!manager)
{
cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl;
return EXIT_FAILURE;
}
TopicPrx fed1;
try
{
fed1 = manager->retrieve("fed1");
}
catch(const NoSuchTopic& e)
{
cerr << argv[0] << ": NoSuchTopic: " << e.name << endl;
return EXIT_FAILURE;
}
EventPrx eventFed1 = EventPrx::uncheckedCast(fed1->getPublisher()->ice_oneway());
string arg = opts.optArg("count");
int count = 1;
if(arg.empty())
{
count = atoi(arg.c_str());
}
while(true)
{
for(int i = 0; i < 10; ++i)
{
eventFed1->pub("fed1");
}
//
// Before we exit, we ping all proxies as twoway, to make sure
// that all oneways are delivered.
//
EventPrx::uncheckedCast(eventFed1->ice_twoway())->ice_ping();
if(count == 0)
{
break;
}
--count;
IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1));
}
return EXIT_SUCCESS;
}
示例2: gen
int
compile(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("E");
opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "tie");
opts.addOpt("", "impl");
opts.addOpt("", "impl-tie");
opts.addOpt("", "depend");
opts.addOpt("", "depend-xml");
opts.addOpt("", "list-generated");
opts.addOpt("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
opts.addOpt("", "checksum", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "stream");
opts.addOpt("", "meta", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
vector<string>args;
try
{
args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
getErrorStream() << argv[0] << ": error: " << e.reason << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(argv[0]);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
getErrorStream() << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
vector<string> cppArgs;
vector<string> optargs = opts.argVec("D");
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-D" + *i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
}
bool preprocess = opts.isSet("E");
string output = opts.optArg("output-dir");
bool tie = opts.isSet("tie");
bool impl = opts.isSet("impl");
bool implTie = opts.isSet("impl-tie");
bool depend = opts.isSet("depend");
bool dependxml = opts.isSet("depend-xml");
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
bool underscore = opts.isSet("underscore");
string checksumClass = opts.optArg("checksum");
bool stream = opts.isSet("stream");
bool listGenerated = opts.isSet("list-generated");
StringList globalMetadata;
vector<string> v = opts.argVec("meta");
copy(v.begin(), v.end(), back_inserter(globalMetadata));
if(args.empty())
{
getErrorStream() << argv[0] << ": error: no input file" << endl;
//.........这里部分代码省略.........
示例3: if
static int
run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator)
{
vector<string> oldCppArgs;
vector<string> newCppArgs;
bool debug;
bool ice = true; // Needs to be true in order to create default definitions.
bool underscore;
string outputFile;
bool ignoreTypeChanges;
bool purgeObjects;
bool catastrophicRecover;
bool suppress;
string inputFile;
vector<string> oldSlice;
vector<string> newSlice;
bool evictor;
string keyTypeNames;
string valueTypeNames;
string dbEnvName, dbName, dbEnvNameNew;
bool allDb = false;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("d", "debug");
opts.addOpt("", "underscore");
opts.addOpt("o", "", IceUtilInternal::Options::NeedArg);
opts.addOpt("i");
opts.addOpt("p");
opts.addOpt("c");
opts.addOpt("w");
opts.addOpt("f", "", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "include-old", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("", "include-new", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("", "old", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("", "new", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("a");
opts.addOpt("e");
opts.addOpt("", "key", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "value", IceUtilInternal::Options::NeedArg);
const string appName = originalArgs[0];
vector<string> args;
try
{
args = opts.parse(originalArgs);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << appName << ": " << e.reason << endl;
usage(appName);
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(appName);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
if(opts.isSet("D"))
{
vector<string> optargs = opts.argVec("D");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
oldCppArgs.push_back("-D" + *i);
newCppArgs.push_back("-D" + *i);
}
}
if(opts.isSet("U"))
{
vector<string> optargs = opts.argVec("U");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
oldCppArgs.push_back("-U" + *i);
newCppArgs.push_back("-U" + *i);
}
}
debug = opts.isSet("debug");
underscore = opts.isSet("underscore");
if(opts.isSet("o"))
{
outputFile = opts.optArg("o");
}
ignoreTypeChanges = opts.isSet("i");
purgeObjects = opts.isSet("p");
catastrophicRecover = opts.isSet("c");
suppress = opts.isSet("w");
if(opts.isSet("f"))
{
//.........这里部分代码省略.........
示例4: icecpp
int
main(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "header-ext", IceUtilInternal::Options::NeedArg, "h");
opts.addOpt("", "source-ext", IceUtilInternal::Options::NeedArg, "cpp");
opts.addOpt("", "add-header", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("E");
opts.addOpt("", "include-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "dll-export", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "impl");
opts.addOpt("", "depend");
opts.addOpt("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "case-sensitive");
vector<string> args;
try
{
args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(argv[0]);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICEE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
string headerExtension = opts.optArg("header-ext");
string sourceExtension = opts.optArg("source-ext");
vector<string>extraHeaders = opts.argVec("add-header");
vector<string> cppArgs;
vector<string> optargs = opts.argVec("D");
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-D" + *i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
}
bool preprocess = opts.isSet("E");
string include = opts.optArg("include-dir");
string output = opts.optArg("output-dir");
string dllExport = opts.optArg("dll-export");
bool impl = opts.isSet("impl");
bool depend = opts.isSet("depend");
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
bool caseSensitive = opts.isSet("case-sensitive");
if(args.empty())
{
cerr << argv[0] << ": no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
//.........这里部分代码省略.........
示例5: icecpp
int
main(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "header-ext", IceUtilInternal::Options::NeedArg, "h");
opts.addOpt("", "source-ext", IceUtilInternal::Options::NeedArg, "cpp");
opts.addOpt("", "add-header", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("E");
opts.addOpt("", "include-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "dll-export", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "impl");
opts.addOpt("", "depend");
opts.addOpt("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "checksum");
opts.addOpt("", "stream");
opts.addOpt("", "case-sensitive");
// alexm: our custom options
opts.addOpt("", "module", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "util");
opts.addOpt("", "log");
vector<string> args;
try
{
args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(argv[0]);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
string headerExtension = opts.optArg("header-ext");
string sourceExtension = opts.optArg("source-ext");
vector<string> extraHeaders = opts.argVec("add-header");
vector<string> cppArgs;
vector<string> optargs = opts.argVec("D");
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-D" + *i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
vector<string> includePaths;
includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
}
// bool preprocess = opts.isSet("E");
string include = opts.optArg("include-dir");
string output = opts.optArg("output-dir");
string dllExport = opts.optArg("dll-export");
bool impl = opts.isSet("impl");
bool depend = opts.isSet("depend");
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
bool checksum = opts.isSet("checksum");
bool stream = opts.isSet("stream");
bool caseSensitive = opts.isSet("case-sensitive");
//.........这里部分代码省略.........
示例6: FileException
int
compile(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("E");
opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "depend");
opts.addOpt("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
opts.addOpt("", "all");
opts.addOpt("", "no-package");
opts.addOpt("", "checksum");
opts.addOpt("", "prefix", IceUtilInternal::Options::NeedArg);
vector<string> args;
try
{
args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
getErrorStream() << argv[0] << ": error: " << e.reason << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(argv[0]);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
getErrorStream() << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
vector<string> cppArgs;
vector<string> optargs = opts.argVec("D");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-D" + *i);
}
optargs = opts.argVec("U");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
vector<string> includePaths = opts.argVec("I");
for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
}
bool preprocess = opts.isSet("E");
string output = opts.optArg("output-dir");
bool depend = opts.isSet("depend");
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
bool underscore = opts.isSet("underscore");
bool all = opts.isSet("all");
bool noPackage = opts.isSet("no-package");
bool checksum = opts.isSet("checksum");
string prefix = opts.optArg("prefix");
if(args.empty())
{
getErrorStream() << argv[0] << ": error: no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
bool keepComments = true;
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
//
//.........这里部分代码省略.........
示例7: catch
int
run(int argc, char* argv[], const CommunicatorPtr& communicator)
{
IceUtilInternal::Options opts;
opts.addOpt("", "ordered");
opts.addOpt("", "twoway");
opts.addOpt("", "events", IceUtilInternal::Options::NeedArg);
try
{
opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
return EXIT_FAILURE;
}
PropertiesPtr properties = communicator->getProperties();
const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default";
string managerProxy = properties->getProperty(managerProxyProperty);
if(managerProxy.empty())
{
cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
ObjectPrx base = communicator->stringToProxy(managerProxy);
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base);
if(!manager)
{
cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl;
return EXIT_FAILURE;
}
ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default");
TopicPrx topic;
while(true)
{
try
{
topic = manager->retrieve("single");
break;
}
// This can happen if the replica group loses the majority
// during retrieve. In this case we retry.
catch(const Ice::UnknownException&)
{
continue;
}
catch(const IceStorm::NoSuchTopic& e)
{
cerr << argv[0] << ": NoSuchTopic: " << e.name << endl;
return EXIT_FAILURE;
}
}
int events = 1000;
if(opts.isSet("events"))
{
events = atoi(opts.optArg("events").c_str());
}
//
// Create subscribers with different QoS.
//
SingleIPtr sub;
IceStorm::QoS qos;
if(opts.isSet("ordered"))
{
sub = new SingleI(communicator, "twoway ordered", events);
qos["reliability"] = "ordered";
}
else
{
sub = new SingleI(communicator, "twoway", events);
}
Ice::ObjectPrx prx = adapter->addWithUUID(sub);
while(true)
{
try
{
topic->subscribeAndGetPublisher(qos, prx);
break;
}
// If we're already subscribed then we're done (previously we
// got an UnknownException which succeeded).
catch(const IceStorm::AlreadySubscribed&)
{
break;
}
// This can happen if the replica group loses the majority
// during subscription. In this case we retry.
catch(const Ice::UnknownException&)
{
}
}
//.........这里部分代码省略.........
示例8: fs
int
Client::run(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("d", "debug");
opts.addOpt("", "import", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "export", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "dbhome", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "dbpath", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "mapsize", IceUtilInternal::Options::NeedArg);
vector<string> args;
try
{
args = opts.parse(argc, const_cast<const char**>(argv));
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
usage();
return EXIT_FAILURE;
}
if(!args.empty())
{
cerr << argv[0] << ": too many arguments" << endl;
usage();
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage();
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
if(!(opts.isSet("import") ^ opts.isSet("export")))
{
cerr << argv[0] << ": either --import or --export must be set" << endl;
usage();
return EXIT_FAILURE;
}
if(!(opts.isSet("dbhome") ^ opts.isSet("dbpath")))
{
cerr << argv[0] << ": set the database environment directory with either --dbhome or --dbpath" << endl;
usage();
return EXIT_FAILURE;
}
bool debug = opts.isSet("debug");
bool import = opts.isSet("import");
string dbFile = opts.optArg(import ? "import" : "export");
string dbPath;
if(opts.isSet("dbhome"))
{
dbPath = opts.optArg("dbhome");
}
else
{
dbPath = opts.optArg("dbpath");
}
string mapSizeStr = opts.optArg("mapsize");
size_t mapSize = IceDB::getMapSize(atoi(mapSizeStr.c_str()));
try
{
IceStorm::AllData data;
IceDB::IceContext dbContext;
dbContext.communicator = communicator();
dbContext.encoding.major = 1;
dbContext.encoding.minor = 1;
if(import)
{
cout << "Importing database to directory " << dbPath << " from file " << dbFile << endl;
if(!IceUtilInternal::directoryExists(dbPath))
{
cerr << argv[0] << ": output directory does not exist: " << dbPath << endl;
return EXIT_FAILURE;
}
if(!IceUtilInternal::isEmptyDirectory(dbPath))
{
cerr << argv[0] << ": output directory is not empty: " << dbPath << endl;
return EXIT_FAILURE;
}
ifstream fs(dbFile.c_str(), ios::binary);
if(fs.fail())
//.........这里部分代码省略.........
示例9: catch
int
run(int argc, char* argv[], const CommunicatorPtr& communicator)
{
IceUtilInternal::Options opts;
opts.addOpt("", "id", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "unsub");
try
{
opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
return EXIT_FAILURE;
}
PropertiesPtr properties = communicator->getProperties();
const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default";
string managerProxy = properties->getProperty(managerProxyProperty);
if(managerProxy.empty())
{
cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
ObjectPrx base = communicator->stringToProxy(managerProxy);
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base);
if(!manager)
{
cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl;
return EXIT_FAILURE;
}
ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default");
TopicPrx topic;
try
{
topic = manager->retrieve("single");
}
catch(const IceStorm::NoSuchTopic& e)
{
cerr << argv[0] << ": NoSuchTopic: " << e.name << endl;
return EXIT_FAILURE;
}
Ice::ObjectPrx prx = adapter->add(new SingleI(), communicator->stringToIdentity(opts.optArg("id")));
if(opts.isSet("unsub"))
{
topic->unsubscribe(prx);
}
else
{
IceStorm::QoS qos;
qos["persistent"] = "true";
topic->subscribeAndGetPublisher(qos, prx);
}
return EXIT_SUCCESS;
}
示例10: fs
int
Client::run(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("d", "debug");
opts.addOpt("", "import", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "export", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "dbhome", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "dbpath", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "mapsize", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "server-version", IceUtilInternal::Options::NeedArg);
vector<string> args;
try
{
args = opts.parse(argc, const_cast<const char**>(argv));
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << e.reason << endl;
usage();
return EXIT_FAILURE;
}
if(!args.empty())
{
cerr << argv[0] << ": too many arguments" << endl;
usage();
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage();
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
if(!(opts.isSet("import") ^ opts.isSet("export")))
{
cerr << "Either --import or --export must be set" << endl;
usage();
return EXIT_FAILURE;
}
if(!(opts.isSet("dbhome") ^ opts.isSet("dbpath")))
{
cerr << "Set the database environment directory with either --dbhome or --dbpath" << endl;
usage();
return EXIT_FAILURE;
}
bool debug = opts.isSet("debug");
bool import = opts.isSet("import");
string dbFile = opts.optArg(import ? "import" : "export");
string dbPath;
if(opts.isSet("dbhome"))
{
dbPath = opts.optArg("dbhome");
}
else
{
dbPath = opts.optArg("dbpath");
}
string mapSizeStr = opts.optArg("mapsize");
size_t mapSize = IceDB::getMapSize(atoi(mapSizeStr.c_str()));
string serverVersion = opts.optArg("server-version");
try
{
IceGrid::AllData data;
IceDB::IceContext dbContext;
dbContext.communicator = communicator();
dbContext.encoding.major = 1;
dbContext.encoding.minor = 1;
if(import)
{
cout << "Importing database to directory `" << dbPath << "' from file `" << dbFile << "'" << endl;
if(!IceUtilInternal::directoryExists(dbPath))
{
cerr << "Output directory does not exist: " << dbPath << endl;
return EXIT_FAILURE;
}
StringSeq files = IcePatch2Internal::readDirectory(dbPath);
if(!files.empty())
{
cerr << "Output directory is not empty: " << dbPath << endl;
return EXIT_FAILURE;
}
//.........这里部分代码省略.........
示例11: if
int
run(int argc, char* argv[], const CommunicatorPtr& communicator)
{
IceUtilInternal::Options opts;
opts.addOpt("", "events", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "qos", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("", "slow");
opts.addOpt("", "erratic", IceUtilInternal::Options::NeedArg);
try
{
opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
return EXIT_FAILURE;
}
int events = 1000;
string s = opts.optArg("events");
if(!s.empty())
{
events = atoi(s.c_str());
}
if(events <= 0)
{
cerr << argv[0] << ": events must be > 0." << endl;
return EXIT_FAILURE;
}
IceStorm::QoS cmdLineQos;
vector<string> sqos = opts.argVec("qos");
for(vector<string>::const_iterator q = sqos.begin(); q != sqos.end(); ++q)
{
string::size_type off = q->find(",");
if(off == string::npos)
{
cerr << argv[0] << ": parse error: no , in QoS" << endl;
return EXIT_FAILURE;
}
cmdLineQos[q->substr(0, off)] = q->substr(off+1);
}
bool slow = opts.isSet("slow");
bool erratic = false;
int erraticNum = 0;
s = opts.optArg("erratic");
if(!s.empty())
{
erratic = true;
erraticNum = atoi(s.c_str());
}
if(events <= 0)
{
cerr << argv[0] << ": events must be > 0." << endl;
return EXIT_FAILURE;
}
PropertiesPtr properties = communicator->getProperties();
const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default";
string managerProxy = properties->getProperty(managerProxyProperty);
if(managerProxy.empty())
{
cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(
communicator->stringToProxy(managerProxy));
if(!manager)
{
cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl;
return EXIT_FAILURE;
}
vector<Subscription> subs;
if(erratic)
{
for(int i = 0 ; i < erraticNum; ++i)
{
ostringstream os;
os << "SubscriberAdapter" << i;
Subscription item;
item.adapter = communicator->createObjectAdapterWithEndpoints(os.str(), "default");
item.servant = new ErraticEventI(communicator, events);
item.qos["reliability"] = "twoway";
subs.push_back(item);
}
}
else if(slow)
{
Subscription item;
item.adapter = communicator->createObjectAdapterWithEndpoints("SubscriberAdapter", "default");
item.servant = new SlowEventI(communicator, events);
item.qos = cmdLineQos;
subs.push_back(item);
}
//.........这里部分代码省略.........
示例12: if
int
compile(const vector<string>& argv)
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "validate");
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("E");
opts.addOpt("", "stdout");
opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "depend");
opts.addOpt("", "depend-json");
opts.addOpt("", "depend-xml");
opts.addOpt("", "depend-file", IceUtilInternal::Options::NeedArg, "");
opts.addOpt("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end();
vector<string> args;
try
{
args = opts.parse(argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << argv[0] << ": error: " << e.reason << endl;
if(!validate)
{
usage(argv[0]);
}
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(argv[0]);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
consoleErr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
vector<string> cppArgs;
vector<string> optargs = opts.argVec("D");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-D" + *i);
}
optargs = opts.argVec("U");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
vector<string> includePaths = opts.argVec("I");
for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
}
bool preprocess = opts.isSet("E");
bool useStdout = opts.isSet("stdout");
string output = opts.optArg("output-dir");
bool depend = opts.isSet("depend");
bool dependJSON = opts.isSet("depend-json");
bool dependxml = opts.isSet("depend-xml");
string dependFile = opts.optArg("depend-file");
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
bool underscore = opts.isSet("underscore");
if(args.empty())
{
consoleErr << argv[0] << ": error: no input file" << endl;
if(!validate)
{
usage(argv[0]);
}
return EXIT_FAILURE;
}
if(depend && dependJSON)
//.........这里部分代码省略.........
示例13: is
int
Client::run(StringSeq& originalArgs)
{
string commands;
bool debug;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("e", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("i", "instanceName", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
opts.addOpt("H", "host", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
opts.addOpt("P", "port", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
opts.addOpt("u", "username", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
opts.addOpt("p", "password", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
opts.addOpt("S", "ssl");
opts.addOpt("d", "debug");
opts.addOpt("s", "server");
opts.addOpt("r", "replica", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
vector<string> args;
try
{
args = opts.parse(originalArgs);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << e.reason << endl;
usage();
return EXIT_FAILURE;
}
if(!args.empty())
{
cerr << _appName << ": too many arguments" << endl;
usage();
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage();
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
if(opts.isSet("server"))
{
ObjectAdapterPtr adapter =
communicator()->createObjectAdapterWithEndpoints("FileParser", "tcp -h localhost");
adapter->activate();
ObjectPrx proxy = adapter->add(new FileParserI, communicator()->stringToIdentity("FileParser"));
cout << proxy << endl;
communicator()->waitForShutdown();
return EXIT_SUCCESS;
}
if(opts.isSet("e"))
{
vector<string> optargs = opts.argVec("e");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
commands += *i + ";";
}
}
debug = opts.isSet("debug");
bool ssl = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL");
if(opts.isSet("ssl"))
{
ssl = true;
}
string id = communicator()->getProperties()->getProperty("IceGridAdmin.Username");
if(!opts.optArg("username").empty())
{
id = opts.optArg("username");
}
string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password");
if(!opts.optArg("password").empty())
{
password = opts.optArg("password");
}
string host = communicator()->getProperties()->getProperty("IceGridAdmin.Host");
if(!opts.optArg("host").empty())
{
host = opts.optArg("host");
}
string instanceName = communicator()->getProperties()->getProperty("IceGridAdmin.InstanceName");
if(!opts.optArg("instanceName").empty())
{
instanceName = opts.optArg("instanceName");
}
//.........这里部分代码省略.........
示例14: out
bool
RegistryService::start(int argc, char* argv[], int& status)
{
bool nowarn;
bool readonly;
std::string initFromReplica;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "nowarn");
opts.addOpt("", "readonly");
opts.addOpt("", "initdb-from-replica", IceUtilInternal::Options::NeedArg);
vector<string> args;
try
{
args = opts.parse(argc, const_cast<const char**>(argv));
}
catch(const IceUtilInternal::BadOptException& e)
{
error(e.reason);
usage(argv[0]);
return false;
}
if(opts.isSet("help"))
{
usage(argv[0]);
status = EXIT_SUCCESS;
return false;
}
if(opts.isSet("version"))
{
print(ICE_STRING_VERSION);
status = EXIT_SUCCESS;
return false;
}
nowarn = opts.isSet("nowarn");
readonly = opts.isSet("readonly");
if(opts.isSet("initdb-from-replica"))
{
initFromReplica = opts.optArg("initdb-from-replica");
}
if(!args.empty())
{
cerr << argv[0] << ": too many arguments" << endl;
usage(argv[0]);
return false;
}
Ice::PropertiesPtr properties = communicator()->getProperties();
//
// Warn the user that setting Ice.ThreadPool.Server isn't useful.
//
if(!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
{
Warning out(communicator()->getLogger());
out << "setting `Ice.ThreadPool.Server.Size' is not useful, ";
out << "you should set individual adapter thread pools instead.";
}
TraceLevelsPtr traceLevels = new TraceLevels(communicator(), "IceGrid.Registry");
_registry = new RegistryI(communicator(), traceLevels, nowarn, readonly, initFromReplica, "");
if(!_registry->start())
{
return false;
}
return true;
}
示例15: s
int
compile(const vector<string>& argv)
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "validate");
opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("E");
opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg, ".");
opts.addOpt("", "hdr", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "ftr", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "indexhdr", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "indexftr", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "index", IceUtilInternal::Options::NeedArg, "1");
opts.addOpt("", "image-dir", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "logo-url", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "search", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "summary", IceUtilInternal::Options::NeedArg, "0");
opts.addOpt("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
bool validate = find(argv.begin(), argv.end(), "--validate") != argv.end();
vector<string> args;
try
{
args = opts.parse(argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << argv[0] << ": error: " << e.reason << endl;
if(!validate)
{
usage(argv[0]);
}
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(argv[0]);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
consoleErr << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
vector<string> cppArgs;
vector<string> optargs = opts.argVec("D");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-D" + *i);
}
optargs = opts.argVec("U");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
optargs = opts.argVec("I");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
}
bool preprocess = opts.isSet("E");
string output = opts.optArg("output-dir");
string header = opts.optArg("hdr");
string footer = opts.optArg("ftr");
string indexHeader = opts.optArg("indexhdr");
string indexFooter = opts.optArg("indexftr");
string ind = opts.optArg("index");
unsigned indexCount = 0;
if(!ind.empty())
{
istringstream s(ind);
s >> indexCount;
if(!s)
{
consoleErr << argv[0] << ": error: the --index operation requires a positive integer argument"
<< endl;
if(!validate)
{
usage(argv[0]);
}
return EXIT_FAILURE;
}
//.........这里部分代码省略.........