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


C++ OptionParser::setShortOptionEquivalent方法代码示例

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


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

示例1: parseOptions

Options parseOptions(int _argc, char * _argv[], Options defaults) {

    /******************************************
     *  Pass the array of argument and the name of
     *  a configuration file to the ArgumentParser
     *  object.  Then ask for the value of the argument
     *  and collect error and warnings.
     *
     *  This function returns a Options structure
     *  defined at the head of this file
     ******************************************/

    Options opt;

    /******************************************
     *  Set the allowed and required options:
     *
     *  Example of configuartion file:
     *
     ******************************************/
    vector<string> required;
    vector<string> allowed;

    opt.required.push_back("pdb");
    opt.required.push_back("type");
    opt.required.push_back("atomNames");
    opt.required.push_back("value");
    opt.allowed.push_back("outputPdb");
    //opt.allowed.push_back("outputdir");
    opt.allowed.push_back("configfile");
    opt.allowed.push_back("version"); // --version
    opt.allowed.push_back("v"); // -v is equivalent to --version
    opt.allowed.push_back("help"); // --help
    opt.allowed.push_back("h"); // -h is equivalent to --help

    opt.equivalent.push_back(vector<string>());
    opt.equivalent.back().push_back("v");
    opt.equivalent.back().push_back("version");
    opt.equivalent.push_back(vector<string>());
    opt.equivalent.back().push_back("h");
    opt.equivalent.back().push_back("help");

    opt.defaultArgs.push_back("configfile");


    //OptionParser OP(_argc, _argv);
    OptionParser OP;
    OP.setShortOptionEquivalent(opt.equivalent);
    OP.readArgv(_argc, _argv);
    OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option
    OP.setRequired(opt.required);
    OP.setAllowed(opt.allowed);
    OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile"
    if (OP.countOptions() == 0) {
        usage();
        exit(0);
    }
    opt.configfile = OP.getString("configfile");
    if (opt.configfile != "") {
        OP.readFile(opt.configfile);
        if (OP.fail()) {
            opt.errorFlag = true;
            opt.errorMessages += "Cannot read configuration file " + opt.configfile + "\n";
            exit(1);
        }
    }

    /*****************************************
     *  VERSION AND HELP
     *
     *  --version or -v arguments print the version number
     *  --help prints the usage and help
     *****************************************/
    opt.version = OP.getBool("version");
    //if (OP.fail()) {
    //	opt.version = OP.getBool("v");
    //}

    if (opt.version) {
        version();
        exit(0);
    }

    opt.help = OP.getBool("help");
//	if (OP.fail()) {
//		opt.help = OP.getBool("h");
//	}

    if (opt.help) {
        help(defaults);
        exit(0);
    }

    /*****************************************
     *  CHECK THE GIVEN OPTIONS
     *****************************************/
    if (!OP.checkOptions()) {
        opt.errorFlag = true;
        opt.OPerrors = OP.getErrors();
        return opt;
//.........这里部分代码省略.........
开发者ID:Suncuss,项目名称:mslib,代码行数:101,代码来源:setConformation.cpp

示例2: parseOptions

Options parseOptions(int _argc, char * _argv[], Options defaults) {

	/******************************************
	 *  Pass the array of argument and the name of
	 *  a configuration file to the ArgumentParser
	 *  object.  Then ask for the value of the argument
	 *  and collect error and warnings.
	 *
	 *  This function returns a Options structure
	 *  defined at the head of this file 
	 ******************************************/
	
	Options opt;

	/******************************************
	 *  Set the allowed and required options:
	 *
	 *  Example of configuartion file:
	 *  
	 ******************************************/
	vector<string> required;
	vector<string> allowed;

	opt.required.push_back("sequence");
	opt.required.push_back("startPos");
	opt.required.push_back("startRegPos");

	opt.required.push_back("r0_start");
	opt.required.push_back("r0_end");
	opt.required.push_back("r0_step");
	opt.required.push_back("r1_start");
	opt.required.push_back("r1_end");
	opt.required.push_back("r1_step");
	opt.required.push_back("w1_start");
	opt.required.push_back("w1_end");
	opt.required.push_back("w1_step");
	opt.required.push_back("phi1_start");
	opt.required.push_back("phi1_end");
	opt.required.push_back("phi1_step");
	opt.required.push_back("rpr_start");
	opt.required.push_back("rpr_end");
	opt.required.push_back("rpr_step");
	opt.required.push_back("pitch_start");
	opt.required.push_back("pitch_end");
	opt.required.push_back("pitch_step");

	opt.required.push_back("nRes");
	opt.required.push_back("symmetry");
	opt.required.push_back("N");

	//opt.required.push_back("testNo");
	opt.allowed.push_back("setState");
	opt.allowed.push_back("rotamerStates");

	opt.allowed.push_back("rotamerSamplingSize");
	opt.allowed.push_back("seed");
	opt.required.push_back("rotamerLibrary"); //filename of rotamer library file
	opt.allowed.push_back("outputdir");
	opt.allowed.push_back("outputfile"); //filename of output file
	opt.allowed.push_back("version"); // --version
	opt.allowed.push_back("v"); // -v is equivalent to --version
	opt.allowed.push_back("help"); // --help
	opt.allowed.push_back("h"); // -h is equivalent to --help
	opt.allowed.push_back("configfile");

	opt.allowed.push_back("runDEE");
	opt.allowed.push_back("runEnum");
	opt.allowed.push_back("runSCMF");
	opt.allowed.push_back("runMCO");

	opt.equivalent.push_back(vector<string>());
	opt.equivalent.back().push_back("v");
	opt.equivalent.back().push_back("version");
	opt.equivalent.push_back(vector<string>());
	opt.equivalent.back().push_back("h");
	opt.equivalent.back().push_back("help");

	opt.defaultArgs.push_back("configfile");


	//OptionParser OP(_argc, _argv);
	OptionParser OP;
	OP.setShortOptionEquivalent(opt.equivalent);
	OP.readArgv(_argc, _argv);
	OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option
	OP.setRequired(opt.required);
	OP.setAllowed(opt.allowed);
	OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile"
	if (OP.countOptions() == 0) {
		usage();
		exit(0);
	}
	opt.configfile = OP.getString("configfile");
	if (opt.configfile != "") {
		OP.readFile(opt.configfile);
		if (OP.fail()) {
			opt.errorFlag = true;
			opt.errorMessages += "Cannot read configuration file " + opt.configfile + "\n";
			exit(1);
		}
//.........这里部分代码省略.........
开发者ID:Suncuss,项目名称:mslib,代码行数:101,代码来源:coiledCoilBuilder.cpp

示例3: parseOptions

Options parseOptions(int _argc, char * _argv[], Options defaults) {

	/******************************************
	 *  Pass the array of argument and the name of
	 *  a configuration file to the ArgumentParser
	 *  object.  Then ask for the value of the argument
	 *  and collect error and warnings.
	 *
	 *  This function returns a Options structure
	 *  defined at the head of this file 
	 ******************************************/
	
	Options opt;

	/******************************************
	 *  Set the allowed and required options:
	 *
	 *  Example of configuartion file:
	 *  
	 ******************************************/
	vector<string> required;
	vector<string> allowed;

	opt.required.push_back("pdbFile");
	opt.required.push_back("helicalAxisPdbFile");
	opt.required.push_back("output");

	opt.required.push_back("xShiftStart");
	opt.required.push_back("xShiftEnd");
	opt.required.push_back("xShiftSteps");

	opt.required.push_back("zShiftAStart");
	opt.required.push_back("zShiftAEnd");
	opt.required.push_back("zShiftASteps");

	opt.required.push_back("zShiftBStart");
	opt.required.push_back("zShiftBEnd");
	opt.required.push_back("zShiftBSteps");

	opt.required.push_back("axialRotAStart");
	opt.required.push_back("axialRotAEnd");
	opt.required.push_back("axialRotASteps");

	opt.required.push_back("axialRotBStart");
	opt.required.push_back("axialRotBEnd");
	opt.required.push_back("axialRotBSteps");

	opt.required.push_back("crossingAngleStart");
	opt.required.push_back("crossingAngleEnd");
	opt.required.push_back("crossingAngleSteps");

	//opt.required.push_back("rotCount");

	opt.required.push_back("topFile");
	opt.required.push_back("parFile");
	opt.required.push_back("solvFile");
	opt.required.push_back("hBondFile");

	//opt.equivalent.push_back(vector<string>());
	//opt.equivalent.back().push_back("v");
	//opt.equivalent.back().push_back("version");
	//opt.equivalent.push_back(vector<string>());
	//opt.equivalent.back().push_back("h");
	//opt.equivalent.back().push_back("help");

	//opt.defaultArgs.push_back("configfile");


	//OptionParser OP(_argc, _argv);
	OptionParser OP;
	OP.setShortOptionEquivalent(opt.equivalent);
	OP.readArgv(_argc, _argv);
	OP.setDefaultArguments(opt.defaultArgs); // a pdb file value can be given as a default argument without the --pdbfile option
	OP.setRequired(opt.required);
	OP.setAllowed(opt.allowed);
	OP.autoExtendOptions(); // if you give option "solvat" it will be autocompleted to "solvationfile"
	if (OP.countOptions() == 0) {
		usage();
		exit(0);
	}
	opt.configfile = OP.getString("configfile");
	if (opt.configfile != "") {
		OP.readFile(opt.configfile);
		if (OP.fail()) {
			opt.errorFlag = true;
			opt.errorMessages += "Cannot read configuration file " + opt.configfile + "\n";
			exit(1);
		}
	}

	/*****************************************
	 *  VERSION AND HELP
	 *
	 *  --version or -v arguments print the version number
	 *  --help prints the usage and help
	 *****************************************/
	opt.version = OP.getBool("version");
	//if (OP.fail()) {
	//	opt.version = OP.getBool("v");
	//}
//.........这里部分代码省略.........
开发者ID:Suncuss,项目名称:mslib,代码行数:101,代码来源:genHeteroUniverse.cpp


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