本文整理汇总了C++中ArgumentParser类的典型用法代码示例。如果您正苦于以下问题:C++ ArgumentParser类的具体用法?C++ ArgumentParser怎么用?C++ ArgumentParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArgumentParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readCommandLine
void CullSettings::readCommandLine(ArgumentParser& arguments)
{
// report the usage options.
if (arguments.getApplicationUsage())
{
arguments.getApplicationUsage()->addCommandLineOption("--COMPUTE_NEAR_FAR_MODE <mode>","DO_NOT_COMPUTE_NEAR_FAR | COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES | COMPUTE_NEAR_FAR_USING_PRIMITIVES");
arguments.getApplicationUsage()->addCommandLineOption("--NEAR_FAR_RATIO <float>","Set the ratio between near and far planes - must greater than 0.0 but less than 1.0.");
}
std::string str;
while(arguments.read("--COMPUTE_NEAR_FAR_MODE",str))
{
if (str=="DO_NOT_COMPUTE_NEAR_FAR") _computeNearFar = DO_NOT_COMPUTE_NEAR_FAR;
else if (str=="COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES") _computeNearFar = COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES;
else if (str=="COMPUTE_NEAR_FAR_USING_PRIMITIVES") _computeNearFar = COMPUTE_NEAR_FAR_USING_PRIMITIVES;
OSG_NOTIFY(osg::INFO)<<"Set compute near far mode to "<<_computeNearFar<<std::endl;
}
double value;
while(arguments.read("--NEAR_FAR_RATIO",value))
{
_nearFarRatio = value;
OSG_NOTIFY(osg::INFO)<<"Set near/far ratio to "<<_nearFarRatio<<std::endl;
}
}
示例2: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
ArgumentParser parser;
QTextStream out(stdout);
parser.next(); // eat the program name
if (!parser.hasNext()) {
showHelp(out);
return 0;
}
try {
Engine eng;
commandWebExport(out, parser);
}
catch (ArgumentParser::HelpException &) {
showHelp(out);
return 0;
}
catch (ArgumentParser::Exception &e){
showError(out, e);
return 1;
}
return 0;
}
示例3: main
int main(int argc, char* argv[])
{
Config* config = Config::getConfig();
ArgumentParser argParser;
if(!argParser.parseArgs(argc, argv))
{
argParser.printUsage();
return 1;
}
if(config->rtPrio)
{
PrioritySwitcher prioSwitcher(config->fifoScheduling);
if(prioSwitcher.switchToRealtimePriority() != 0)
{
Logger::ERROR("Switching to realtime priority failed, maybe not running as root?");
return 1;
}
}
ros::init(argc, argv, "communication_tests_subscriber");
config->nodeHandle = new ros::NodeHandle();
Subscriber subscriber("communication_tests");
subscriber.startMeasurement();
subscriber.printMeasurementResults();
subscriber.saveGnuplotData();
return 0;
}
示例4: main
int main(int argc, char* argv[])
{
ArgumentParser argParser;
if(!argParser.parseArgs(argc, argv))
{
Logger::ERROR("Invalid arguments provided!");
Logger::ERROR(argParser.getUsage());
return 1;
}
Config* config = Config::getConfig();
config->testnodePrioritySwitcher = new PrioritySwitcher(0, config->fifoScheduling);
if(!setProcessPriority())
{
Logger::ERROR("Couldn't set priority appropriately, maybe not running as root?");
return 1;
}
ros::init(argc, argv, "oneshot_timer_tests");
config->nodeHandle = new ros::NodeHandle;
Logger::INFO("Performing ROS Timer latency measurements...");
OneShotLatencyMeasurer* measurer;
if(config->busyMode)
{
Logger::INFO("Running in busy mode");
measurer = new BusyOneShotLatencyMeasurer();
} else {
Logger::INFO("Running in default mode");
measurer = new IdleOneShotLatencyMeasurer();
}
measurer->measure();
measurer->printMeasurementResults();
measurer->saveMeasuredLatencyGnuplotData();
return 0;
}
示例5: getDefaultArgumentParser
int
ArgumentParserTest::testStringMatch(){
int retval = 0;
char *argv[2] = {
"-stringArg",
"someString",
};
ArgumentParser *toTest = getDefaultArgumentParser();
vector<string> argVec = ArgumentParser::vectorifyArguments( 2, argv, false );
if( argVec[0] != "-stringArg" || argVec[1] != "someString" ){
retval = 1;
goto end;
}
toTest->checkArgs( argVec );
if( stringArg != "someString" ){
retval = 1;
goto end;
}
if( argVec.size() > 0 ){
retval = 1;
goto end;
}
end:
return retval;
}
示例6: getSeed
long getSeed(const ArgumentParser &args){//{{{
long seed;
if(args.isSet("seed"))seed=args.getL("seed");
else seed = time(NULL);
if(args.verbose)message("seed: %ld\n",seed);
return seed;
}//}}}
示例7: main
int
main(int argc, char **argv)
{
ArgumentParser *argp = new ArgumentParser(argc, argv, "arlsh");
if ( argp->has_arg("h") ) {
cout << "Usage: " << argv[0] << "[-r] [-h] [-s] [-l] [-a]" << endl
<< " -r receiver (sender otherwise)" << endl
<< " -h this help message" << endl
<< " -s single per recv, only process a single message per recv()" << endl
#ifdef HAVE_AVAHI
<< " -a enable Avahi for mDNS lookup" << endl
#else
<< " -a not available (Avahi not installed)" << endl
#endif
<< " -l enable multicast loop back" << endl;
return 0;
}
WorldInfoQAMain m(argp);
SignalManager::register_handler(SIGINT, &m);
SignalManager::ignore(SIGPIPE);
m.run();
SignalManager::finalize();
delete argp;
return 0;
}
示例8: main
int main(int argc, char *argv[]) {
ArgumentParser ap;
ap.parse_args(argc, argv);
initialize_dash_dirs();
if (ap.index) {
if (ap.genome == "" || ap.seed_len <= 0 || ap.threads <= 0) {
parse_error(ap);
} else {
indexer(ap.genome, ap.seed_len, ap.threads);
}
}
else if (ap.align) {
if (ap.out == "" || ap.in == "" || ap.threads <= 0 || ap.edit_dist < 0 \
|| ap.conf <= 0 ) {
parse_error(ap);
} else {
aligner(ap.in, ap.out, ap.threads, ap.edit_dist, ap.conf);
}
}
else {
parse_error(ap);
}
return 0;
}
示例9: main
int main(int argc, char *argv[])
{
ArgumentParser parser;
parser.addArgument("-i", "--input", 1, false);
parser.parse(argc, argv);
TApplication *myapp = new TApplication("App", &argc, argv);
fit(parser.retrieve<string>("i"));
myapp->Run();
}
示例10: openOutput
bool openOutput(const ArgumentParser &args, ofstream *outF){//{{{
outF->open(args.getS("outFileName").c_str());
if(!outF->is_open()){
error("Main: Output file open failed.\n");
return false;
}
return true;
}//}}}
示例11: getOutputType
string getOutputType(const ArgumentParser &args, const string &defaultType){ //{{{
string type = ns_misc::toLower(args.getS("outputType"));
if((type!="theta") && (type!="rpkm") && (type!="counts") && (type!="tau")){
type = defaultType;
warning("Using output type %s.",type.c_str());
}
return type;
} //}}}
示例12: parseOptions
/**
* @brief parseOptions parse user arguments
*/
UserOptions parseOptions(const int argc, const char* argv[]) {
UserOptions user_options;
vector<string> arguments;
for (const size_t argn : crange(argc))
arguments.push_back(argv[argn]);
// Parse arguments
ArgumentParser parser;
user_options = parser.parseArguments(arguments);
user_options.addDefaultFiles();
if (user_options.use_textfile) {
output_streamer.createStreamFile(results_str, user_options.datatext_file);
}
return user_options;
}
示例13: readConditions
bool readConditions(const ArgumentParser &args, long *C, long *M, long *N, Conditions *cond){//{{{
if(! cond->init("NONE", args.args(), C, M, N)){
error("Main: Failed loading MCMC samples.\n");
return false;
}
if(args.isSet("normalization")){
if(! cond->setNorm(args.getTokenizedS2D("normalization"))){
error("Main: Applying normalization constants failed.\n");
return false;
}
}
if(!cond->logged() && args.verb()){
message("Samples are not logged. (will log for you)\n");
message("Using %lg as minimum instead of log(0).\n",LOG_ZERO);
}
if(args.verb())message("Files with samples loaded.\n");
return true;
}//}}}
示例14: main
int main(int argc, char* argv[]){
ArgumentParser parser;
parser.parse_args(argc, argv);
if ( argc != 2 ){
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if (!image.data){
printf("No image data \n");
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE );
imshow("Display Image", image);
return 0;
}
示例15: run
int Command::run(std::vector<std::string> arguments, std::ostream *errorStream) {
vector<Argument> parsedArguments;
vector<string> values;
if (arguments.size() > 0) {
if (_subcommands.size() > 0) {
// Check for subcommands
for (auto it = _subcommands.begin(); it != _subcommands.end(); ++it) {
if (arguments[0] == it->name()) {
// Remove first argument (=command)
arguments.erase(arguments.begin());
// Set pointer to sender
it->setParentCommand(this);
return it->run(arguments);
}
}
// Show error
*errorStream << "Error: Invalid command: " << arguments[0] << endl;
return EXIT_FAILURE;
}
// Parse arguments
ArgumentParser parser;
if (!parser.parse(arguments, _options, parsedArguments, values)) {
return EXIT_FAILURE;
}
}
// Run command
if (_action) {
_action(Context(this, parsedArguments, values));
}
return EXIT_SUCCESS;
}