本文整理汇总了C++中Option::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Option::isValid方法的具体用法?C++ Option::isValid怎么用?C++ Option::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::isValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matches
bool Option::matches(OptSpecifier Opt) const {
// Aliases are never considered in matching, look through them.
const Option Alias = getAlias();
if (Alias.isValid())
return Alias.matches(Opt);
// Check exact match.
if (getID() == Opt.getID())
return true;
const Option Group = getGroup();
if (Group.isValid())
return Group.matches(Opt);
return false;
}
示例2: print
void Option::print(raw_ostream &O) const {
O << "<";
switch (getKind()) {
#define P(N) case N: O << #N; break
P(GroupClass);
P(InputClass);
P(UnknownClass);
P(FlagClass);
P(JoinedClass);
P(ValuesClass);
P(SeparateClass);
P(CommaJoinedClass);
P(MultiArgClass);
P(JoinedOrSeparateClass);
P(JoinedAndSeparateClass);
P(RemainingArgsClass);
P(RemainingArgsJoinedClass);
#undef P
}
if (Info->Prefixes) {
O << " Prefixes:[";
for (const char *const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
O << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
}
O << ']';
}
O << " Name:\"" << getName() << '"';
const Option Group = getGroup();
if (Group.isValid()) {
O << " Group:";
Group.print(O);
}
const Option Alias = getAlias();
if (Alias.isValid()) {
O << " Alias:";
Alias.print(O);
}
if (getKind() == MultiArgClass)
O << " NumArgs:" << getNumArgs();
O << ">\n";
}
示例3: dump
void Option::dump() const {
llvm::errs() << "<";
switch (getKind()) {
#define P(N) case N: llvm::errs() << #N; break
P(GroupClass);
P(InputClass);
P(UnknownClass);
P(FlagClass);
P(JoinedClass);
P(SeparateClass);
P(CommaJoinedClass);
P(MultiArgClass);
P(JoinedOrSeparateClass);
P(JoinedAndSeparateClass);
#undef P
}
if (Info->Prefixes) {
llvm::errs() << " Prefixes:[";
for (const char * const *Pre = Info->Prefixes; *Pre != 0; ++Pre) {
llvm::errs() << '"' << *Pre << (*(Pre + 1) == 0 ? "\"" : "\", ");
}
llvm::errs() << ']';
}
llvm::errs() << " Name:\"" << getName() << '"';
const Option Group = getGroup();
if (Group.isValid()) {
llvm::errs() << " Group:";
Group.dump();
}
const Option Alias = getAlias();
if (Alias.isValid()) {
llvm::errs() << " Alias:";
Alias.dump();
}
if (getKind() == MultiArgClass)
llvm::errs() << " NumArgs:" << getNumArgs();
llvm::errs() << ">\n";
}
示例4: append
void ArgList::append(Arg *A) {
Args.push_back(A);
// Update ranges for the option and all of its groups.
for (Option O = A->getOption().getUnaliasedOption(); O.isValid();
O = O.getGroup()) {
auto &R =
OptRanges.insert(std::make_pair(O.getID(), emptyRange())).first->second;
R.first = std::min<unsigned>(R.first, Args.size() - 1);
R.second = Args.size();
}
}
示例5: PrintHelp
void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
unsigned FlagsToInclude, unsigned FlagsToExclude,
bool ShowAllAliases) const {
OS << "OVERVIEW: " << Title << "\n";
OS << '\n';
OS << "USAGE: " << Name << " [options] <inputs>\n";
OS << '\n';
// Render help text into a map of group-name to a list of (option, help)
// pairs.
using helpmap_ty = std::map<std::string, std::vector<OptionInfo>>;
helpmap_ty GroupedOptionHelp;
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned Id = i + 1;
// FIXME: Split out option groups.
if (getOptionKind(Id) == Option::GroupClass)
continue;
unsigned Flags = getInfo(Id).Flags;
if (FlagsToInclude && !(Flags & FlagsToInclude))
continue;
if (Flags & FlagsToExclude)
continue;
// If an alias doesn't have a help text, show a help text for the aliased
// option instead.
const char *HelpText = getOptionHelpText(Id);
if (!HelpText && ShowAllAliases) {
const Option Alias = getOption(Id).getAlias();
if (Alias.isValid())
HelpText = getOptionHelpText(Alias.getID());
}
if (HelpText) {
const char *HelpGroup = getOptionHelpGroup(*this, Id);
const std::string &OptName = getOptionHelpName(*this, Id);
GroupedOptionHelp[HelpGroup].push_back({OptName, HelpText});
}
}
for (helpmap_ty::iterator it = GroupedOptionHelp .begin(),
ie = GroupedOptionHelp.end(); it != ie; ++it) {
if (it != GroupedOptionHelp .begin())
OS << "\n";
PrintHelpOptionList(OS, it->first, it->second);
}
OS.flush();
}