• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parseCommandLine函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parseCommandLine函数的典型用法代码示例。如果您正苦于以下问题:C++ parseCommandLine函数的具体用法?C++ parseCommandLine怎么用?C++ parseCommandLine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: request

void RPCExecutor::request(const QString &command)
{
    std::vector<std::string> args;
    if(!parseCommandLine(args, command.toStdString()))
    {
        emit reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
        return;
    }
    if(args.empty())
        return; // Nothing to do
    try
    {
        std::string strPrint;
        // Convert argument list to JSON objects in method-dependent way,
        // and pass it along with the method name to the dispatcher.
        json_spirit::Value result = tableRPC.execute(
            args[0],
            RPCConvertValues(args[0], std::vector<std::string>(args.begin() + 1, args.end())));

        // Format result reply
        if (result.type() == json_spirit::null_type)
            strPrint = "";
        else if (result.type() == json_spirit::str_type)
            strPrint = result.get_str();
        else
            strPrint = write_string(result, true);

        emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
    }
    catch (json_spirit::Object& objError)
    {
        try // Nice formatting for standard-format error
        {
            int code = find_value(objError, "code").get_int();
            std::string message = find_value(objError, "message").get_str();
            emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")");
        }
        catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message
        {   // Show raw JSON object
            emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false)));
        }
    }
    catch (std::exception& e)
    {
        emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
    }
}
开发者ID:JeduRockzz,项目名称:arpacoin,代码行数:47,代码来源:rpcconsole.cpp


示例2: main

int main (int argc, const char **argv)
{

    gSymbolList = (const char**)calloc (MAX_SUBSCRIPTIONS, sizeof (char*));

    parseCommandLine (argc, argv);

    if (!gNumSymbols)
        gSymbolList[gNumSymbols++] = "MAMA_TOPIC";

    initializeMama ();
    createPublisher ();
    subscribeToSymbols ();
    start();

    return 0;
}
开发者ID:MattMulhern,项目名称:OpenMamaCassandra,代码行数:17,代码来源:mamaproxyc.c


示例3: main

int main(int argc, char* argv[])
{
    parseCommandLine(argc,argv);
    NarrowBand nb(filename);
    nb.build3Dgrid(prec);
    nb.expandGrid(expand);
    nb.writeGridToFile();
    nb.computeDistanceFunction();
    nb.writeDtoFile();
    nb.computeGradient();
    nb.writeDDtoFile();
    nb.computeInitialSurface();
    nb.writeUtoFile();
    nb.evolve(iter,deltaT);

    return 0;
}
开发者ID:schizzz8,项目名称:narrow_band,代码行数:17,代码来源:main.cpp


示例4: parseCommandLine

  static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
  {
    while (true)
    {
      std::string tag = cin->getString();
      if (tag == "") return;

      /* parse command line parameters from a file */
      if (tag == "-c") {
        FileName file = path + cin->getFileName();
        parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
      }

      /* parse camera parameters */
      else if (tag == "-vp") g_camera.from = cin->getVec3fa();
      else if (tag == "-vi") g_camera.to = cin->getVec3fa();
      else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
      else if (tag == "-vu") g_camera.up = cin->getVec3fa();
      else if (tag == "-fov") g_camera.fov = cin->getFloat();

      /* frame buffer size */
      else if (tag == "-size") {
        g_width = cin->getInt();
        g_height = cin->getInt();
      }

      /* full screen mode */
      else if (tag == "-fullscreen") 
        g_fullscreen = true;
      
      /* rtcore configuration */
      else if (tag == "-rtcore")
        g_rtcore = cin->getString();

      /* number of threads to use */
      else if (tag == "-threads")
        g_numThreads = cin->getInt();

      /* skip unknown command line parameter */
      else {
        std::cerr << "unknown command line parameter: " << tag << " ";
        while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " ";
        std::cerr << std::endl;
      }
    }
  }
开发者ID:cpaalman,项目名称:embree,代码行数:46,代码来源:tutorial05.cpp


示例5: TEST_F

TEST_F(TestApplication, can_parse_command_line_expected_query) {
    // Arrange
    constexpr int argc = 3;
    constexpr const char* argv[argc] = {
        "somepath_to_binary",
        "-q",
        "Name1,Name2"
    };
    Parameters expected;
    expected.query = "Name1,Name2";

    // Act
    const auto result = parseCommandLine(argc, argv);

    // Assert
    EXPECT_EQ(expected.query, result.query);
}
开发者ID:dabelyaeva,项目名称:devtools-course-practice,代码行数:17,代码来源:test_application.cpp


