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


C++ parseOptions函数代码示例

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


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

示例1: main

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

    config.hostip = sdsnew("127.0.0.1");
    config.hostport = 6379;
    config.hostsocket = NULL;
    config.repeat = 1;
    config.interval = 0;
    config.dbnum = 0;
    config.interactive = 0;
    config.shutdown = 0;
    config.monitor_mode = 0;
    config.pubsub_mode = 0;
    config.latency_mode = 0;
    config.stdinarg = 0;
    config.auth = NULL;
    config.raw_output = !isatty(fileno(stdout)) && (getenv("FAKETTY") == NULL);
    config.mb_delim = sdsnew("\n");
    cliInitHelp();

#ifdef _WIN32
    _fmode = _O_BINARY;
    _setmode(_fileno(stdin), _O_BINARY);
    _setmode(_fileno(stdout), _O_BINARY);
    _setmode(_fileno(stderr), _O_BINARY);

    if (!w32initWinSock()) {
      printf("Winsock init error %d", WSAGetLastError());
      exit(1);
    };

    atexit((void(*)(void)) WSACleanup);
#endif
    firstarg = parseOptions(argc,argv);
    argc -= firstarg;
    argv += firstarg;

    /* Start in latency mode if appropriate */
    if (config.latency_mode) {
        cliConnect(0);
        latencyMode();
    }

    /* Start interactive mode when no command is provided */
    if (argc == 0) {
        /* Note that in repl mode we don't abort on connection error.
         * A new attempt will be performed for every command send. */
        cliConnect(0);
        repl();
    }

    /* Otherwise, we have some arguments to execute */
    if (cliConnect(0) != REDIS_OK) exit(1);
    return noninteractive(argc,convertToSds(argc,argv));
}
开发者ID:ambakshi,项目名称:redis,代码行数:55,代码来源:redis-cli.c

示例2: initialize

bool AndroidInputServer::initialize(int argc, char* argv[]) {
	// parse arguments, daemonize, create device handlers, ready sockets

	if ( !parseOptions(argc, argv) ) {
		logger->error("Error parsing parametres");
		return false;
	}

	if ( !parseOptionsFile() ) {
		logger->error("Error in config file");
		return false;
	}

	if ( !getDefaultPaths() ) {
		logger->error("Error setting options");
		return false;
	}

	if (debug) {
		logger->printMessage("08.12.2011 16:25:02 Options parsed");
	}

	if (!semaphoresInit()) {
		logger->error("13.12.2011 21:17:54 Semaphore initialization failed");
		return false;
	}

	if ( isDaemon ) {
		if (!daemonize()) {
			logger->error("06.12.2011 01:34:59 daemonize() error");
			return false;
		}
	}

	if (isDaemon && debug) {
		logger->printMessage("06.12.2011 01:40:39 Daemonized");
	}

	if ( !readySocket(&keyboardListeningSocket, &keyboardServerAddress, keyboardListeningPort) ) {
		logger->error("08.12.2011 16:20:59 readySocket() error");
		return false;
	}

	if ( !readySocket(&mouseListeningSocket, &mouseServerAddress, mouseListeningPort) ) {
		logger->error("12.11.2012 10:00:01 readySocket() error");
		return false;
	}

	if (debug) {
		logger->printMessage("08.12.2011 16:27:10 listeningSocket bound");
	}

	return true;
}
开发者ID:AlvinCheng,项目名称:Android-Virtual-Input-for-Linux,代码行数:54,代码来源:AndroidInputServer.cpp

示例3: main

/**
 * @brief Main entry point.
 */
int main(int argc, char** argv)
{
    boost::program_options::variables_map variables;

    if (parseOptions(argc, argv, variables))
    {
        run(variables);
    }

    return 0;
}
开发者ID:HiddenDark,项目名称:freeablo,代码行数:14,代码来源:main.cpp

示例4: parseOptions

C3dsTool::EParseOptionReturn C3dsTool::parseOptions(int a_nKey, int& a_nIndex, int m_nArgc, char* a_pArgv[])
{
	for (SOption* pOption = s_Option; pOption->Name != nullptr || pOption->Key != 0 || pOption->Doc != nullptr; pOption++)
	{
		if (pOption->Key == a_nKey)
		{
			return parseOptions(pOption->Name, a_nIndex, m_nArgc, a_pArgv);
		}
	}
	return kParseOptionReturnIllegalOption;
}
开发者ID:ajd4096,项目名称:3dstool,代码行数:11,代码来源:3dstool.cpp

示例5: parseOptions

