当前位置: 首页>>代码示例>>C++>>正文


C++ ArgumentParser类代码示例

本文整理汇总了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;
    }

}
开发者ID:seafengl,项目名称:osg-by-google,代码行数:28,代码来源:CullSettings.cpp

示例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;
}
开发者ID:ademko,项目名称:hydra,代码行数:29,代码来源:hydraweb.cpp

示例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;
}
开发者ID:F34140r,项目名称:ros_realtime_tests,代码行数:26,代码来源:ct_subscriber_node.cpp

示例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;
}
开发者ID:housel,项目名称:ros_realtime_tests,代码行数:33,代码来源:main.cpp

示例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;
}
开发者ID:CindyYang85,项目名称:pdes,代码行数:28,代码来源:ArgumentParserTest.cpp

示例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;
}//}}}
开发者ID:BitSeq,项目名称:BitSeq-BioC-old,代码行数:7,代码来源:misc.cpp

示例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;
}
开发者ID:F34140r,项目名称:rockin-refbox,代码行数:30,代码来源:qa_worldinfo.cpp

示例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;
}
开发者ID:shobhit6993,项目名称:dash,代码行数:26,代码来源:main.cpp

示例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();
}
开发者ID:Catofes,项目名称:RootScript,代码行数:9,代码来源:cd_fit.cpp

示例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;
}//}}}
开发者ID:BitSeq,项目名称:BitSeq-BioC-old,代码行数:8,代码来源:misc.cpp

示例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;
} //}}}
开发者ID:BitSeq,项目名称:BitSeq-BioC-old,代码行数:8,代码来源:misc.cpp

示例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;
   }
开发者ID:sybila,项目名称:Parsybone,代码行数:21,代码来源:parsing_manager.hpp

示例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;
}//}}}
开发者ID:BitSeq,项目名称:BitSeq-BioC-old,代码行数:18,代码来源:misc.cpp

示例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;
}
开发者ID:PiJoules,项目名称:meme-classification-cpp,代码行数:21,代码来源:classify.cpp

示例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;
}
开发者ID:questbeat,项目名称:CLI,代码行数:39,代码来源:command.cpp


注:本文中的ArgumentParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。