示例6: main

 void main(int argc, char **argv) 
 {
   /*! parse command line options */
   parseCommandLine(argc, argv);
   
   /*! bind to a port */
   network::socket_t socket = network::bind(g_port);
   
   /*! handle incoming connections */
   do {
     std::cout << std::endl << "listening for connections on port " << g_port << " ... " << std::flush;
     network::socket_t client = network::listen(socket);
     std::cout << "  [CONNECTED]" << std::endl;
     new NetworkServer(client,Device::rtCreateDevice(g_device_type.c_str(), g_threads),g_encoding,g_verbose);
   } 
   while (g_multiple_connections);
 }
开发者ID:PetrVevoda,项目名称:smallupbp,代码行数:17,代码来源:network_server_main.cpp


示例7: main

int main(int argc, const char* argv[])
{
    mamaCaptureConfig mCapture = NULL;
    mamaCaptureList mCaptureList     = NULL;
    mamaCaptureConfig_create (&mCapture);

    if (mCapture == NULL)
    {
        mama_log (MAMA_LOG_LEVEL_NORMAL,
                  "Allocation of memory for capture failed!!!!");
        exit (1);
    }

    gCapture  = &mCapture;
    parseCommandLine (mCapture , &mCaptureList, argc, argv);

    /*Set up a signal handler so that we don't
      just stop without cleaning up*/
    gCaptureList = &mCaptureList;
    initializeMama (mCapture);

    mamaCaptureList_parseCommandInput (mCapture,
                                       mCaptureList, gSource);
    mamaCapture_openFile (&mCapture->myCapture,
                       mCapture->myCaptureFilename);


    buildDataDictionary(mCapture);
    dumpDataDictionary (mCapture);

    if (mCapture->myDumpList)
    {
        dumpList (mCaptureList);
    }
    subscribeToSymbols (mCapture,mCaptureList);

    mama_logStdout (MAMA_LOG_LEVEL_NORMAL, "Type CTRL-C to exit.\n\n");

    mama_start (mCapture->myBridge);

    mamaCapture_closeFile(mCapture->myCapture);
    msshutdown (mCapture,mCaptureList);

    return 0;
}
开发者ID:MattMulhern,项目名称:OpenMamaCassandra,代码行数:45,代码来源:capturec.c


示例8: main

int
main(int argc, char **argv) {

    struct cmdlineInfo cmdline;
    struct pam pam;
    int row;
    double normalizer;
    tuplen * tuplerown;
    
    pnm_init(&argc, argv);
   
    parseCommandLine(argc, argv, &cmdline);

    pam.size        = sizeof(pam);
    pam.len         = PAM_STRUCT_SIZE(tuple_type);
    pam.file        = stdout;
    pam.format      = PAM_FORMAT;
    pam.plainformat = 0;
    pam.width       = cmdline.width;
    pam.height      = cmdline.height;
    pam.depth       = 1;
    pam.maxval      = cmdline.maxval;
    strcpy(pam.tuple_type, cmdline.tupletype);

    normalizer = imageNormalizer(&pam, cmdline.sigma);
    
    pnm_writepaminit(&pam);
   
    tuplerown = pnm_allocpamrown(&pam);

    for (row = 0; row < pam.height; ++row) {
        int col;
        for (col = 0; col < pam.width; ++col) {
            double const gauss1 = gauss(distFromCenter(&pam, col, row),
                                        cmdline.sigma);

            tuplerown[col][0] = gauss1 * normalizer;
        }
        pnm_writepamrown(&pam, tuplerown);
    }
    
    pnm_freepamrown(tuplerown);

    return 0;
}
开发者ID:ownclo,项目名称:jpeg-on-steroids,代码行数:45,代码来源:pamgauss.c


示例9: readCommandFile