void Application::slotParseMessage(const QString &msg, QObject*)
{
    if (msg.startsWith(QLatin1String("MSG_PARSEOPTIONS:"))) {
        const int lengthOfMsgPrefix = 17;
        QStringList options = msg.mid(lengthOfMsgPrefix).split(QLatin1Char('|'));
        parseOptions(options);
        setupLogging();
    } else if (msg.startsWith(QLatin1String("MSG_SHOWSETTINGS"))) {
        showSettingsDialog();
    }
}
开发者ID:Buckeye,项目名称:client,代码行数:11,代码来源:application.cpp

示例6: parseOptions

struct hash *optionParseIntoHash(int *pArgc, char *argv[], boolean justFirst)
/* Read options in command line (only up to first real argument) into
 * options hash.   Options come in three forms:
 *      -option         words starting with dash
 *      option=val      words with = in the middle
 *      -option=val     combining the two.
 * The resulting hash will be keyed by the option name with the val
 * string for value.  For '-option' types the value is 'on'. */
{
return parseOptions(pArgc, argv, justFirst, NULL);
}
开发者ID:Puneet-Shivanand,项目名称:zinba,代码行数:11,代码来源:options.c

示例7: main

int main(int argc, char **argv) {
    char filename[kMaxStringLength];
    char targetName[kMaxStringLength];
    uint64_t targetPos;
    parseOptions(argc, argv,  filename, targetName, &targetPos);
    mafFileApi_t *mfa = maf_newMfa(filename, "r");

    searchInput(mfa, targetName, targetPos);
    maf_destroyMfa(mfa);

    return EXIT_SUCCESS;
}
开发者ID:adamnovak,项目名称:mafTools,代码行数:12,代码来源:mafPositionFinder.c

示例8: main

int main(int argc, char **argv) {
    extern const int kMaxStringLength;
    char filename[kMaxStringLength];
    parseOptions(argc, argv, filename);
    
    mafFileApi_t *mfa = maf_newMfa(filename, "r");
    processBody(mfa);

    maf_destroyMfa(mfa);

    return EXIT_SUCCESS;
}
开发者ID:sorrywm,项目名称:mafTools,代码行数:12,代码来源:mafBlockDuplicateFilter.c

示例9: main

extern int main (int __unused__ argc, char **argv)
{
    cookedArgs *args;
#ifdef VMS
    extern int getredirection (int *ac, char ***av);

    /* do wildcard expansion and I/O redirection */
    getredirection (&argc, &argv);
#endif

#ifdef AMIGA
    /* This program doesn't work when started from the Workbench */
    if (argc == 0)
	exit (1);
#endif

#ifdef __EMX__
    _wildcard (&argc, &argv);	/* expand wildcards in argument list */
#endif

#if defined (macintosh) && BUILD_MPW_TOOL == 0
    argc = ccommand (&argv);
#endif

    setCurrentDirectory ();
    setExecutableName (*argv++);
    checkRegex ();

    args = cArgNewFromArgv (argv);
    previewFirstOption (args);
    testEtagsInvocation ();
    initializeParsing ();
    initOptions ();
    readOptionConfiguration ();
    verbose ("Reading initial options from command line\n");
    parseOptions (args);
    checkOptions ();
    makeTags (args);

    /*  Clean up.
     */
    eFree (CurrentDirectory);
    cArgDelete (args);
    freeKeywordTable ();
    freeSourceFileResources ();
    freeTagFileResources ();
    freeOptionResources ();
    freeParserResources ();
    freeRegexResources ();

    exit (0);
    return 0;
}
开发者ID:att,项目名称:uwin,代码行数:53,代码来源:main.c

示例10: main

int
main(int argc, char **argv)
{
    int rc;
    int i;
    char *l;

    l = setlocale(LC_ALL, "");
    if(!l)
        ErrorF("Warning: couldn't set locale.\n");

    inputState = allocIso2022();
    if(!inputState)
        FatalError("Couldn't create input state\n");
        
    outputState = allocIso2022();
    if(!outputState)
        FatalError("Couldn't create output state\n");
    
    if(l) {
        locale_name = setlocale(LC_CTYPE, NULL);
    } else {
        locale_name = getenv("LC_ALL");
        if(locale_name == NULL) {
            locale_name = getenv("LC_CTYPE");
            if(locale_name == NULL) {
                locale_name = getenv("LANG");
            }
        }
    }

    if(locale_name == NULL) {
        ErrorF("Couldn't get locale name -- using C\n");
        locale_name = "C";
    }

    rc = initIso2022(locale_name, NULL, outputState);
    if(rc < 0)
        FatalError("Couldn't init output state\n");

    i = parseOptions(argc, argv);
    if(i < 0)
        FatalError("Couldn't parse options\n");

    rc = mergeIso2022(inputState, outputState);
    if(rc < 0)
        FatalError("Couldn't init input state\n");

    if(converter)
        return convert(0, 1);
    else
        return condom(argc - i, argv + i);
}
开发者ID:aosm,项目名称:X11,代码行数:53,代码来源:luit.c

