本文整理汇总了C++中Option::hasArgStr方法的典型用法代码示例。如果您正苦于以下问题:C++ Option::hasArgStr方法的具体用法?C++ Option::hasArgStr怎么用?C++ Option::hasArgStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::hasArgStr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOptionWidth
// Return the width of the option tag for printing...
size_t generic_parser_base::getOptionWidth(const Option &O) const {
if (O.hasArgStr()) {
size_t Size = std::strlen(O.ArgStr)+6;
for (unsigned i = 0, e = getNumOptions(); i != e; ++i)
Size = std::max(Size, std::strlen(getOption(i))+8);
return Size;
} else {
size_t BaseSize = 0;
for (unsigned i = 0, e = getNumOptions(); i != e; ++i)
BaseSize = std::max(BaseSize, std::strlen(getOption(i))+8);
return BaseSize;
}
}
示例2: printOptionInfo
// printOptionInfo - Print out information about this option. The
// to-be-maintained width is specified.
//
void generic_parser_base::printOptionInfo(const Option &O,
size_t GlobalWidth) const {
if (O.hasArgStr()) {
size_t L = std::strlen(O.ArgStr);
cout << " -" << O.ArgStr;
cout << string(GlobalWidth-L-6,' ') << " - " << O.HelpStr << '\n';
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
size_t NumSpaces = GlobalWidth-strlen(getOption(i))-8;
cout << " =" << getOption(i);
cout << string(NumSpaces,' ') << " - " << getDescription(i) << '\n';
}
} else {
if (O.HelpStr[0])
cout << " " << O.HelpStr << '\n';
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
size_t L = std::strlen(getOption(i));
cout << " -" << getOption(i);
cout << string(GlobalWidth-L-8,' ') << " - " << getDescription(i) << '\n';
}
}
}