void
readCommandFile(
    char *name
    )
{
    char *s,                        // buffer
         **vector;                  // local versions of arg vector
    unsigned count = 0;             // count
    size_t n;

    if (!(file = FILEOPEN(name,"rt")))
        makeError(0,CANT_OPEN_FILE,name);
    vector = NULL;                      // no args yet
    while (fgets(buf,MAXBUF,file)) {
        n = _tcslen(buf);

        // if we didn't get the whole line, OR the line ended with a backSlash

        if ((n == MAXBUF-1 && buf[n-1] != '\n') ||
            (buf[n-1] == '\n' && buf[n-2] == '\\')
           ) {
            if (buf[n-2] == '\\' && buf[n-1] == '\n') {
                // Replace \n by \0 and \\ by a space; Also reset length
                buf[n-1] = '\0';
                buf[n-2] = ' ';
                n--;
            }
            s = makeString(buf);
            getRestOfLine(&s,&n);
        } else
            s = buf;

        processLine(s,&count,&vector);  // separate into args
        if (s != buf)
            FREE(s);
    }

    if (fclose(file) == EOF)
        makeError(0, ERROR_CLOSING_FILE, name);

    parseCommandLine(count,vector);     // evaluate the args
    while (count--)                     // free the arg vector
        if(vector[count])
            FREE(vector[count]);        // NULL entries mean that the space the
}                                       //  entry used to pt to is still in use
开发者ID:ArildF,项目名称:masters,代码行数:45,代码来源:command.cpp


示例10: main