示例11: main

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

	int n;

	assert(argc == 2);
	n = atoi(argv[1]);

	engine.solve(new NNQueens(n));

	return 0;
}
开发者ID:geoffchu,项目名称:chuffed,代码行数:12,代码来源:nn_queens.c

示例12: parseConnectConfirmTpdu

static bool
parseConnectConfirmTpdu(CotpConnection* self, uint8_t* buffer, uint8_t len)
{
    if (len < 6)
        return false;

    self->srcRef = getUint16(buffer);
    self->dstRef = getUint16(buffer + 2);
    self->protocolClass = getUint8(buffer + 4);

    return parseOptions(self, buffer + 5, len - 6);
}
开发者ID:nono19710321,项目名称:libiec61850,代码行数:12,代码来源:cotp.c

示例13: main

int main(int argc, char **argv)
{
    OptionsStruct opts; // struct for options
    int optStatus = 0; //

    // Get the parameters:
    optStatus = parseOptions(argc, argv, &opts);

    // if errors reading options then exit with non 0 status
    if (optStatus != 0)
    {
        return 1;
    }

    //open the Raspberry Pi's onboard serial port, baud rate is 115200
    //make sure that the display module has the same baud rate
    genieSetup("/dev/ttyAMA0", 115200);

    // If a value is provided send that to the display and exit
    if (strlen(opts.value) > 0)
    {
        pushToDisplay(opts, opts.value);
        // If no value provided on command line the use stdin
        // Need to fix this for non string objects
    } else {
        int continueLoop = 1;
        while (continueLoop)
        {
            char *line = NULL;
            size_t size;
            size_t chars;
            chars = getline(&line, &size, stdin);
            if (chars == -1) {
                continueLoop = 0; // get out of the loop
            } else {
                // remove the newline character
                if (line[chars - 1] == '\n')
                {
                    line[chars - 1] = '\0';
                    --chars;
                }
                // push the line to the display
                pushToDisplay(opts, line);
            }
        }
    }
    if (opts.cleanClose == 1)
    {
        genieClose();
    }
    return 0;
}
开发者ID:notrom,项目名称:visiGenieWriter-Pi,代码行数:52,代码来源:visiGenieWrite.c

示例14: main

int main(int argc, char **argv)
{
	std::set_terminate(sp_android_terminate);
	std::string packageName = "org.stappler.stappler";
	stappler::data::Value val = stappler::data::readFile("app.json");
	if (val.isDictionary()) {
		stappler::data::Value &resultObj = val.getValue("result");
		if (resultObj.isArray()) {
			stappler::data::Value &obj = resultObj.getValue(0);
			if (obj.isDictionary()) {
				std::string name = obj.getString("alias");
				if (name.empty()) {
					name = obj.getString("name");
				}
				if (!name.empty()) {
					packageName = name;
				}
			}
		}
	}

	stappler::data::Value args = parseOptions(argc, (const char **)argv);
	if (args.getInteger("width") == 0) {
		args.setInteger(1024, "width");
	}

	if (args.getInteger("height") == 0) {
		args.setInteger(768, "height");
	}

	if (args.getString("package").empty()) {
		args.setString(packageName, "package");
	}

	if (args.getString("locale").empty()) {
		args.setString("en-us", "locale");
	}

	if (args.getDouble("density") == 0.0f) {
		args.setDouble(1.0f, "density");
	}

	stappler::platform::desktop::_screenSize = cocos2d::Size(args.getInteger("width"), args.getInteger("height"));
	stappler::platform::desktop::_isTablet = args.getBool("isTablet");
	stappler::platform::desktop::_package = args.getString("package");
	stappler::platform::desktop::_density = args.getDouble("density");
	stappler::platform::desktop::_isFixed = args.getBool("fixed");
	stappler::platform::desktop::_userLanguage = args.getString("locale");

    // create the application instance
    return Application::getInstance()->run();
}
开发者ID:SBKarr,项目名称:stappler,代码行数:52,代码来源:SPMain.cpp

示例15: main

int main(int argc, char **argv) {
    extern const int kMaxStringLength;
    char seq[kMaxSeqName];
    char filename[kMaxStringLength];
    uint32_t start, stop;
    parseOptions(argc, argv, filename, seq, &start, &stop);
    mafFileApi_t *mfa = maf_newMfa(filename, "r");

    processBody(mfa, seq, start, stop);
    maf_destroyMfa(mfa);
    
    return EXIT_SUCCESS;
}
开发者ID:sorrywm,项目名称:mafTools,代码行数:13,代码来源:mafBlockExtractor.c


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