本文整理汇总了C++中iceutilinternal::Options::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ Options::parse方法的具体用法?C++ Options::parse怎么用?C++ Options::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iceutilinternal::Options
的用法示例。
在下文中一共展示了Options::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
IceUtilInternal::Options opts;
opts.addOpt("", "array");
opts.addOpt("", "async");
vector<string> args;
try
{
args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cout << argv[0] << ": " << e.reason << endl;
return false;
}
bool array = opts.isSet("array");
bool async = opts.isSet("async");
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorI, array, async), "");
adapter->activate();
TEST_READY
communicator->waitForShutdown();
return EXIT_SUCCESS;
}
示例2: start
bool SyncService::start(int argc, char* argv[])
{
_myLogger = (MyLoggerI*)communicator()->getLogger()._ptr;
Ice::PropertiesPtr properties = communicator()->getProperties();
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
vector<string> args;
try
{
args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
error(e.reason);
usage(argv[0]);
return false;
}
if(opts.isSet("help"))
{
usage(argv[0]);
return false;
}
if(opts.isSet("version"))
{
print(SYNC_STRING_VERSION);
return false;
}
string connString = properties->getProperty("DB.ConnectionString");
_db = new Database(connString, communicator(), communicator()->getLogger());
std::map<std::string, OrderQueuePtr> queueMap;
_accounts = _db->getAccounts();
for (AccountInfoSeq::iterator p = _accounts.begin(); p != _accounts.end(); ++p)
{
TraderPtr recvTrader = new Trader(*p, communicator()->getLogger());
ReportSyncThreadPtr thread = new ReportSyncThread(p->account, recvTrader, communicator(), _db);
thread->start();
_rsThreads[p->account] = thread;
int workerCount = _db->getPropertyAsInt(p->account + "_wrokerCount");
if (workerCount <= 0)
{
_db->setLongProperty(p->account + "_wrokerCount", 1);
workerCount = 1;
}
OrderQueuePtr queue = new OrderQueue(*p, recvTrader, communicator()->getLogger());
queue->start(workerCount);
queueMap[p->account] = queue;
}
_syncThread = new SyncThread(queueMap, communicator(), _db);
_syncThread->start();
_timer = new IceUtil::Timer();
_timer->scheduleRepeated(new RefreshScreenTask(this), IceUtil::Time::seconds(2));
return true;
}
示例3: out
PyObject*
IcePy_loadSlice(PyObject* /*self*/, PyObject* args)
{
char* cmd;
PyObject* list = 0;
if(!PyArg_ParseTuple(args, STRCAST("s|O!"), &cmd, &PyList_Type, &list))
{
return 0;
}
vector<string> argSeq;
try
{
argSeq = IceUtilInternal::Options::split(cmd);
}
catch(const IceUtilInternal::BadOptException& ex)
{
PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str());
return 0;
}
catch(const IceUtilInternal::APIException& ex)
{
PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str());
return 0;
}
if(list)
{
if(!listToStringSeq(list, argSeq))
{
return 0;
}
}
IceUtilInternal::Options opts;
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("d", "debug");
opts.addOpt("", "ice");
opts.addOpt("", "underscore");
opts.addOpt("", "checksum");
opts.addOpt("", "all");
vector<string> files;
try
{
argSeq.insert(argSeq.begin(), ""); // dummy argv[0]
files = opts.parse(argSeq);
if(files.empty())
{
PyErr_Format(PyExc_RuntimeError, "no Slice files specified in `%s'", cmd);
return 0;
}
}
catch(const IceUtilInternal::BadOptException& ex)
{
PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str());
return 0;
}
catch(const IceUtilInternal::APIException& ex)
{
PyErr_Format(PyExc_RuntimeError, "error in Slice options: %s", ex.reason.c_str());
return 0;
}
vector<string> cppArgs;
Ice::StringSeq includePaths;
bool debug = false;
bool ice = true; // This must be true so that we can create Ice::Identity when necessary.
bool underscore = opts.isSet("underscore");
bool all = false;
bool checksum = false;
if(opts.isSet("D"))
{
vector<string> optargs = opts.argVec("D");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.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)
{
cppArgs.push_back("-U" + *i);
}
}
if(opts.isSet("I"))
{
includePaths = opts.argVec("I");
for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + *i);
}
}
debug = opts.isSet("d") || opts.isSet("debug");
all = opts.isSet("all");
checksum = opts.isSet("checksum");
//.........这里部分代码省略.........
示例4: 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())
//.........这里部分代码省略.........
示例5: 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;
}
//.........这里部分代码省略.........
示例6: 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;
//.........这里部分代码省略.........
示例7: catch
int
run(int argc, char* argv[], const CommunicatorPtr& communicator)
{
IceUtilInternal::Options opts;
opts.addOpt("", "cycle");
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;
}
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(
communicator->stringToProxy(managerProxy));
if(!manager)
{
cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl;
return EXIT_FAILURE;
}
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;
}
}
assert(topic);
//
// Get a publisher object, create a twoway proxy and then cast to
// a Single object.
//
if(opts.isSet("cycle"))
{
Ice::ObjectPrx prx = topic->getPublisher()->ice_twoway();
vector<SinglePrx> single;
Ice::EndpointSeq endpoints = prx->ice_getEndpoints();
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
if((*p)->toString().substr(0, 3) != "udp")
{
Ice::EndpointSeq e;
e.push_back(*p);
single.push_back(SinglePrx::uncheckedCast(prx->ice_endpoints(e)));
}
}
if(single.size() <= 1)
{
cerr << argv[0] << ": Not enough endpoints in publisher proxy" << endl;
return EXIT_FAILURE;
}
int which = 0;
for(int i = 0; i < 1000; ++i)
{
single[which]->event(i);
which = (which + 1) % static_cast<int>(single.size());
}
}
else
{
SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway());
for(int i = 0; i < 1000; ++i)
{
single->event(i);
}
}
return EXIT_SUCCESS;
}
示例8: 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);
//.........这里部分代码省略.........
示例9: 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);
}
//.........这里部分代码省略.........
示例10: 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)
//.........这里部分代码省略.........
示例11: if
int
main(int argc, char* argv[])
#endif
{
Ice::StringSeq originalArgs = Ice::argsToStringSeq(argc, argv);
assert(originalArgs.size() > 0);
const string appName = originalArgs[0];
string dataDir;
StringSeq fileSeq;
int compress = 1;
bool verbose;
bool caseInsensitive;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("z", "compress");
opts.addOpt("Z", "no-compress");
opts.addOpt("V", "verbose");
opts.addOpt("i", "case-insensitive");
vector<string> args;
try
{
args = opts.parse(originalArgs);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << 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;
}
bool doCompress = opts.isSet("compress");
bool dontCompress = opts.isSet("no-compress");
if(doCompress && dontCompress)
{
cerr << appName << ": only one of -z and -Z are mutually exclusive" << endl;
usage(appName);
return EXIT_FAILURE;
}
if(doCompress)
{
compress = 2;
}
else if(dontCompress)
{
compress = 0;
}
verbose = opts.isSet("verbose");
caseInsensitive = opts.isSet("case-insensitive");
if(args.empty())
{
cerr << appName << ": no data directory specified" << endl;
usage(appName);
return EXIT_FAILURE;
}
dataDir = simplify(args[0]);
for(vector<string>::size_type i = 1; i < args.size(); ++i)
{
fileSeq.push_back(simplify(args[i]));
}
try
{
string absDataDir = dataDir;
string cwd;
if(IceUtilInternal::getcwd(cwd) != 0)
{
throw "cannot get the current directory:\n" + IceUtilInternal::lastErrorToString();
}
if(!IceUtilInternal::isAbsolutePath(absDataDir))
{
absDataDir = simplify(cwd + '/' + absDataDir);
}
for(StringSeq::iterator p = fileSeq.begin(); p != fileSeq.end(); ++p)
{
if(!IceUtilInternal::isAbsolutePath(*p))
{
*p = cwd + '/' + *p;
}
}
//
//.........这里部分代码省略.........
示例12: 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");
//.........这里部分代码省略.........
示例13: if
int
Client::run(int argc, char* argv[])
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
vector<string> commands;
try
{
commands = opts.parse(argc, const_cast<const char**>(argv));
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << e.reason << 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(commands.empty())
{
usage();
return EXIT_FAILURE;
}
ObjectPrxPtr base = communicator()->propertyToProxy("IceBoxAdmin.ServiceManager.Proxy");
if(base == 0)
{
//
// The old deprecated way to retrieve the service manager proxy
//
PropertiesPtr properties = communicator()->getProperties();
Identity managerIdentity;
managerIdentity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
managerIdentity.name = "ServiceManager";
string managerProxy;
if(properties->getProperty("Ice.Default.Locator").empty())
{
string managerEndpoints = properties->getProperty("IceBox.ServiceManager.Endpoints");
if(managerEndpoints.empty())
{
cerr << appName() << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
return EXIT_FAILURE;
}
managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" :" + managerEndpoints;
}
else
{
string managerAdapterId = properties->getProperty("IceBox.ServiceManager.AdapterId");
if(managerAdapterId.empty())
{
cerr << appName() << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
return EXIT_FAILURE;
}
managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" @" + managerAdapterId;
}
base = communicator()->stringToProxy(managerProxy);
}
IceBox::ServiceManagerPrxPtr manager = ICE_CHECKED_CAST(IceBox::ServiceManagerPrx, base);
if(!manager)
{
cerr << appName() << ": `" << base << "' is not an IceBox::ServiceManager" << endl;
return EXIT_FAILURE;
}
Ice::SliceChecksumDict serverChecksums = manager->getSliceChecksums();
Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
for(Ice::SliceChecksumDict::const_iterator p = localChecksums.begin(); p != localChecksums.end(); ++p)
{
Ice::SliceChecksumDict::const_iterator q = serverChecksums.find(p->first);
if(q == serverChecksums.end())
{
cerr << appName() << ": server is using unknown Slice type `" << q->first << "'" << endl;
}
else if(p->second != q->second)
{
cerr << appName() << ": server is using a different Slice definition of `" << q->first << "'" << endl;
}
}
//.........这里部分代码省略.........
示例14: 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"))
{
//.........这里部分代码省略.........
示例15: err
bool
RouterService::start(int argc, char* argv[], int& status)
{
bool nowarn;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "nowarn");
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");
if(!args.empty())
{
consoleErr << argv[0] << ": too many arguments" << endl;
usage(argv[0]);
return false;
}
PropertiesPtr properties = communicator()->getProperties();
//
// Initialize the client object adapter.
//
const string clientEndpointsProperty = "Glacier2.Client.Endpoints";
if(properties->getProperty(clientEndpointsProperty).empty())
{
error("property `" + clientEndpointsProperty + "' is not set");
return false;
}
if(properties->getPropertyAsInt("Glacier2.SessionTimeout") > 0 &&
properties->getProperty("Glacier2.Client.ACM.Timeout").empty())
{
ostringstream os;
os << properties->getPropertyAsInt("Glacier2.SessionTimeout");
properties->setProperty("Glacier2.Client.ACM.Timeout", os.str());
}
if(properties->getProperty("Glacier2.Client.ACM.Close").empty())
{
properties->setProperty("Glacier2.Client.ACM.Close", "4"); // Forcefull close on invocation and idle.
}
ObjectAdapterPtr clientAdapter = communicator()->createObjectAdapter("Glacier2.Client");
//
// Initialize the server object adapter only if server endpoints
// are defined.
//
const string serverEndpointsProperty = "Glacier2.Server.Endpoints";
ObjectAdapterPtr serverAdapter;
if(!properties->getProperty(serverEndpointsProperty).empty())
{
serverAdapter = communicator()->createObjectAdapter("Glacier2.Server");
}
string instanceName = communicator()->getProperties()->getPropertyWithDefault("Glacier2.InstanceName", "Glacier2");
vector<string> verifierProperties;
verifierProperties.push_back("Glacier2.PermissionsVerifier");
verifierProperties.push_back("Glacier2.SSLPermissionsVerifier");
Glacier2Internal::setupNullPermissionsVerifier(communicator(), instanceName, verifierProperties);
string verifierProperty = verifierProperties[0];
PermissionsVerifierPrx verifier;
ObjectPrx obj;
try
{
//
// We use propertyToProxy instead of stringToProxy because the property
// can provide proxy attributes
//
obj = communicator()->propertyToProxy(verifierProperty);
}
//.........这里部分代码省略.........