int
main(int argc, char **argv)
{
    struct cmdlineInfo cmdline;
    struct pam outpam;
    int * jasperCmpt;  /* malloc'ed */
       /* jaspercmpt[P] is the component number for use with the
          Jasper library that corresponds to Plane P of the PAM.  
       */
    jas_image_t * jasperP;

    pnm_init(&argc, argv);
    
    parseCommandLine(argc, argv, &cmdline);
    
    { 
        int rc;
        
        rc = jas_init();
        if ( rc != 0 )
            pm_error("Failed to initialize Jasper library.  "
                     "jas_init() returns rc %d", rc );
    }
    
    jas_setdbglevel(cmdline.debuglevel);
    
    readJpc(cmdline.inputFilename, &jasperP);

    outpam.file = stdout;
    outpam.size = sizeof(outpam);
    outpam.len  = PAM_STRUCT_SIZE(tuple_type);

    computeOutputParm(jasperP, &outpam, &jasperCmpt);

    pnm_writepaminit(&outpam);
    
    convertToPamPnm(&outpam, jasperP, jasperCmpt);
    
    free(jasperCmpt);
	jas_image_destroy(jasperP);

    pm_close(stdout);
    
    return 0;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:45,代码来源:jpeg2ktopam.c


示例11: QApplication

AppDelegate::AppDelegate(int argc, char* argv[]) :
    QApplication(argc, argv),
    _qtReady(false),
    _dsReady(false),
    _dsResourcesReady(false),
    _acReady(false),
    _domainServerProcess(NULL),
    _acMonitorProcess(NULL),
    _domainServerName("localhost")
{
    // be a signal handler for SIGTERM so we can stop child processes if we get it
    signal(SIGTERM, signalHandler);

    // look for command-line options
    parseCommandLine();

    setApplicationName("Stack Manager");
    setOrganizationName("High Fidelity");
    setOrganizationDomain("io.highfidelity.StackManager");

    QFile* logFile = new QFile("last_run_log", this);
    if (!logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
        qDebug() << "Failed to open log file. Will not be able to write STDOUT/STDERR to file.";
    } else {
        outStream = new QTextStream(logFile);
    }


    qInstallMessageHandler(myMessageHandler);
    _domainServerProcess = new BackgroundProcess(GlobalData::getInstance().getDomainServerExecutablePath(), this);
    _acMonitorProcess = new BackgroundProcess(GlobalData::getInstance().getAssignmentClientExecutablePath(), this);

    _manager = new QNetworkAccessManager(this);

    _window = new MainWindow();

    createExecutablePath();
    downloadLatestExecutablesAndRequirements();

    _checkVersionTimer.setInterval(0);
    connect(&_checkVersionTimer, SIGNAL(timeout()), this, SLOT(checkVersion()));
    _checkVersionTimer.start();

    connect(this, &QApplication::aboutToQuit, this, &AppDelegate::stopStack);
}
开发者ID:Atlante45,项目名称:StackManagerQt,代码行数:45,代码来源:AppDelegate.cpp


示例12: main

int main( int argc, const char *argv[] )
{
   std::string path;
   Json::Features features;
   bool parseOnly;
   int exitCode = parseCommandLine( argc, argv, features, path, parseOnly );
   if ( exitCode != 0 )
   {
      return exitCode;
   }

   std::string input = readInputTestFile( path.c_str() );
   if ( input.empty() )
   {
      printf( "Failed to read input or empty input: %s\n", path.c_str() );
      return 3;
   }

   std::string basePath = removeSuffix( argv[1], ".json" );
   if ( !parseOnly  &&  basePath.empty() )
   {
      printf( "Bad input path. Path does not end with '.expected':\n%s\n", path.c_str() );
      return 3;
   }

   std::string actualPath = basePath + ".actual";
   std::string rewritePath = basePath + ".rewrite";
   std::string rewriteActualPath = basePath + ".actual-rewrite";

   Json::Value root;
   exitCode = parseAndSaveValueTree( input, actualPath, "input", root, features, parseOnly );
   if ( exitCode == 0  &&  !parseOnly )
   {
      std::string rewrite;
      exitCode = rewriteValueTree( rewritePath, root, rewrite );
      if ( exitCode == 0 )
      {
         Json::Value rewriteRoot;
         exitCode = parseAndSaveValueTree( rewrite, rewriteActualPath, 
            "rewrite", rewriteRoot, features, parseOnly );
      }
   }

   return exitCode;
}
开发者ID:tuita,项目名称:DOMQ,代码行数:45,代码来源:main.cpp


示例13: main

int main(int argc, char **argv) {
    try {
        std::vector<Common::UString> args;
        Common::Platform::getParameters(argc, argv, args);

        int returnValue = 1;
        Common::UString inFile, outFile;

        if (!parseCommandLine(args, returnValue, inFile, outFile))
            return returnValue;

        desmall(inFile, outFile);
    } catch (...) {
        Common::exceptionDispatcherError();
    }

    return 0;
}
开发者ID:idkwim,项目名称:xoreos-tools,代码行数:18,代码来源:desmall.cpp


示例14: main

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

    struct cmdlineInfo cmdline;
    FILE * ifP;
    xelval lmin, lmax;
    gray * lumamap;           /* Luminosity map */
    unsigned int * lumahist;  /* Histogram of luminosity values */
    int rows, cols;           /* Rows, columns of input image */
    xelval maxval;            /* Maxval of input image */
    int format;               /* Format indicator (PBM/PGM/PPM) */
    xel ** xels;              /* Pixel array */
    unsigned int pixelCount;

    pnm_init(&argc, argv);

    parseCommandLine(argc, argv, &cmdline);

    ifP = pm_openr(cmdline.inputFileName);

    xels = pnm_readpnm(ifP, &cols, &rows, &maxval, &format);

    pm_close(ifP);

    computeLuminosityHistogram(xels, rows, cols, maxval, format,
                               cmdline.gray, &lumahist, &lmin, &lmax,
                               &pixelCount);

    getMapping(cmdline.rmap, lumahist, maxval, pixelCount, &lumamap);

    if (cmdline.verbose)
        reportMap(lumahist, maxval, lumamap);

    remap(xels, cols, rows, maxval, format, !!cmdline.gray, lumamap);

    pnm_writepnm(stdout, xels, cols, rows, maxval, format, 0);

    if (cmdline.wmap)
        writeMap(cmdline.wmap, lumamap, maxval);

    pgm_freerow(lumamap);

    return 0;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:44,代码来源:pnmhisteq.c


示例15: main

int 
main(int argc, char ** argv) {

    struct cmdlineInfo cmdline;

    MS_Ico const MSIconDataP = createIconFile();
    unsigned int iconIndex;
    unsigned int offset;
   
    ppm_init (&argc, argv);

    parseCommandLine(argc, argv, &cmdline);

    verbose = cmdline.verbose;

    for (iconIndex = 0; iconIndex < cmdline.iconCount; ++iconIndex) {
        addEntryToIcon(MSIconDataP, cmdline.inputFilespec[iconIndex],
                       cmdline.andpgmFilespec[iconIndex], 
                       cmdline.truetransparent);
    }
    /*
     * Now we have to go through and calculate the offsets.
     * The first infoheader starts at 6 + count*16 bytes.
     */
    offset = (MSIconDataP->count * 16) + 6;
    for (iconIndex = 0; iconIndex < MSIconDataP->count; ++iconIndex) {
        IC_Entry entry = MSIconDataP->entries[iconIndex];
        entry->file_offset = offset;
        /* 
         * Increase the offset by the size of this offset & data.
         * this includes the size of the color data.
         */
        offset += entry->size_in_bytes;
    }
    /*
     * And now, we have to actually SAVE the .ico!
     */
    writeMS_Ico(MSIconDataP, cmdline.output);

    free(cmdline.inputFilespec);
    free(cmdline.andpgmFilespec);

    return 0;
}
开发者ID:cjd8363,项目名称:Global-Illum,代码行数:44,代码来源:ppmtowinicon.c


示例16: main

int main( int argc, char **argv ){
	string pathStr;
	gProgramName = argv[0];

	parseCommandLine( argc, argv );
	argc -= optind;
	argv += optind;
	if( gTheScene->hasInputSceneFilePath( ) &&
			gTheScene->hasOutputFilePath( ) &&
			gTheScene->hasDepthFilePath( ) ){
		gTheScene->parse( );	
		cout << *gTheScene << endl;	
	}else{
		usage( "You specify an input scene file, an output file and a depth file." );
	}


	return( 0 );
}
开发者ID:HandOfCthulhu,项目名称:CS566SampleCode,代码行数:19,代码来源:raytrace.cpp


示例17: parseCommandLine

bool Main::parseOptions(int argc, char** argv) {
  // Reprint command line
  for (int i=0; i<argc; ++i)
    cout << argv[i] << ' ';
  cout << endl;
  // parse command line
  ProgramOptions* opt = parseCommandLine(argc, argv);
  if (!opt) {
    err_txt("Error parsing command line.");
    return false;
  }

  if (opt->seed == NONE)
    opt->seed = time(0);
  rand::seed(opt->seed);

  m_options.reset(opt);
  return true;
}
开发者ID:joergkappes,项目名称:daoopt,代码行数:19,代码来源:Main.cpp


示例18: main

  /* main function in embree namespace */
  int main(int argc, char** argv) 
  {
    /* create stream for parsing */
    Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));

    /* parse command line */  
    parseCommandLine(stream, FileName());
    if (g_numThreads) 
      g_rtcore += ",threads=" + std::stringOf(g_numThreads);
    if (g_numBenchmarkFrames)
      g_rtcore += ",benchmark=1";

    /* initialize task scheduler */
