本文整理汇总了C++中OptionParser::GetErrMsg方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionParser::GetErrMsg方法的具体用法?C++ OptionParser::GetErrMsg怎么用?C++ OptionParser::GetErrMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionParser
的用法示例。
在下文中一共展示了OptionParser::GetErrMsg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
OptionParser op;
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 << " : " << OptionParser::GetErrMsg();
exit(1);
}
MyBase::SetErrMsgCB(ErrMsgCBHandler);
if (opt.help) {
Usage(op, NULL);
exit(0);
}
if (argc != 2) {
Usage(op, "Wrong number of arguments");
exit(1);
}
if ((strlen(opt.cmap) == 0) && (strlen(opt.omap) == 0)) {
Usage(op, "Wrong number of arguments");
exit(1);
}
TransferFunctionLite tf(8);
if (MyBase::GetErrCode() !=0) exit(1);
tf.setMinColorMapValue(0.0);
tf.setMaxColorMapValue(1.0);
tf.setMinOpacMapValue(0.0);
tf.setMaxOpacMapValue(1.0);
string vtffile(argv[1]);
int rc;
if (strlen(opt.cmap) != 0) {
ProcessCMAP(&tf, opt.type);
}
if (strlen(opt.omap) != 0) {
float point, o;
vector <float> pvec, ovec;
OpacityMapBase *omap = tf.getOpacityMap(0);
omap->clear();
FILE *fp = fopen(opt.omap, "r");
if (! fp) {
MyBase::SetErrMsg("fopen(%s) : %M", opt.omap);
exit(1);
}
const char *format = "%f %f";
while ((rc = fscanf(fp, format, &point, &o)) == 2) {
pvec.push_back(point);
ovec.push_back(o);
}
vector <float> tmpvec = pvec;
sort(tmpvec.begin(), tmpvec.end());
tf.setMinOpacMapValue(tmpvec[0]);
tf.setMaxOpacMapValue(tmpvec[tmpvec.size()-1]);
omap->minValue(tmpvec[0]);
omap->maxValue(tmpvec[tmpvec.size()-1]);
for (int i=0; i<pvec.size(); i++) {
// omap->addNormControlPoint(pvec[i], ovec[i]);
omap->addControlPoint(pvec[i], ovec[i]);
}
omap->minValue(0.0);
omap->maxValue(1.0);
if (ferror(fp)) {
MyBase::SetErrMsg("Error parsing file %s", opt.omap);
exit(1);
}
fclose(fp);
} // End of if omap.
//
// Write output file.
//
ofstream fileout;
fileout.open(vtffile.c_str());
if (! fileout) {
MyBase::SetErrMsg(
"Can't open file \"%s\" for writing", vtffile.c_str()
);
//.........这里部分代码省略.........
示例2: 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);
}
}
}
}
//.........这里部分代码省略.........