本文整理汇总了C++中Option::getValueExpectedFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ Option::getValueExpectedFlag方法的具体用法?C++ Option::getValueExpectedFlag怎么用?C++ Option::getValueExpectedFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::getValueExpectedFlag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOptionPred
/// HandlePrefixedOrGroupedOption - The specified argument string (which started
/// with at least one '-') does not fully match an available option. Check to
/// see if this is a prefix or grouped option. If so, split arg into output an
/// Arg/Value pair and return the Option to parse it with.
static Option *HandlePrefixedOrGroupedOption(string& Arg, string &Value,
bool &ErrorParsing,
const unordered_map<string, Option*> &OptionsMap) {
if (Arg.size() == 1) return 0;
// Do the lookup!
size_t Length = 0;
Option *PGOpt = getOptionPred(Arg, Length, isPrefixedOrGrouping, OptionsMap);
if (PGOpt == 0) return 0;
// If the option is a prefixed option, then the value is simply the
// rest of the name... so fall through to later processing, by
// setting up the argument name flags and value fields.
if (PGOpt->getFormattingFlag() == cl::Prefix) {
Value = Arg.substr(Length);
Arg = Arg.substr(0, Length);
assert(OptionsMap.count(Arg) && OptionsMap.find(Arg)->second == PGOpt);
return PGOpt;
}
// This must be a grouped option... handle them now. Grouping options can't
// have values.
assert(isGrouping(PGOpt) && "Broken getOptionPred!");
do {
// Move current arg name out of Arg into OneArgName.
string OneArgName = Arg.substr(0, Length);
Arg = Arg.substr(Length);
// Because ValueRequired is an invalid flag for grouped arguments,
// we don't need to pass argc/argv in.
assert(PGOpt->getValueExpectedFlag() != cl::ValueRequired &&
"Option can not be cl::Grouping AND cl::ValueRequired!");
int Dummy = 0;
string dummystr;
ErrorParsing |= ProvideOption(PGOpt, OneArgName,
dummystr, 0, 0, Dummy);
// Get the next grouping option.
PGOpt = getOptionPred(Arg, Length, isGrouping, OptionsMap);
} while (PGOpt && Length != Arg.size());
// Return the last option with Arg cut down to just the last one.
return PGOpt;
}
示例2: ParseCommandLineOptions
//.........这里部分代码省略.........
ArgName = argv[i]+1;
Handler = LookupOption(ArgName, Value, Opts);
// Check to see if this "option" is really a prefixed or grouped argument.
if (Handler == 0) {
std::string RealName(ArgName);
if (RealName.size() > 1) {
size_t Length = 0;
Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping,
Opts);
// If the option is a prefixed option, then the value is simply the
// rest of the name... so fall through to later processing, by
// setting up the argument name flags and value fields.
//
if (PGOpt && PGOpt->getFormattingFlag() == cl::Prefix) {
Value = ArgName+Length;
assert(Opts.find(std::string(ArgName, Value)) != Opts.end() &&
Opts.find(std::string(ArgName, Value))->second == PGOpt);
Handler = PGOpt;
} else if (PGOpt) {
// This must be a grouped option... handle them now.
assert(isGrouping(PGOpt) && "Broken getOptionPred!");
do {
// Move current arg name out of RealName into RealArgName...
std::string RealArgName(RealName.begin(),
RealName.begin() + Length);
RealName.erase(RealName.begin(), RealName.begin() + Length);
// Because ValueRequired is an invalid flag for grouped arguments,
// we don't need to pass argc/argv in...
//
assert(PGOpt->getValueExpectedFlag() != cl::ValueRequired &&
"Option can not be cl::Grouping AND cl::ValueRequired!");
int Dummy;
ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(),
0, 0, 0, Dummy);
// Get the next grouping option...
PGOpt = getOptionPred(RealName, Length, isGrouping, Opts);
} while (PGOpt && Length != RealName.size());
Handler = PGOpt; // Ate all of the options.
}
}
}
}
if (Handler == 0) {
if (SinkOpts.empty()) {
cerr << ProgramName << ": Unknown command line argument '"
<< argv[i] << "'. Try: '" << argv[0] << " --help'\n";
ErrorParsing = true;
} else {
for (std::vector<Option*>::iterator I = SinkOpts.begin(),
E = SinkOpts.end(); I != E ; ++I)
(*I)->addOccurrence(i, "", argv[i]);
}
continue;
}
// Check to see if this option accepts a comma separated list of values. If
// it does, we have to split up the value into multiple values...
if (Value && Handler->getMiscFlags() & CommaSeparated) {
std::string Val(Value);