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


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

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


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

示例1: Usage

void Usage(OptionParser &op, const char * msg) {

	if (msg) {
		cerr << ProgName << " : " << msg << endl;
	}
	cerr << "Usage: " << ProgName << " [options] (-cmap cmap.txt | -omap omap.txt) file.vtf" << endl;
	op.PrintOptionHelp(stderr);

}
开发者ID:yyr,项目名称:vapor,代码行数:9,代码来源:asciitf2vtf.cpp

示例2: metadata

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

	OptionParser op;
	FILE	*fp;
	const char	*metafile;
	const char	*datafile;

	float	timer = 0.0;
	float	read_timer = 0.0;
	float	write_timer = 0.0;
	float	xform_timer = 0.0;
	string	s;

	MyBase::SetErrMsgCB(ErrMsgCBHandler);

	//
	// Parse command line arguments
	//
	ProgName = Basename(argv[0]);

	if (op.AppendOptions(set_opts) < 0) {
		exit(1);
	}

	if (op.ParseOptions(&argc, argv, get_options) < 0) {
		exit(1);
	}

	if (opt.help) {
		cerr << "Usage: " << ProgName << " [options] vdfFile outputFile" << endl;
		op.PrintOptionHelp(stderr);
		exit(0);
	}

	if (argc != 3) {
		cerr << "Usage: " << ProgName << " [options] vdfFile dataFile" << endl;
		op.PrintOptionHelp(stderr);
		exit(1);
	}

	metafile = argv[1];	// Path to a vdf file
	datafile = argv[2];	// Path to raw data file 

    if (opt.debug) MyBase::SetDiagMsgFilePtr(stderr);

	WaveletBlockIOBase	*wbwriter3D = NULL;
	WaveCodecIO	*wcwriter = NULL;
	VDFIOBase *vdfio = NULL;

	size_t min[3] = {opt.xregion.min, opt.yregion.min, opt.zregion.min};
	size_t max[3] = {opt.xregion.max, opt.yregion.max, opt.zregion.max};

	// Determine if variable is 3D
	//
	MetadataVDC metadata (metafile);
	if (MetadataVDC::GetErrCode() != 0) {
		MyBase::SetErrMsg("Error processing metafile \"%s\"", metafile);
		exit(1);
	}
	Metadata::VarType_T vtype = metadata.GetVarType(opt.varname);
	if (vtype == Metadata::VARUNKNOWN) {
		MyBase::SetErrMsg("Unknown variable \"%s\"", opt.varname);
		exit(1);
	}

	
	bool vdc1 = (metadata.GetVDCType() == 1);
	if (vdc1) {

		// Create an appropriate WaveletBlock writer. 
		//
		if (min[0] == min[1] && min[1] == min[2] && min[2] == max[0] &&
			max[0] == max[1]  && max[1] == max[2] && max[2] == (size_t) -1 &&
			vtype == Metadata::VAR3D) {

			wbwriter3D = new WaveletBlock3DBufWriter(metadata);
		}
		else {
			wbwriter3D = new WaveletBlock3DRegionWriter(metadata);
		}
		vdfio = wbwriter3D;
	} 
	else {
		wcwriter = new WaveCodecIO(metadata, opt.nthreads);
		vdfio = wcwriter;
	}
	if (vdfio->GetErrCode() != 0) {
		exit(1);
	}

	fp = FOPEN64(datafile, "rb");
	if (! fp) {
		MyBase::SetErrMsg("Could not open file \"%s\" : %M", datafile);
		exit(1);
	}


	double t0 = GetTime();

	if (min[0] == min[1] && min[1] == min[2] && min[2] == max[0] &&
//.........这里部分代码省略.........
开发者ID:yyr,项目名称:vapor,代码行数:101,代码来源:raw2vdf.cpp

示例3: if

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

	OptionParser op;
	const char	*metafile;

	string	s;

	MyBase::SetErrMsgCB(ErrMsgCB);

	ProgName = Basename(argv[0]);

	if (op.AppendOptions(set_opts) < 0) {
		cerr << ProgName << " : " << op.GetErrMsg();
		exit(1);
	}

	if (op.ParseOptions(&argc, argv, get_options) < 0) {
		cerr << ProgName << " : " << op.GetErrMsg();
		exit(1);
	}

	if (opt.help) {
		cerr << "Usage: " << ProgName << " [options] metafile datafile" << endl;
		op.PrintOptionHelp(stderr);
		exit(0);
	}

	if (argc != 2) {
		cerr << "Usage: " << ProgName << " [options] metafile " << endl;
		op.PrintOptionHelp(stderr);
		exit(1);
	}

	metafile = argv[1];
	map <long, map <string, VarFileInfo > > statsvec;


	const MetadataVDC *metadata = new MetadataVDC(metafile);
	if (MyBase::GetErrCode() != 0) exit(1);

	if (getStats(metadata, statsvec) < 0) {
		exit(1);
	}
	

	string sort = opt.sort;

	int numApproximations;
	if (metadata->GetVDCType() == 2) {
		if (opt.level < 0) numApproximations = metadata->GetCRatios().size();
		else numApproximations = opt.level+1;
	} else {
		if (opt.level < 0) numApproximations = metadata->GetNumTransforms()+1;
		else numApproximations = opt.level+1;
	}

	if (sort.compare("time") == 0) {
		map <long, map <string, VarFileInfo > >::iterator iter1;
		for (iter1 = statsvec.begin(); iter1 != statsvec.end(); iter1++) {
			map <string, VarFileInfo>::iterator iter2;

			for (iter2 = iter1->second.begin(); iter2 != iter1->second.end(); iter2++) {
				const VarFileInfo &vfiref = iter2->second;

				for(int j=0; j<numApproximations; j++) {
					PrintVariable(metadata,vfiref, j);
				}
			}
		}
	}
	else if (sort.compare("level") == 0) {
		for (int j=0; j<numApproximations; j++) {
			map <long, map <string, VarFileInfo > >::iterator iter1;
			for (iter1 = statsvec.begin(); iter1 != statsvec.end(); iter1++) {
				map <string, VarFileInfo>::iterator iter2;

				for (iter2 = iter1->second.begin(); iter2 != iter1->second.end(); iter2++) {
					const VarFileInfo &vfiref = iter2->second;

					PrintVariable(metadata,vfiref, j);
				}
			}
		}
	}
	else if (sort.compare("varname") == 0) {
		const vector <string> varNames = metadata->GetVariableNames();
		vector <string>::const_iterator iter1;
		for (iter1=varNames.begin(); iter1 != varNames.end(); iter1++) {
		
			for (int j=0; j<numApproximations; j++) {
				map <long, map <string, VarFileInfo > >::iterator iter2;
				for (iter2 = statsvec.begin(); iter2 != statsvec.end(); iter2++) {

					const VarFileInfo &vfiref = iter2->second[*iter1];;

					PrintVariable(metadata,vfiref, j);
				}
			}
		}
	}
//.........这里部分代码省略.........
开发者ID:yyr,项目名称:vapor,代码行数:101,代码来源:vdfls.cpp


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