mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Occurrence' has no
a' and the `r' is doubled.
llvm-svn: 7140
This commit is contained in:
parent
6b2cd003d4
commit
14194dcdae
@ -34,7 +34,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
// Flags permitted to be passed to command line arguments
|
// Flags permitted to be passed to command line arguments
|
||||||
//
|
//
|
||||||
|
|
||||||
enum NumOccurances { // Flags for the number of occurances allowed...
|
enum NumOccurrences { // Flags for the number of occurances allowed...
|
||||||
Optional = 0x01, // Zero or One occurance
|
Optional = 0x01, // Zero or One occurance
|
||||||
ZeroOrMore = 0x02, // Zero or more occurances allowed
|
ZeroOrMore = 0x02, // Zero or more occurances allowed
|
||||||
Required = 0x03, // One occurance required
|
Required = 0x03, // One occurance required
|
||||||
@ -49,7 +49,7 @@ enum NumOccurances { // Flags for the number of occurances allowed...
|
|||||||
//
|
//
|
||||||
ConsumeAfter = 0x05,
|
ConsumeAfter = 0x05,
|
||||||
|
|
||||||
OccurancesMask = 0x07,
|
OccurrencesMask = 0x07,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ValueExpected { // Is a value required for the option?
|
enum ValueExpected { // Is a value required for the option?
|
||||||
@ -104,13 +104,13 @@ class Option {
|
|||||||
friend void cl::ParseCommandLineOptions(int &, char **, const char *, int);
|
friend void cl::ParseCommandLineOptions(int &, char **, const char *, int);
|
||||||
friend class alias;
|
friend class alias;
|
||||||
|
|
||||||
// handleOccurances - Overriden by subclasses to handle the value passed into
|
// handleOccurrences - Overriden by subclasses to handle the value passed into
|
||||||
// an argument. Should return true if there was an error processing the
|
// an argument. Should return true if there was an error processing the
|
||||||
// argument and the program should exit.
|
// argument and the program should exit.
|
||||||
//
|
//
|
||||||
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0;
|
virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) = 0;
|
||||||
|
|
||||||
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
virtual enum NumOccurrences getNumOccurrencesFlagDefault() const {
|
||||||
return Optional;
|
return Optional;
|
||||||
}
|
}
|
||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
@ -123,16 +123,16 @@ class Option {
|
|||||||
return NormalFormatting;
|
return NormalFormatting;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NumOccurances; // The number of times specified
|
int NumOccurrences; // The number of times specified
|
||||||
int Flags; // Flags for the argument
|
int Flags; // Flags for the argument
|
||||||
public:
|
public:
|
||||||
const char *ArgStr; // The argument string itself (ex: "help", "o")
|
const char *ArgStr; // The argument string itself (ex: "help", "o")
|
||||||
const char *HelpStr; // The descriptive text message for --help
|
const char *HelpStr; // The descriptive text message for --help
|
||||||
const char *ValueStr; // String describing what the value of this option is
|
const char *ValueStr; // String describing what the value of this option is
|
||||||
|
|
||||||
inline enum NumOccurances getNumOccurancesFlag() const {
|
inline enum NumOccurrences getNumOccurrencesFlag() const {
|
||||||
int NO = Flags & OccurancesMask;
|
int NO = Flags & OccurrencesMask;
|
||||||
return NO ? (enum NumOccurances)NO : getNumOccurancesFlagDefault();
|
return NO ? (enum NumOccurrences)NO : getNumOccurrencesFlagDefault();
|
||||||
}
|
}
|
||||||
inline enum ValueExpected getValueExpectedFlag() const {
|
inline enum ValueExpected getValueExpectedFlag() const {
|
||||||
int VE = Flags & ValueMask;
|
int VE = Flags & ValueMask;
|
||||||
@ -169,15 +169,15 @@ public:
|
|||||||
Flags |= Flag;
|
Flags |= Flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNumOccurancesFlag(enum NumOccurances Val) {
|
void setNumOccurrencesFlag(enum NumOccurrences Val) {
|
||||||
setFlag(Val, OccurancesMask);
|
setFlag(Val, OccurrencesMask);
|
||||||
}
|
}
|
||||||
void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); }
|
void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); }
|
||||||
void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); }
|
void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); }
|
||||||
void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); }
|
void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); }
|
||||||
void setMiscFlag(enum MiscFlags M) { setFlag(M, M); }
|
void setMiscFlag(enum MiscFlags M) { setFlag(M, M); }
|
||||||
protected:
|
protected:
|
||||||
Option() : NumOccurances(0), Flags(0),
|
Option() : NumOccurrences(0), Flags(0),
|
||||||
ArgStr(""), HelpStr(""), ValueStr("") {}
|
ArgStr(""), HelpStr(""), ValueStr("") {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -195,15 +195,15 @@ public:
|
|||||||
//
|
//
|
||||||
virtual void printOptionInfo(unsigned GlobalWidth) const = 0;
|
virtual void printOptionInfo(unsigned GlobalWidth) const = 0;
|
||||||
|
|
||||||
// addOccurance - Wrapper around handleOccurance that enforces Flags
|
// addOccurrence - Wrapper around handleOccurrence that enforces Flags
|
||||||
//
|
//
|
||||||
bool addOccurance(const char *ArgName, const std::string &Value);
|
bool addOccurrence(const char *ArgName, const std::string &Value);
|
||||||
|
|
||||||
// Prints option name followed by message. Always returns true.
|
// Prints option name followed by message. Always returns true.
|
||||||
bool error(std::string Message, const char *ArgName = 0);
|
bool error(std::string Message, const char *ArgName = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline int getNumOccurances() const { return NumOccurances; }
|
inline int getNumOccurrences() const { return NumOccurrences; }
|
||||||
virtual ~Option() {}
|
virtual ~Option() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -598,8 +598,8 @@ template<> struct applicator<const char*> {
|
|||||||
static void opt(const char *Str, Opt &O) { O.setArgStr(Str); }
|
static void opt(const char *Str, Opt &O) { O.setArgStr(Str); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<> struct applicator<NumOccurances> {
|
template<> struct applicator<NumOccurrences> {
|
||||||
static void opt(NumOccurances NO, Option &O) { O.setNumOccurancesFlag(NO); }
|
static void opt(NumOccurrences NO, Option &O) { O.setNumOccurrencesFlag(NO); }
|
||||||
};
|
};
|
||||||
template<> struct applicator<ValueExpected> {
|
template<> struct applicator<ValueExpected> {
|
||||||
static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); }
|
static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); }
|
||||||
@ -700,7 +700,7 @@ class opt : public Option,
|
|||||||
::boost::is_class<DataType>::value> {
|
::boost::is_class<DataType>::value> {
|
||||||
ParserClass Parser;
|
ParserClass Parser;
|
||||||
|
|
||||||
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
|
virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) {
|
||||||
typename ParserClass::parser_data_type Val;
|
typename ParserClass::parser_data_type Val;
|
||||||
if (Parser.parse(*this, ArgName, Arg, Val))
|
if (Parser.parse(*this, ArgName, Arg, Val))
|
||||||
return true; // Parse error!
|
return true; // Parse error!
|
||||||
@ -846,14 +846,14 @@ template <class DataType, class Storage = bool,
|
|||||||
class list : public Option, public list_storage<DataType, Storage> {
|
class list : public Option, public list_storage<DataType, Storage> {
|
||||||
ParserClass Parser;
|
ParserClass Parser;
|
||||||
|
|
||||||
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
virtual enum NumOccurrences getNumOccurrencesFlagDefault() const {
|
||||||
return ZeroOrMore;
|
return ZeroOrMore;
|
||||||
}
|
}
|
||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
return Parser.getValueExpectedFlagDefault();
|
return Parser.getValueExpectedFlagDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
|
virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) {
|
||||||
typename ParserClass::parser_data_type Val;
|
typename ParserClass::parser_data_type Val;
|
||||||
if (Parser.parse(*this, ArgName, Arg, Val))
|
if (Parser.parse(*this, ArgName, Arg, Val))
|
||||||
return true; // Parse Error!
|
return true; // Parse Error!
|
||||||
@ -943,8 +943,8 @@ public:
|
|||||||
|
|
||||||
class alias : public Option {
|
class alias : public Option {
|
||||||
Option *AliasFor;
|
Option *AliasFor;
|
||||||
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
|
virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) {
|
||||||
return AliasFor->handleOccurance(AliasFor->ArgStr, Arg);
|
return AliasFor->handleOccurrence(AliasFor->ArgStr, Arg);
|
||||||
}
|
}
|
||||||
// Aliases default to be hidden...
|
// Aliases default to be hidden...
|
||||||
virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
|
virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
|
||||||
|
@ -93,7 +93,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the handler now!
|
// Run the handler now!
|
||||||
return Handler->addOccurance(ArgName, Value);
|
return Handler->addOccurrence(ArgName, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ProvidePositionalOption(Option *Handler, std::string &Arg) {
|
static bool ProvidePositionalOption(Option *Handler, std::string &Arg) {
|
||||||
@ -143,13 +143,13 @@ static Option *getOptionPred(std::string Name, unsigned &Length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool RequiresValue(const Option *O) {
|
static bool RequiresValue(const Option *O) {
|
||||||
return O->getNumOccurancesFlag() == cl::Required ||
|
return O->getNumOccurrencesFlag() == cl::Required ||
|
||||||
O->getNumOccurancesFlag() == cl::OneOrMore;
|
O->getNumOccurrencesFlag() == cl::OneOrMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool EatsUnboundedNumberOfValues(const Option *O) {
|
static bool EatsUnboundedNumberOfValues(const Option *O) {
|
||||||
return O->getNumOccurancesFlag() == cl::ZeroOrMore ||
|
return O->getNumOccurrencesFlag() == cl::ZeroOrMore ||
|
||||||
O->getNumOccurancesFlag() == cl::OneOrMore;
|
O->getNumOccurrencesFlag() == cl::OneOrMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cl::ParseCommandLineOptions(int &argc, char **argv,
|
void cl::ParseCommandLineOptions(int &argc, char **argv,
|
||||||
@ -168,7 +168,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
unsigned NumPositionalRequired = 0;
|
unsigned NumPositionalRequired = 0;
|
||||||
Option *ConsumeAfterOpt = 0;
|
Option *ConsumeAfterOpt = 0;
|
||||||
if (!PositionalOpts.empty()) {
|
if (!PositionalOpts.empty()) {
|
||||||
if (PositionalOpts[0]->getNumOccurancesFlag() == cl::ConsumeAfter) {
|
if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) {
|
||||||
assert(PositionalOpts.size() > 1 &&
|
assert(PositionalOpts.size() > 1 &&
|
||||||
"Cannot specify cl::ConsumeAfter without a positional argument!");
|
"Cannot specify cl::ConsumeAfter without a positional argument!");
|
||||||
ConsumeAfterOpt = PositionalOpts[0];
|
ConsumeAfterOpt = PositionalOpts[0];
|
||||||
@ -362,9 +362,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
// do not give it values that others need. 'Done' controls whether the
|
// do not give it values that others need. 'Done' controls whether the
|
||||||
// option even _WANTS_ any more.
|
// option even _WANTS_ any more.
|
||||||
//
|
//
|
||||||
bool Done = PositionalOpts[i]->getNumOccurancesFlag() == cl::Required;
|
bool Done = PositionalOpts[i]->getNumOccurrencesFlag() == cl::Required;
|
||||||
while (NumVals-ValNo > NumPositionalRequired && !Done) {
|
while (NumVals-ValNo > NumPositionalRequired && !Done) {
|
||||||
switch (PositionalOpts[i]->getNumOccurancesFlag()) {
|
switch (PositionalOpts[i]->getNumOccurrencesFlag()) {
|
||||||
case cl::Optional:
|
case cl::Optional:
|
||||||
Done = true; // Optional arguments want _at most_ one value
|
Done = true; // Optional arguments want _at most_ one value
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
@ -373,7 +373,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]);
|
ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0 && "Internal error, unexpected NumOccurances flag in "
|
assert(0 && "Internal error, unexpected NumOccurrences flag in "
|
||||||
"positional argument processing!");
|
"positional argument processing!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,10 +405,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
// Loop over args and make sure all required args are specified!
|
// Loop over args and make sure all required args are specified!
|
||||||
for (std::map<std::string, Option*>::iterator I = Opts.begin(),
|
for (std::map<std::string, Option*>::iterator I = Opts.begin(),
|
||||||
E = Opts.end(); I != E; ++I) {
|
E = Opts.end(); I != E; ++I) {
|
||||||
switch (I->second->getNumOccurancesFlag()) {
|
switch (I->second->getNumOccurrencesFlag()) {
|
||||||
case Required:
|
case Required:
|
||||||
case OneOrMore:
|
case OneOrMore:
|
||||||
if (I->second->getNumOccurances() == 0) {
|
if (I->second->getNumOccurrences() == 0) {
|
||||||
I->second->error(" must be specified at least once!");
|
I->second->error(" must be specified at least once!");
|
||||||
ErrorParsing = true;
|
ErrorParsing = true;
|
||||||
}
|
}
|
||||||
@ -442,16 +442,16 @@ bool Option::error(std::string Message, const char *ArgName) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Option::addOccurance(const char *ArgName, const std::string &Value) {
|
bool Option::addOccurrence(const char *ArgName, const std::string &Value) {
|
||||||
NumOccurances++; // Increment the number of times we have been seen
|
NumOccurrences++; // Increment the number of times we have been seen
|
||||||
|
|
||||||
switch (getNumOccurancesFlag()) {
|
switch (getNumOccurrencesFlag()) {
|
||||||
case Optional:
|
case Optional:
|
||||||
if (NumOccurances > 1)
|
if (NumOccurrences > 1)
|
||||||
return error(": may only occur zero or one times!", ArgName);
|
return error(": may only occur zero or one times!", ArgName);
|
||||||
break;
|
break;
|
||||||
case Required:
|
case Required:
|
||||||
if (NumOccurances > 1)
|
if (NumOccurrences > 1)
|
||||||
return error(": must occur exactly one time!", ArgName);
|
return error(": must occur exactly one time!", ArgName);
|
||||||
// Fall through
|
// Fall through
|
||||||
case OneOrMore:
|
case OneOrMore:
|
||||||
@ -460,7 +460,7 @@ bool Option::addOccurance(const char *ArgName, const std::string &Value) {
|
|||||||
default: return error(": bad num occurances flag value!");
|
default: return error(": bad num occurances flag value!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleOccurance(ArgName, Value);
|
return handleOccurrence(ArgName, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// addArgument - Tell the system that this Option subclass will handle all
|
// addArgument - Tell the system that this Option subclass will handle all
|
||||||
@ -471,9 +471,9 @@ void Option::addArgument(const char *ArgStr) {
|
|||||||
AddArgument(ArgStr, this);
|
AddArgument(ArgStr, this);
|
||||||
else if (getFormattingFlag() == Positional)
|
else if (getFormattingFlag() == Positional)
|
||||||
getPositionalOpts().push_back(this);
|
getPositionalOpts().push_back(this);
|
||||||
else if (getNumOccurancesFlag() == ConsumeAfter) {
|
else if (getNumOccurrencesFlag() == ConsumeAfter) {
|
||||||
assert((getPositionalOpts().empty() ||
|
assert((getPositionalOpts().empty() ||
|
||||||
getPositionalOpts().front()->getNumOccurancesFlag() != ConsumeAfter)
|
getPositionalOpts().front()->getNumOccurrencesFlag() != ConsumeAfter)
|
||||||
&& "Cannot specify more than one option with cl::ConsumeAfter "
|
&& "Cannot specify more than one option with cl::ConsumeAfter "
|
||||||
"specified!");
|
"specified!");
|
||||||
getPositionalOpts().insert(getPositionalOpts().begin(), this);
|
getPositionalOpts().insert(getPositionalOpts().begin(), this);
|
||||||
@ -488,7 +488,7 @@ void Option::removeArgument(const char *ArgStr) {
|
|||||||
std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this);
|
std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this);
|
||||||
assert(I != getPositionalOpts().end() && "Arg not registered!");
|
assert(I != getPositionalOpts().end() && "Arg not registered!");
|
||||||
getPositionalOpts().erase(I);
|
getPositionalOpts().erase(I);
|
||||||
} else if (getNumOccurancesFlag() == ConsumeAfter) {
|
} else if (getNumOccurrencesFlag() == ConsumeAfter) {
|
||||||
assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this &&
|
assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this &&
|
||||||
"Arg not registered correctly!");
|
"Arg not registered correctly!");
|
||||||
getPositionalOpts().erase(getPositionalOpts().begin());
|
getPositionalOpts().erase(getPositionalOpts().begin());
|
||||||
@ -735,7 +735,7 @@ public:
|
|||||||
// Print out the positional options...
|
// Print out the positional options...
|
||||||
std::vector<Option*> &PosOpts = getPositionalOpts();
|
std::vector<Option*> &PosOpts = getPositionalOpts();
|
||||||
Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists...
|
Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists...
|
||||||
if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter)
|
if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter)
|
||||||
CAOpt = PosOpts[0];
|
CAOpt = PosOpts[0];
|
||||||
|
|
||||||
for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i)
|
for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i)
|
||||||
|
@ -93,7 +93,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the handler now!
|
// Run the handler now!
|
||||||
return Handler->addOccurance(ArgName, Value);
|
return Handler->addOccurrence(ArgName, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ProvidePositionalOption(Option *Handler, std::string &Arg) {
|
static bool ProvidePositionalOption(Option *Handler, std::string &Arg) {
|
||||||
@ -143,13 +143,13 @@ static Option *getOptionPred(std::string Name, unsigned &Length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool RequiresValue(const Option *O) {
|
static bool RequiresValue(const Option *O) {
|
||||||
return O->getNumOccurancesFlag() == cl::Required ||
|
return O->getNumOccurrencesFlag() == cl::Required ||
|
||||||
O->getNumOccurancesFlag() == cl::OneOrMore;
|
O->getNumOccurrencesFlag() == cl::OneOrMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool EatsUnboundedNumberOfValues(const Option *O) {
|
static bool EatsUnboundedNumberOfValues(const Option *O) {
|
||||||
return O->getNumOccurancesFlag() == cl::ZeroOrMore ||
|
return O->getNumOccurrencesFlag() == cl::ZeroOrMore ||
|
||||||
O->getNumOccurancesFlag() == cl::OneOrMore;
|
O->getNumOccurrencesFlag() == cl::OneOrMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cl::ParseCommandLineOptions(int &argc, char **argv,
|
void cl::ParseCommandLineOptions(int &argc, char **argv,
|
||||||
@ -168,7 +168,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
unsigned NumPositionalRequired = 0;
|
unsigned NumPositionalRequired = 0;
|
||||||
Option *ConsumeAfterOpt = 0;
|
Option *ConsumeAfterOpt = 0;
|
||||||
if (!PositionalOpts.empty()) {
|
if (!PositionalOpts.empty()) {
|
||||||
if (PositionalOpts[0]->getNumOccurancesFlag() == cl::ConsumeAfter) {
|
if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) {
|
||||||
assert(PositionalOpts.size() > 1 &&
|
assert(PositionalOpts.size() > 1 &&
|
||||||
"Cannot specify cl::ConsumeAfter without a positional argument!");
|
"Cannot specify cl::ConsumeAfter without a positional argument!");
|
||||||
ConsumeAfterOpt = PositionalOpts[0];
|
ConsumeAfterOpt = PositionalOpts[0];
|
||||||
@ -362,9 +362,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
// do not give it values that others need. 'Done' controls whether the
|
// do not give it values that others need. 'Done' controls whether the
|
||||||
// option even _WANTS_ any more.
|
// option even _WANTS_ any more.
|
||||||
//
|
//
|
||||||
bool Done = PositionalOpts[i]->getNumOccurancesFlag() == cl::Required;
|
bool Done = PositionalOpts[i]->getNumOccurrencesFlag() == cl::Required;
|
||||||
while (NumVals-ValNo > NumPositionalRequired && !Done) {
|
while (NumVals-ValNo > NumPositionalRequired && !Done) {
|
||||||
switch (PositionalOpts[i]->getNumOccurancesFlag()) {
|
switch (PositionalOpts[i]->getNumOccurrencesFlag()) {
|
||||||
case cl::Optional:
|
case cl::Optional:
|
||||||
Done = true; // Optional arguments want _at most_ one value
|
Done = true; // Optional arguments want _at most_ one value
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
@ -373,7 +373,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]);
|
ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0 && "Internal error, unexpected NumOccurances flag in "
|
assert(0 && "Internal error, unexpected NumOccurrences flag in "
|
||||||
"positional argument processing!");
|
"positional argument processing!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,10 +405,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
|
|||||||
// Loop over args and make sure all required args are specified!
|
// Loop over args and make sure all required args are specified!
|
||||||
for (std::map<std::string, Option*>::iterator I = Opts.begin(),
|
for (std::map<std::string, Option*>::iterator I = Opts.begin(),
|
||||||
E = Opts.end(); I != E; ++I) {
|
E = Opts.end(); I != E; ++I) {
|
||||||
switch (I->second->getNumOccurancesFlag()) {
|
switch (I->second->getNumOccurrencesFlag()) {
|
||||||
case Required:
|
case Required:
|
||||||
case OneOrMore:
|
case OneOrMore:
|
||||||
if (I->second->getNumOccurances() == 0) {
|
if (I->second->getNumOccurrences() == 0) {
|
||||||
I->second->error(" must be specified at least once!");
|
I->second->error(" must be specified at least once!");
|
||||||
ErrorParsing = true;
|
ErrorParsing = true;
|
||||||
}
|
}
|
||||||
@ -442,16 +442,16 @@ bool Option::error(std::string Message, const char *ArgName) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Option::addOccurance(const char *ArgName, const std::string &Value) {
|
bool Option::addOccurrence(const char *ArgName, const std::string &Value) {
|
||||||
NumOccurances++; // Increment the number of times we have been seen
|
NumOccurrences++; // Increment the number of times we have been seen
|
||||||
|
|
||||||
switch (getNumOccurancesFlag()) {
|
switch (getNumOccurrencesFlag()) {
|
||||||
case Optional:
|
case Optional:
|
||||||
if (NumOccurances > 1)
|
if (NumOccurrences > 1)
|
||||||
return error(": may only occur zero or one times!", ArgName);
|
return error(": may only occur zero or one times!", ArgName);
|
||||||
break;
|
break;
|
||||||
case Required:
|
case Required:
|
||||||
if (NumOccurances > 1)
|
if (NumOccurrences > 1)
|
||||||
return error(": must occur exactly one time!", ArgName);
|
return error(": must occur exactly one time!", ArgName);
|
||||||
// Fall through
|
// Fall through
|
||||||
case OneOrMore:
|
case OneOrMore:
|
||||||
@ -460,7 +460,7 @@ bool Option::addOccurance(const char *ArgName, const std::string &Value) {
|
|||||||
default: return error(": bad num occurances flag value!");
|
default: return error(": bad num occurances flag value!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleOccurance(ArgName, Value);
|
return handleOccurrence(ArgName, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// addArgument - Tell the system that this Option subclass will handle all
|
// addArgument - Tell the system that this Option subclass will handle all
|
||||||
@ -471,9 +471,9 @@ void Option::addArgument(const char *ArgStr) {
|
|||||||
AddArgument(ArgStr, this);
|
AddArgument(ArgStr, this);
|
||||||
else if (getFormattingFlag() == Positional)
|
else if (getFormattingFlag() == Positional)
|
||||||
getPositionalOpts().push_back(this);
|
getPositionalOpts().push_back(this);
|
||||||
else if (getNumOccurancesFlag() == ConsumeAfter) {
|
else if (getNumOccurrencesFlag() == ConsumeAfter) {
|
||||||
assert((getPositionalOpts().empty() ||
|
assert((getPositionalOpts().empty() ||
|
||||||
getPositionalOpts().front()->getNumOccurancesFlag() != ConsumeAfter)
|
getPositionalOpts().front()->getNumOccurrencesFlag() != ConsumeAfter)
|
||||||
&& "Cannot specify more than one option with cl::ConsumeAfter "
|
&& "Cannot specify more than one option with cl::ConsumeAfter "
|
||||||
"specified!");
|
"specified!");
|
||||||
getPositionalOpts().insert(getPositionalOpts().begin(), this);
|
getPositionalOpts().insert(getPositionalOpts().begin(), this);
|
||||||
@ -488,7 +488,7 @@ void Option::removeArgument(const char *ArgStr) {
|
|||||||
std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this);
|
std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this);
|
||||||
assert(I != getPositionalOpts().end() && "Arg not registered!");
|
assert(I != getPositionalOpts().end() && "Arg not registered!");
|
||||||
getPositionalOpts().erase(I);
|
getPositionalOpts().erase(I);
|
||||||
} else if (getNumOccurancesFlag() == ConsumeAfter) {
|
} else if (getNumOccurrencesFlag() == ConsumeAfter) {
|
||||||
assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this &&
|
assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this &&
|
||||||
"Arg not registered correctly!");
|
"Arg not registered correctly!");
|
||||||
getPositionalOpts().erase(getPositionalOpts().begin());
|
getPositionalOpts().erase(getPositionalOpts().begin());
|
||||||
@ -735,7 +735,7 @@ public:
|
|||||||
// Print out the positional options...
|
// Print out the positional options...
|
||||||
std::vector<Option*> &PosOpts = getPositionalOpts();
|
std::vector<Option*> &PosOpts = getPositionalOpts();
|
||||||
Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists...
|
Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists...
|
||||||
if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter)
|
if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter)
|
||||||
CAOpt = PosOpts[0];
|
CAOpt = PosOpts[0];
|
||||||
|
|
||||||
for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i)
|
for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user