#if !defined(__EXPORT_ALL_SYMBOLS__)
    TaskScheduler::create(g_numThreads);
#endif

    /* load scene */
    if (filename.str() != "")
      loadOBJ(filename,one,g_obj_scene);

    /* initialize ray tracing core */
    init(g_rtcore.c_str());

    /* send model */
    set_scene(&g_obj_scene);
    
    /* benchmark mode */
    if (g_numBenchmarkFrames)
      renderBenchmark(outFilename);
    
    /* render to disk */
    if (outFilename.str() != "")
      renderToFile(outFilename);
    
    /* interactive mode */
    if (g_interactive) {
      initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen);
      enterWindowRunLoop();
    }

    return 0;
  }
开发者ID:D-POWER,项目名称:embree,代码行数:44,代码来源:tutorial03.cpp


示例19: main

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

    struct cmdlineInfo cmdline;
    FILE * ifP;
    int format;
    struct pam colormapPam;
    struct pam outpam;
    tuple ** colormapRaster;
    tupletable2 colormap;

    pnm_init(&argc, argv);

    parseCommandLine(argc, argv, &cmdline);

    ifP = pm_openr(cmdline.inputFilespec);

    computeColorMapFromInput(ifP,
                             cmdline.allcolors, cmdline.newcolors, 
                             cmdline.methodForLargest, 
                             cmdline.methodForRep,
                             &format, &colormapPam, &colormap);

    pm_close(ifP);

    colormapToImage(format, &colormapPam, colormap,
                    cmdline.sort, cmdline.square, &outpam, &colormapRaster);

    if (cmdline.verbose)
        pm_message("Generating %u x %u image", outpam.width, outpam.height);

    outpam.file = stdout;
    
    pnm_writepam(&outpam, colormapRaster);
    
    pnm_freetupletable2(&colormapPam, colormap);

    pnm_freepamarray(colormapRaster, &outpam);

    pm_close(stdout);

    return 0;
}
开发者ID:chneukirchen,项目名称:netpbm-mirror,代码行数:43,代码来源:pnmcolormap.c


示例20: main

int main(int argc, char **argv) {
    std::vector<Common::UString> args;
    Common::Platform::getParameters(argc, argv, args);

    int returnValue = 1;
    Common::UString nbfsFile, nbfpFile, outFile;
    uint32 width = 0xFFFFFFFF, height = 0xFFFFFFFF;

    try {
        if (!parseCommandLine(args, returnValue, nbfsFile, nbfpFile, outFile, width, height))
            return returnValue;

        convert(nbfsFile, nbfpFile, outFile, width, height);
    } catch (...) {
        Common::exceptionDispatcherError();
    }

    return 0;
}
开发者ID:Terentyev,项目名称:xoreos-tools,代码行数:19,代码来源:nbfs2tga.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parseExpression函数代码示例发布时间:2022-05-30
下一篇:
C++ parseCommand函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap