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


C++ AnyOption::getValue方法代码示例

本文整理汇总了C++中AnyOption::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ AnyOption::getValue方法的具体用法?C++ AnyOption::getValue怎么用?C++ AnyOption::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnyOption的用法示例。


在下文中一共展示了AnyOption::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readoption

void readoption(int argc, char *argv[], bool *convertDir,
                QString *filename, QString *dir, QString *path)
{
    /* 1. CREATE AN OBJECT */
    AnyOption *opt = new AnyOption();

    /* 2. SET PREFERENCES  */
    //opt->noPOSIX(); /* do not check for POSIX style character options */
    //opt->setVerbose(); /* print warnings about unknown options */
    //opt->autoUsagePrint(true); /* print usage for bad options */

    /* 3. SET THE USAGE/HELP   */
    opt->addUsage( "" );
    opt->addUsage( "Usage: " );
    opt->addUsage( "" );
    opt->addUsage( " -h  --help               Prints this help " );
    opt->addUsage( " -f  --filename FILENAME  Filename to be converted " );
    opt->addUsage( " -d  --dir DIRECTORY      File dir to be converted " );
    opt->addUsage( " -p  --path PATH          Path where converted file saves " );
    opt->addUsage( "" );

    /* 4. SET THE OPTION STRINGS/CHARACTERS */

    /* by default all  options  will be checked on the command line and from option/resource file */
    opt->setFlag(  "help", 'h' );   /* a flag (takes no argument), supporting long and short form */
    opt->setOption(  "filename", 'f' ); /* an option (takes an argument), supporting long and short form */
    opt->setOption(  "dir", 'd' ); /* an option (takes an argument), supporting long and short form */
    opt->setOption(  "path", 'p' ); /* an option (takes an argument), supporting long and short form */

    /* 5. PROCESS THE COMMANDLINE AND RESOURCE FILE */

    /* go through the command line and get the options  */
    opt->processCommandArgs( argc, argv );

    if( ! opt->hasOptions()) { /* print usage if no options */
        opt->printUsage();
        delete opt;
        return;
    }

    /* 6. GET THE VALUES */
    if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) )
        opt->printUsage();
    if( opt->getValue( 'f' ) != NULL  || opt->getValue( "filename" ) != NULL  ) {
        *convertDir = false;
        filename->append(QString(opt->getValue( 'f' )));
    }
    if( opt->getValue( 'd' ) != NULL  || opt->getValue( "dir" ) != NULL  ) {
        *convertDir = true;
        dir->append(QString(opt->getValue( 'd' )));
    }
    if( opt->getValue( 'p' ) != NULL  || opt->getValue( "path" ) != NULL  ) {
        path->append(QString(opt->getValue( 'p' )));
    }

    /* 8. DONE */
    delete opt;
}
开发者ID:quxiaofeng,项目名称:ImageNameParser,代码行数:58,代码来源:main.cpp

示例2: parse

void UpdaterOptions::parse(int argc, char** argv)
{
	AnyOption parser;
	parser.setOption("install-dir");
	parser.setOption("package-dir");
	parser.setOption("script");
	parser.setOption("wait");
	parser.setOption("mode");
	parser.setFlag("version");
	parser.setFlag("force-elevated");
	parser.setFlag("auto-close");

	parser.processCommandArgs(argc,argv);

	if (parser.getValue("mode"))
	{
		mode = stringToMode(parser.getValue("mode"));
	}
	if (parser.getValue("install-dir"))
	{
		installDir = parser.getValue("install-dir");
	}
	if (parser.getValue("package-dir"))
	{
		packageDir = parser.getValue("package-dir");
	}
	if (parser.getValue("script"))
	{
		scriptPath = parser.getValue("script");
	}
	if (parser.getValue("wait"))
	{
		waitPid = static_cast<PLATFORM_PID>(atoll(parser.getValue("wait")));
	}

	showVersion = parser.getFlag("version");
	forceElevated = parser.getFlag("force-elevated");
	autoClose = parser.getFlag("auto-close");
		
	if (installDir.empty())
	{
		// if no --install-dir argument is present, try parsing
		// the command-line arguments in the old format (which uses
		// a list of 'Key=Value' args)
		parseOldFormatArgs(argc,argv);
	}
}
开发者ID:emandino,项目名称:Update-Installer,代码行数:47,代码来源:UpdaterOptions.cpp

示例3: main

int main(int argc, char* argv[])
{
    AnyOption opt;

    // Usage
    opt.addUsage( "Example: " );
    opt.addUsage( "  cppbitmessage -p 8444" );
    opt.addUsage( " " );
    opt.addUsage( "Usage: " );
    opt.addUsage( "" );
    opt.addUsage( "  -p --port                 Port to listen on");
    opt.addUsage( "  -V --version              Show version number");
    opt.addUsage( "     --help                 Show help");
    opt.addUsage( "" );

    opt.setOption(  "port", 'p' );
    opt.setFlag(  "version", 'V' );
    opt.setFlag(  "help" );

    opt.processCommandArgs(argc, argv);

    if ((!opt.hasOptions()) || (opt.getFlag( "help" )))
    {
		// print usage if no options
        opt.printUsage();
        return 0;
	}

    if ((opt.getFlag("version")) || (opt.getFlag('V')))
    {
        std::cout << "Version " << VERSION << std::endl;
        return 0;
	}

	int port = 8444;
    if ((opt.getValue("port") != NULL) || (opt.getValue('p')))
    {
        std::stringstream ss;
        ss << opt.getValue("port");
        ss >> port;
	}	
开发者ID:bashrc,项目名称:cppbitmessage,代码行数:41,代码来源:main.cpp

示例4: AnyOption

void
simple( int argc, char* argv[] )
{

        AnyOption *opt = new AnyOption();
        opt->noPOSIX(); /* use simpler option type */

        opt->setOption(  "width" );
        opt->setOption(  "height" );
        opt->setFlag( "convert");
        opt->setCommandOption(  "name" );
        opt->setFileOption(  "title" );

        if (  ! opt->processFile( "sample.txt" ) )
                cout << "Failed processing the resource file" << endl ;
        opt->processCommandArgs( argc, argv );

	cout << "THE OPTIONS : " << endl << endl ;
	if( opt->getValue( "width" ) != NULL )
        	cout << "width  : " << opt->getValue( "width" ) << endl ;
	if( opt->getValue( "height" ) != NULL )
        	cout << "height : " << opt->getValue( "height" ) << endl ;
	if( opt->getValue( "name" ) != NULL )
        	cout << "name   : " << opt->getValue( "name" ) << endl ;
	if( opt->getValue( "title" ) != NULL )
        	cout << "title  : " << opt->getValue( "title" ) << endl ;
        if( opt->getFlag( "convert" ) )  
		cout << "convert : set " << endl ;
        cout << endl ;

	cout << "THE ARGUMENTS : " << endl << endl ;
	for( int i = 0 ; i < opt->getArgc() ; i++ ){
		cout << opt->getArgv( i ) << endl  ;
	}
	cout << endl;

        delete opt;

}
开发者ID:Aliandrana,项目名称:snesdev,代码行数:39,代码来源:demo.cpp

示例5: main

int main(int argc, char** argv)
{
    QApplication app(argc, argv);

    AnyOption options;
    options.addUsage(QString("Usage: %1 --help | --console | [--output path --prefix prefixName --suffix suffixName --type typeName").arg(argv[0]).toAscii());
    options.addUsage("");
    options.addUsage("--help                Displays this message.");
    options.addUsage("--console             Run the gui version.");
    options.addUsage("--output [path]       Output directory for the plugin skeleton.");
    options.addUsage("--prefix [prefixName] Prefix to use for the plugin.");
    options.addUsage("--suffix [suffixName] Suffix to use for the plugin.");
    options.addUsage("--type [typeName]     Type to use for the plugin.");
    options.addUsage("--quiet               Process quietly (non gui generation only).");

    options.setFlag("help");
    options.setFlag("console");

    options.setOption("output");
    options.setOption("prefix");
    options.setOption("suffix");
    options.setOption("type");
    options.setOption("quiet");

    options.processCommandArgs(argc, argv);

    if(options.getFlag("help")) {
        options.printUsage();
        return 0;
    }

    if(options.getFlag("console")) {

        bool paramsOk = options.getValue("output") && options.getValue("prefix") && options.getValue("type") && options.getValue("suffix");

        if( !paramsOk ) {
            options.printUsage();
            return 1;
        }

        if(!options.getFlag("quiet")) {
            qDebug() << "output = " << options.getValue("output");
            qDebug() << "prefix = " << options.getValue("prefix");
            qDebug() << "suffix = " << options.getValue("suffix");
            qDebug() << "type = " << options.getValue("type");
        }

        dtkPluginGenerator generator;
        generator.setOutputDirectory(options.getValue("output"));
        generator.setPrefix(options.getValue("prefix"));
        generator.setSuffix(options.getValue("suffix"));
        generator.setType(options.getValue("type"));

        bool resultGenerator = generator.run();

        if(!options.getFlag("quiet")) {
            if(resultGenerator)
                qDebug() << "Generation succeeded.";
            else
                qDebug() << "Plugin generation: Generation failed.";
        }

    } else {

        dtkPluginGeneratorMainWindow generator;
        generator.show();
	generator.raise();
        return app.exec();
        
    }
}
开发者ID:papadop,项目名称:dtk,代码行数:71,代码来源:main.cpp

示例6: main

/**
 * @brief Read in a list of array and check for each of the arrays whether they are in LMC form or not
 * @param argc
 * @param argv[]
 * @return
 */
int main (int argc, char *argv[]) {
        char *fname;
        int correct = 0, wrong = 0;

        /* parse command line options */
        AnyOption opt;
        opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
        opt.setOption ("loglevel", 'l');
        opt.setOption ("oaconfig", 'c');
        opt.setOption ("check");
        opt.setOption ("strength", 's');
        opt.setOption ("prune", 'p');
        opt.setOption ("output", 'o');
        opt.setOption ("mode", 'm');

        opt.addUsage ("oacheck: Check arrays for LMC form or reduce to LMC form");
        opt.addUsage ("Usage: oacheck [OPTIONS] [ARRAYFILE]");
        opt.addUsage ("");
        opt.addUsage (" -h  --help  			Prints this help");
        opt.addUsage (" -l [LEVEL]  --loglevel [LEVEL]	Set loglevel to number");
        opt.addUsage (" -s [STRENGTH]  --strength [STRENGTH] Set strength to use in checking");
        std::string ss = " --check [MODE]			Select mode: ";
        ss +=
            printfstring ("%d (default: check ), %d (reduce to LMC form), %d (apply random transformation and reduce)",
                          MODE_CHECK, MODE_REDUCE, MODE_REDUCERANDOM); //
        for (int i = 3; i < ncheckopts; ++i)
                ss += printfstring (", %d (%s)", static_cast< checkmode_t > (i), modeString ((checkmode_t)i).c_str ());
        opt.addUsage (ss.c_str ());
        opt.addUsage (" -o [OUTPUTFILE] Output file for LMC reduction");

        opt.processCommandArgs (argc, argv);

        algorithm_t algmethod = (algorithm_t)opt.getIntValue ("mode", MODE_AUTOSELECT);

        int loglevel = NORMAL;
        if (opt.getValue ("loglevel") != NULL || opt.getValue ('l') != NULL)
                loglevel = atoi (opt.getValue ('l')); // set custom loglevel
        setloglevel (loglevel);

        if (checkloglevel (QUIET)) {
                print_copyright ();
        }

        if (opt.getFlag ("help") || opt.getFlag ('h') || opt.getArgc () == 0) {
                opt.printUsage ();
                return 0;
        }

        checkmode_t mode = MODE_CHECK;
        if (opt.getValue ("check") != NULL)
                mode = (checkmode_t)atoi (opt.getValue ("check")); // set custom loglevel
        if (mode >= ncheckopts)
                mode = MODE_CHECK;

        logstream (QUIET) << "#time start: " << currenttime () << std::endl;

        double t = get_time_ms ();
        t = 1e3 * (t - floor (t));
        srand (t);

        int prune = opt.getIntValue ('p', 0);

        fname = opt.getArgv (0);
        setloglevel (loglevel);

        int strength = opt.getIntValue ('s', 2);
        if (strength < 1 || strength > 10) {
                printf ("Strength specfied (t=%d) is invalid\n", strength);
                exit (1);
        } else {
                log_print (NORMAL, "Using strength %d to increase speed of checking arrays\n", strength);
        }

        arraylist_t outputlist;
        char *outputfile = 0;
        bool writeoutput = false;
        if (opt.getValue ("output") != NULL) {
                writeoutput = true;
                outputfile = opt.getValue ('o');
        }

        arrayfile_t *afile = new arrayfile_t (fname);
        if (!afile->isopen ()) {
                printf ("Problem opening %s\n", fname);
                exit (1);
        }

        logstream (NORMAL) << "Check mode: " << mode << " (" << modeString (mode) << ")" << endl;

        /* start checking */
        double Tstart = get_time_ms (), dt;

        int index;
        array_link al (afile->nrows, afile->ncols, -1);
//.........这里部分代码省略.........
开发者ID:eendebakpt,项目名称:oapackage,代码行数:101,代码来源:oacheck.cpp

示例7: main

int   main(int argc, char **argv)
{
    AnyOption *opt = new AnyOption();

    opt->addUsage("");
    opt->addUsage("Usage: ");
    opt->addUsage("");
    opt->addUsage(" -h  --help          Print usage ");
    opt->addUsage(" -L  --subsecLet     Letter of Subsector (A-P) to generate, if omitted will generate entire sector ");
    opt->addUsage(" -d  --detail       %|zero|rift|sparse|scattered|dense ");
    opt->addUsage(" -m  --maturity      Tech level, backwater|frontier|mature|cluster ");
    opt->addUsage(" -a  --ac            Two-letter system alignment code ");
    opt->addUsage(" -s  --secName       Name of sector. For default output file name and sectorName_names.txt file");
    opt->addUsage(" -p  --path          Path to sectorName_names.txt file ");
    opt->addUsage(" -o  --outFormat     1|2|3|4|5|6 : v1.0, v2.0, v2.1 v2.1b, v2.2, v2.5 ");
    opt->addUsage(" -u  --outPath       Path and name of output file ");
    opt->addUsage("");

    opt->setCommandFlag("main", 'm');
    opt->setCommandFlag("system", 'S');
    opt->setCommandFlag("sector", 's');
    opt->setCommandFlag("subsector", 'u');
    opt->setCommandFlag("help", 'h');
    opt->setCommandOption("", 'x');
    opt->setCommandOption("", 'y');
    opt->setCommandOption("", 'z');
    opt->setCommandOption("detail", 'd');
    opt->setCommandOption("seed");

    //opt->setVerbose(); /* print warnings about unknown options */
    //opt->autoUsagePrint(true); /* print usage for bad options */

    opt->processCommandArgs(argc, argv);
#if 0
    if(! opt->hasOptions()) {  /* print usage if no options */
        opt->printUsage();
        delete opt;
        return 0;
    }
#endif
    if(opt->getFlag("help") || opt->getFlag('h')) {
        opt->printUsage();
        delete opt;
        return 0;
    }
    //long seed = 12345;
    long x = 0;
    long y = 10;
    long z = 0;
    int detail = 3;
    if(opt->getValue('x') != NULL) {
        x = atol(opt->getValue('x'));
    }
    if(opt->getValue('y') != NULL) {
        y = atol(opt->getValue('y'));
    }
    if(opt->getValue('z') != NULL) {
        z = atol(opt->getValue('z'));
    }
    if(opt->getValue("seed") != NULL) {
        //seed = atol(opt->getValue("seed"));
    }
    if(opt->getValue("detail") != NULL) {
        detail = atol(opt->getValue("detail"));
    }

    long startX, startY, startZ;
    long endX, endY, endZ;
    long sectorX = 8 * 4;
    long sectorY = 10 * 4;
    long sectorZ = 1;
    if(opt->getFlag("sector")) {
        startX = x / sectorX;
        endX = startX + sectorX - 1;
        startY = y / sectorY;
        endY = startY + sectorY - 1;
        startZ = z / sectorZ;
        endZ = startZ + sectorZ - 1;
    } else {
        startX = x;
        endX = x;
        startY = y;
        endY = y;
        startZ = z;
        endZ = z;
    }

    for(int i = startX; i <= endX; i++) {
        for(int j = startY; j <= endY; j++) {
            for(int k = startZ; k <= endZ; k++) {
                printSystem(x, y, z, detail);
            }
        }
    }

}
开发者ID:scadding,项目名称:MyUniverse,代码行数:96,代码来源:sysgen.cpp

示例8: pfs

//+----------------------------------------------------------------------------+
//| main()                                                                     |
//-----------------------------------------------------------------------------+
int
main(int argc, char** argv)
{
  common::PathFileString pfs(argv[0]);
  //////////////////////////////////////////////////////////////////////////////
  // User command line parser
  AnyOption *opt = new AnyOption();
  opt->autoUsagePrint(true);

  opt->addUsage( "" );
  opt->addUsage( "Usage: " );
  char buff[256];
  sprintf(buff, "       Example: %s -r example1_noisy.cfg", pfs.getFileName().c_str());
  opt->addUsage( buff );
  opt->addUsage( " -h  --help                 Prints this help" );
  opt->addUsage( " -r  --readfile <filename>  Reads the polyhedra description file" );
  opt->addUsage( " -t  --gltopic <topic name> (opt) ROS Topic to send OpenGL commands " );
  opt->addUsage( "" );

  opt->setFlag(  "help", 'h' );
  opt->setOption(  "readfile", 'r' );

  opt->processCommandArgs( argc, argv );

  if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) {opt->printUsage(); delete opt; return(1);}

  std::string gltopic("OpenGLRosComTopic");
  if( opt->getValue( 't' ) != NULL  || opt->getValue( "gltopic" ) != NULL  ) gltopic = opt->getValue( 't' );
	std::cerr << "[OpenGL communication topic is set to : \"" << gltopic << "\"]\n";

  std::string readfile;
	if( opt->getValue( 'r' ) != NULL  || opt->getValue( "readfile" ) != NULL  )
	{
    readfile = opt->getValue( 'r' );
    std::cerr << "[ World description is read from \"" << readfile << "\"]\n";
	}
	else{opt->printUsage(); delete opt; return(-1);}

  delete opt;
  //
  //////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////////////////////////////////////////////////
  // Initialize ROS and OpenGLRosCom node (visualization)
  std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]"<< std::endl;
  ros::init(argc, argv, pfs.getFileName().c_str());
  if(ros::isInitialized())
    std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[OK]\n"<< std::endl;
  else{
    std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[FAILED]\n"<< std::endl;
    return(1);
  }
  COpenGLRosCom glNode;
  glNode.CreateNode(gltopic);
  //
  //////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////////////////////////////////////////////////
  // Reading the input file
  std::cerr << "Reading the input file..." << std::endl;
  ShapeVector shapes;
  PoseVector  poses;
  IDVector    ID;
  if(ReadPolyhedraConfigFile(readfile, shapes, poses, ID)==false)
  {
    std::cerr << "["<<pfs.getFileName()<<"]:" << "Error reading file \"" << readfile << "\"\n";
    return(-1);
  }
  std::cerr << "Read " << poses.size() << " poses of " << shapes.size() << " shapes with " << ID.size() << " IDs.\n";
  //
  //////////////////////////////////////////////////////////////////////////////

  //////////////////////////////////////////////////////////////////////////////
  // Visualizing the configuration of objects
  std::cerr << "Visualizing the configuration of objects..." << std::endl;
  for(unsigned int i=0; i<shapes.size(); i++)
  {
    for(size_t j=0; j<shapes[i].F.size(); j++)
    {
      glNode.LineWidth(1.0f);
      glNode.AddColor3(0.3f, 0.6f, 0.5f);
      glNode.AddBegin("LINE_LOOP");
      for(size_t k=0; k<shapes[i].F[j].Idx.size(); k++)
      {
        int idx = shapes[i].F[j].Idx[k];
        Eigen::Matrix<Real,3,1> Vt = poses[i]*shapes[i].V[ idx ];
        glNode.AddVertex(Vt.x(), Vt.y(), Vt.z());
      }
      glNode.AddEnd();
    }
  }
  glNode.SendCMDbuffer();
  ros::spinOnce();
  common::PressEnterToContinue();
  //
  //////////////////////////////////////////////////////////////////////////////

//.........这里部分代码省略.........
开发者ID:Rasoul77,项目名称:promts,代码行数:101,代码来源:DemoPROMTSDLS.cpp

示例9: main

int main(int argc, char * argv[], MPI_Comm commWorld)
{
#else
int main(int argc, char * argv[])
{
 MPI_Comm commWorld;
#endif

  std::string fileName;
  int reduceDM    =  10;
  int reduceS=  1;
#ifndef PARTICLESRENDERER
  std::string fullScreenMode    = "";
  bool stereo     = false;
#endif
  int nmaxsample = 200000;
  std::string display;

  bool inSitu = false;
  bool quickSync = true;
  int sleeptime = 1;

  {
    AnyOption opt;

#define ADDUSAGE(line) {{std::stringstream oss; oss << line; opt.addUsage(oss.str());}}

    ADDUSAGE(" ");
    ADDUSAGE("Usage:");
    ADDUSAGE(" ");
    ADDUSAGE(" -h  --help             Prints this help ");
    ADDUSAGE(" -i  --infile #         Input snapshot filename ");
    ADDUSAGE(" -I  --insitu          Enable in-situ rendering ");
    ADDUSAGE("     --sleep  #        start up sleep in sec [1]  ");
    ADDUSAGE("     --noquicksync      disable syncing with simulation [enabled] ");
    ADDUSAGE("     --reduceDM    #    cut down DM dataset by # factor [10]. 0-disable DM");
    ADDUSAGE("     --reduceS     #    cut down stars dataset by # factor [1]. 0-disable S");
#ifndef PARTICLESRENDERER
    ADDUSAGE("     --fullscreen  #    set fullscreen mode string");
    ADDUSAGE("     --stereo           enable stereo rendering");
#endif
    ADDUSAGE(" -s  --nmaxsample   #   set max number of samples for DD [" << nmaxsample << "]");
    ADDUSAGE(" -D  --display      #   set DISPLAY=display, otherwise inherited from environment");


    opt.setFlag  ( "help" ,        'h');
    opt.setOption( "infile",       'i');
    opt.setFlag  ( "insitu",       'I');
    opt.setOption( "reduceDM");
    opt.setOption( "sleep");
    opt.setOption( "reduceS");
    opt.setOption( "fullscreen");
    opt.setFlag("stereo");
    opt.setOption("nmaxsample", 's');
    opt.setOption("display", 'D');
    opt.setFlag  ( "noquicksync");

    opt.processCommandArgs( argc, argv );


    if( ! opt.hasOptions() ||  opt.getFlag( "help" ) || opt.getFlag( 'h' ) )
    {
      /* print usage if no options or requested help */
      opt.printUsage();
      ::exit(0);
    }

    char *optarg = NULL;
    if (opt.getFlag("insitu"))  inSitu = true;
    if ((optarg = opt.getValue("infile")))       fileName           = std::string(optarg);
    if ((optarg = opt.getValue("reduceDM"))) reduceDM       = atoi(optarg);
    if ((optarg = opt.getValue("reduceS"))) reduceS       = atoi(optarg);
#ifndef PARTICLESRENDERER
    if ((optarg = opt.getValue("fullscreen")))	 fullScreenMode     = std::string(optarg);
    if (opt.getFlag("stereo"))  stereo = true;
#endif
    if ((optarg = opt.getValue("nmaxsample"))) nmaxsample = atoi(optarg);
    if ((optarg = opt.getValue("display"))) display = std::string(optarg);
    if ((optarg = opt.getValue("sleep"))) sleeptime = atoi(optarg);
    if (opt.getValue("noquicksync")) quickSync = false;

    if ((fileName.empty() && !inSitu) ||
        reduceDM < 0 || reduceS < 0)
    {
      opt.printUsage();
      ::exit(0);
    }

#undef ADDUSAGE
  }

  MPI_Comm comm = MPI_COMM_WORLD;
  int mpiInitialized = 0;
  MPI_Initialized(&mpiInitialized);
  if (!mpiInitialized)
    MPI_Init(&argc, &argv);
  else
    comm = commWorld;

  int nranks, rank;
//.........这里部分代码省略.........
开发者ID:treecode,项目名称:Bonsai,代码行数:101,代码来源:main.cpp

示例10: parsecmd

/**
	Utilizing AnyOption class, take the command line and parse it for valid options. Handle usage printout as well.
	@param argc argc from main()
	@param char**argv array of char* directly from main()
	@returns If an error occurs, return false. Currently no errors. Always returns true.
 */
bool parsecmd(int argc, char**argv)
{
    stringstream str;
    // Setup all default values if not already set by simple strings and values above.

    if (getenv("WEBRTC_SERVER"))
        mainserver = xGetDefaultServerName();

    if (getenv("WEBRTC_CONNECT"))
    {
        stunserver = "STUN ";
        stunserver += xGetPeerConnectionString();
    }
    
    peername = xGetPeerName();
    
	AnyOption *opt = new AnyOption();

	opt->addUsage("Usage: ");
	opt->addUsage("");
	opt->addUsage(" -h  --help                    Prints this help ");
    opt->addUsage(" --server <servername|IP>[:<serverport>]      Main sever and optional port.");
	opt->addUsage(
			" --stun <stunserver|IP>[:<port>]      STUN server (and optionally port).\n   Default is " STUNSERVER_DEFAULT);
	opt->addUsage(
			" --peername <Name>     Use this name as my client/peer name online.");
    opt->addUsage(" --avopts <none|audio|video|audiovideo>      Enable audio, video, or audiovideo.");
	opt->addUsage("");
    opt->addUsage("Environment variables can be used as defaults as well.");
    opt->addUsage("  WEBRTC_SERVER - Main server name.");
    opt->addUsage("  WEBRTC_CONNECT - STUN server name with port.");
    opt->addUsage("  USERNAME - Peer user name.");
	opt->addUsage("");

	opt->setFlag("help", 'h');
	opt->setOption("server");
	opt->setOption("stun");
	opt->setOption("peername");
	opt->setOption("avopts");

	opt->processCommandArgs(argc, argv);

	/* 6. GET THE VALUES */
	if (opt->getFlag("help") || opt->getFlag('h'))
	{
		opt->printUsage();
		exit(1);
	}

    if (opt->getValue("server"))
    {
        cout << "New main server is " << opt->getValue("server") << endl;
        
        string serverloc = opt->getValue("server");
        size_t colonpos = serverloc.find(':');
        mainserver = serverloc.substr(0,colonpos);
        
        if(colonpos != string::npos)
        {
            stringstream sstrm;
            sstrm << serverloc.substr(colonpos+1);
            sstrm >> mainserver_port;
        }
开发者ID:ljqian1990,项目名称:ljqian,代码行数:69,代码来源:parsecmd.cpp

示例11: flag

/// parse the command line options for the program
AnyOption *parseOptions (int argc, char *argv[], algorithm_t &algorithm) {
        AnyOption *opt = new AnyOption;

        /* parse command line options */
        opt->setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
        opt->setOption ("loglevel", 'l');
        opt->setOption ("sort", 's');
        opt->setFlag ("x", 'x'); /* special debugging flag */
        opt->setOption ("restart", 'r');
        opt->setOption ("oaconfig", 'c');    /* file that specifies the design */
        opt->setOption ("output", 'o');      /* prefix for output files */
        opt->setFlag ("generate", 'g');      /* only generate extensions, do not perform LMC check */
        opt->setFlag ("coptions");           /* print compile time options */
        opt->setOption ("format", 'f');      /* format to write to */
        opt->setOption ("mode", 'm');        /* algorithm method */
        opt->setOption ("maxk", 'K');        /* max number of columns to extend to */
        opt->setOption ("rowsymmetry", 'R'); /* max number of columns to extend to */

        opt->setFlag ("streaming"); /* operate in streaming mode */

        opt->setOption ("initcolprev", 'I'); /* algorithm method */

        opt->addUsage ("Orthonal Arrays: extend orthogonal arrays");
#ifdef OAEXTEND_SINGLECORE
        opt->addUsage ("Usage: oaextendmpi [OPTIONS]");
#else
        opt->addUsage ("Usage: oaextendsingle [OPTIONS]");
#endif

        opt->addUsage ("");
        opt->addUsage (" -h  --help  			Prints this help ");
        opt->addUsage (" --coptions			Show compile time options used ");
        opt->addUsage (" -r [FILE]  --restart [FILE]	Restart with results file ");
        opt->addUsage (" -l [LEVEL] --loglevel [LEVEL]	Set loglevel to number ");
        opt->addUsage (" -s [INTEGER] --sort [INTEGER]	Sort input and output arrays (default: 1) ");
        opt->addUsage (" -c [FILE]  --oaconfig [FILE]	Set file with design specification");
        opt->addUsage (" -g  --generate [FILE]		Only generate arrays, do not perform LMC check");
        opt->addUsage ("  --rowsymmetry [VALUE]		Use row symmetry in generation");
        opt->addUsage (" -o [STR]  --output [FILE]	Set prefix for output (default: result) ");
        opt->addUsage (" -f [FORMAT]			Output format (default: TEXT, or BINARY, D, Z). Format D is "
                       "binary difference, format Z is binary with zero-difference ");
        opt->addUsage (" --initcolprev [INTEGER]	Initialization method of new column (default: 1)");
        opt->addUsage (
            " --maxk [INTEGER] Maximum number of columns to exten to (default: extracted from config file) ");
        opt->addUsage (
            " --streaming			Operate in streaming mode. Generated arrays will be written to disk "
            "immediately. ");

        std::string ss = printfstring (" -m [MODE]			Algorithm (") + algorithm_t_list () + ")\n";
        opt->addUsage (ss.c_str ());
        // opt->printUsage();
        opt->addUsage ("");
        opt->addUsage ("Example: ./oaextendsingle -l 2");

        opt->processCommandArgs (argc, argv);

        if (opt->getValue ("mode") != NULL || opt->getValue ('m') != NULL) {
                int vv = atoi (opt->getValue ('m')); // set custom loglevel
                algorithm = (algorithm_t)vv;
        } else {
                algorithm = MODE_AUTOSELECT;
        }

        return opt;
}
开发者ID:eendebakpt,项目名称:oapackage,代码行数:66,代码来源:oaextend.cpp

示例12: main

/**
 * @brief Main function for oaextendmpi and oaextendsingle
 * @param argc
 * @param argv[]
 * @return
 */
int main (int argc, char *argv[]) {
#ifdef OAEXTEND_SINGLECORE
        const int n_processors = 1;
        const int this_rank = 0;
#else
        MPI::Init (argc, argv);

        const int n_processors = MPI::COMM_WORLD.Get_size ();
        const int this_rank = MPI::COMM_WORLD.Get_rank ();
#endif

        // printf("MPI: this_rank %d\n", this_rank);

        /*----------SET STARTING ARRAY(S)-----------*/
        if (this_rank != MASTER) {
#ifdef OAEXTEND_MULTICORE
                slave_print (QUIET, "M: running core %d/%d\n", this_rank, n_processors);
#endif
                algorithm_t algorithm = MODE_INVALID;
                AnyOption *opt = parseOptions (argc, argv, algorithm);
                OAextend oaextend;
                oaextend.setAlgorithm (algorithm);

#ifdef OAEXTEND_MULTICORE
                log_print (NORMAL, "slave: receiving algorithm int\n");
                algorithm = (algorithm_t)receive_int_slave ();
                oaextend.setAlgorithm (algorithm);
// printf("slave %d: receive algorithm %d\n", this_rank, algorithm);
#endif

                extend_slave_code (this_rank, oaextend);

                delete opt;
        } else {
                double Tstart = get_time_ms ();
                int nr_extensions;
                arraylist_t solutions, extensions;

                algorithm_t algorithm = MODE_INVALID;
                AnyOption *opt = parseOptions (argc, argv, algorithm);
                print_copyright ();

                int loglevel = opt->getIntValue ('l', NORMAL);
                setloglevel (loglevel);

                int dosort = opt->getIntValue ('s', 1);
                int userowsymm = opt->getIntValue ("rowsymmetry", 1);
                int maxk = opt->getIntValue ("maxk", 100000);
                int initcolprev = opt->getIntValue ("initcolprev", 1);

                const bool streaming = opt->getFlag ("streaming");

                bool restart = false;
                if (opt->getValue ("restart") != NULL || opt->getValue ('r') != NULL) {
                        restart = true;
                }

                const char *oaconfigfile = opt->getStringValue ('c', "oaconfig.txt");
                const char *resultprefix = opt->getStringValue ('o', "result");

                arrayfile::arrayfilemode_t mode = arrayfile_t::parseModeString (opt->getStringValue ('f', "T"));

                OAextend oaextend;
                oaextend.setAlgorithm (algorithm);

                if (streaming) {
                        logstream (SYSTEM) << "operating in streaming mode, sorting of arrays will not work "
                                           << std::endl;
                        oaextend.extendarraymode = OAextend::STOREARRAY;
                }

                // J5_45
                int xx = opt->getFlag ('x');
                if (xx) {
                        oaextend.j5structure = J5_45;
                }

                if (userowsymm == 0) {
                        oaextend.use_row_symmetry = userowsymm;
                        printf ("use row symmetry -> %d\n", oaextend.use_row_symmetry);
                }
                if (opt->getFlag ('g')) {
                        std::cout << "only generating arrays (no LMC check)" << endl;
                        oaextend.checkarrays = 0;
                }

                if (opt->getFlag ("help") || (opt->getValue ("coptions") != NULL)) {
                        if (opt->getFlag ("help")) {
                                opt->printUsage ();
                        }
                        if (opt->getValue ("coptions") != NULL) {
                                print_options (cout);
                        }
                } else {
//.........这里部分代码省略.........
开发者ID:eendebakpt,项目名称:oapackage,代码行数:101,代码来源:oaextend.cpp

示例13: main

int main(int argc, char** argv)
#endif
/*
#else
int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
#endif
*/
{
	string datapath;

	AnyOption *opt = new AnyOption();
	
    opt->addUsage( "" );
    opt->addUsage( "Usage: " );
    opt->addUsage( "" );
    opt->addUsage( " -h  --help  				Prints this help " );
    opt->addUsage( " -d  --data-path /dir		Data files path " );
    opt->addUsage( "" );

	opt->setFlag(  "help", 'h' );
	opt->setOption(  "data-path", 'd' );

	opt->processCommandArgs( argc, argv );

    if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) 
	{
    	GWDBG_OUTPUT("Usage")
        opt->printUsage();
		delete opt;
		return 0;
	}
	if( opt->getValue( 'd' ) != NULL  || opt->getValue( "data-size" ) != NULL  )
		datapath = opt->getValue('d');

	delete opt;

    try
    {
#ifdef GP2X
        GW_PlatformGP2X platform;
#elif defined(GW_PLAT_PANDORA)
        GW_PlatformPandora platform;
#elif defined(GW_PLAT_S60)
        GW_PlatformS60 platform;
#elif defined(GW_PLAT_WIZ)
        GW_PlatformWIZ platform;
#elif defined(GW_PLAT_ANDROID)
        GW_PlatformAndroid platform;
#elif defined(GW_PLAT_IOS)
        GW_PlatformIOS platform;
#else
        GW_PlatformSDL platform(640, 480);
#endif
		if (!datapath.empty())
			platform.datapath_set(datapath);

        platform.initialize();

        GW_GameList gamelist(&platform);

        GW_Menu menu(&platform, &gamelist);
        menu.Run();

        platform.finalize();
    } catch (GW_Exception &e) {
    	GWDBG_OUTPUT(e.what().c_str())
        fprintf(stderr, "%s\n", e.what().c_str());
        return 1;
    }

    return 0;
}
开发者ID:RangelReale,项目名称:gameandwatch,代码行数:76,代码来源:gamewatch.cpp

示例14: process_option

int process_option(int argc, char* argv[]){
	AnyOption *opt = new AnyOption();
	opt->setVerbose();
	opt->addUsage( "" );
	opt->addUsage( "Usage: " );
	opt->addUsage( "" );
	opt->addUsage( "--S0" );
	opt->addUsage( "--G0" );
	opt->addUsage( "--RhoGEF0" );
	opt->addUsage( "--RhoA0" );
	opt->addUsage( "--Inhibitor0" );
	opt->addUsage( "--kg1" );
	opt->addUsage( "--kg2" );
	opt->addUsage( "--kf1" );
	opt->addUsage( "--kfd" );
	opt->addUsage( "--kg3" );
	opt->addUsage( "--kgd" );
	opt->addUsage( "--kf2" );
	opt->addUsage( "--ka1" );
	opt->addUsage( "--ka2" );
	opt->addUsage( "--ki1" );
	opt->addUsage( "--kid" );
	opt->addUsage( "" );

	opt->setOption( "S0" );
	opt->setOption( "G0" );
	opt->setOption( "RhoGEF0" );
	opt->setOption( "RhoA0" );
	opt->setOption( "Inhibitor0" );
	opt->setOption( "kg1" );
	opt->setOption( "kg2" );
	opt->setOption( "kf1" );
	opt->setOption( "kfd" );
	opt->setOption( "kg3" );
	opt->setOption( "kgd" );
	opt->setOption( "kf2" );
	opt->setOption( "ka1" );
	opt->setOption( "ka2" );
	opt->setOption( "ki1" );
	opt->setOption( "kid" );
	

	opt->processCommandArgs( argc, argv );
	if( opt->getValue( "S0" ) != NULL  ){
		S0 = atof(opt->getValue( "S0" ));
	}
	if( opt->getValue( "G0" ) != NULL  ){
		G0 = atof(opt->getValue( "G0" ));
	}
	if( opt->getValue( "RhoGEF0" ) != NULL  ){
		RhoGEF0 = atof(opt->getValue( "RhoGEF0" ));
	}
	if( opt->getValue( "RhoA0" ) != NULL  ){
		RhoA0 = atof(opt->getValue( "RhoA0" ));
	}
	if( opt->getValue( "Inhibitor0" ) != NULL  ){
		Inhibitor0 = atof(opt->getValue( "Inhibitor0" ));
	}
	if( opt->getValue( "kg1" ) != NULL  ){
		kg1 = atof(opt->getValue( "kg1" ));
	}
	if( opt->getValue( "kg2" ) != NULL  ){
		kg2 = atof(opt->getValue( "kg2" ));
	}
	if( opt->getValue( "kf1" ) != NULL  ){
		kf1 = atof(opt->getValue( "kf1" ));
	}
	if( opt->getValue( "kfd" ) != NULL  ){
		kfd = atof(opt->getValue( "kfd" ));
	}
	if( opt->getValue( "kg3" ) != NULL  ){
		kg3 = atof(opt->getValue( "kg3" ));
	}
	if( opt->getValue( "kgd" ) != NULL  ){
		kgd = atof(opt->getValue( "kgd" ));
	}
	if( opt->getValue( "kf2" ) != NULL  ){
		kf2 = atof(opt->getValue( "kf2" ));
	}
	if( opt->getValue( "ka1" ) != NULL  ){
		ka1 = atof(opt->getValue( "ka1" ));
	}
	if( opt->getValue( "ka2" ) != NULL  ){
		ka2 = atof(opt->getValue( "ka2" ));
	}
	if( opt->getValue( "ki1" ) != NULL  ){
		ki1 = atof(opt->getValue( "ki1" ));
	}
	if( opt->getValue( "kid" ) != NULL  ){
		kid = atof(opt->getValue( "kid" ));
	}
	return 0;
}
开发者ID:jksr,项目名称:xu,代码行数:93,代码来源:main.cpp

示例15: main

int main (int argc, char *argv[]) {
        AnyOption opt;
        /* parse command line options */
        opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
        opt.setOption ("output", 'o');
        opt.setOption ("input", 'I');
        opt.setOption ("rand", 'r');
        opt.setOption ("verbose", 'v');
        opt.setOption ("ii", 'i');
        opt.setOption ("jj");
        opt.setOption ("xx", 'x');
        opt.setOption ("dverbose", 'd');
        opt.setOption ("rows");
        opt.setOption ("cols");
        opt.setOption ("nrestarts");
        opt.setOption ("niter");
        opt.setOption ("mdebug", 'm');
        opt.setOption ("oaconfig", 'c'); /* file that specifies the design */

        opt.addUsage ("Orthonal Array: oatest: testing platform");
        opt.addUsage ("Usage: oatest [OPTIONS] [FILE]");
        opt.addUsage ("");
        opt.addUsage (" -h --help  			Prints this help ");
        opt.processCommandArgs (argc, argv);

        double t0 = get_time_ms (), dt = 0;
        int randvalseed = opt.getIntValue ('r', 1);
        int ix = opt.getIntValue ('i', 1);
        int r = opt.getIntValue ('r', 1);
        int jj = opt.getIntValue ("jj", 5);

        int xx = opt.getIntValue ('x', 0);
        int niter = opt.getIntValue ("niter", 10);
        int verbose = opt.getIntValue ("verbose", 1);

        const char *input = opt.getValue ('I');
        if (input == 0)
                input = "test.oa";

        srand (randvalseed);
        if (randvalseed == -1) {
                randvalseed = time (NULL);
                printf ("random seed %d\n", randvalseed);
                srand (randvalseed);
        }



		array_link array = exampleArray(0);
		lmc_t lmc_type = LMCcheck(array);


		array = array.randomperm();
		array.showarray();
		array_link reduced_array = reduceLMCform(array);
		reduced_array.showarray();
		exit(0);

		try {
			array_link al = exampleArray(r);
			al.show();
			al.showarray();

			std::vector<int> sizes = array2modelmatrix_sizes(al);
			display_vector(sizes); myprintf("\n");
			MatrixFloat modelmatrix = array2modelmatrix(al, "i", 1);
			array_link modelmatrixx = modelmatrix;
			modelmatrixx.show();
			modelmatrixx.showarray();

			modelmatrix = array2modelmatrix(al, "main", 1);
			modelmatrixx = modelmatrix;
			modelmatrixx.show();
			modelmatrixx.showarray();

			exit(0);

		}
		catch (const std::exception &e) {
			std::cerr << e.what() << std::endl;
			throw;
		}

        {
                array_link al = exampleArray (r);

                array_transformation_t tt = reduceOAnauty (al);
                array_link alx = tt.apply (al);
                exit (0);
        }



        return 0;
}
开发者ID:eendebakpt,项目名称:oapackage,代码行数:95,代码来源:oatest.cpp


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