Renamed private variables
This commit is contained in:
parent
9abcd28b44
commit
d6c1384991
BIN
Hazelnupp.vpp
BIN
Hazelnupp.vpp
Binary file not shown.
@ -144,14 +144,14 @@ void Hazelnupp::PopulateRawArgs(const int argc, const char* const* argv)
|
||||
void Hazelnupp::ExpandAbbreviations()
|
||||
{
|
||||
// Abort if no abbreviations
|
||||
if (abbreviations.size() == 0)
|
||||
if (parameterAbreviations.size() == 0)
|
||||
return;
|
||||
|
||||
for (std::string& arg : rawArgs)
|
||||
{
|
||||
// Is arg registered as an abbreviation?
|
||||
auto abbr = abbreviations.find(arg);
|
||||
if (abbr != abbreviations.end())
|
||||
auto abbr = parameterAbreviations.find(arg);
|
||||
if (abbr != parameterAbreviations.end())
|
||||
{
|
||||
// Yes: replace arg with the long form
|
||||
arg = abbr->second;
|
||||
@ -382,7 +382,7 @@ std::string Hazelnupp::GenerateDocumentation() const
|
||||
|
||||
// Collect abbreviations
|
||||
// first value is abbreviation, second is long form
|
||||
for (const auto& it : abbreviations)
|
||||
for (const auto& it : parameterAbreviations)
|
||||
{
|
||||
// Do we already have that param in the paramInfo set?
|
||||
if (paramInfos.find(it.second) == paramInfos.end())
|
||||
@ -393,7 +393,7 @@ std::string Hazelnupp::GenerateDocumentation() const
|
||||
}
|
||||
|
||||
// Collect constraints
|
||||
for (const auto& it : constraints)
|
||||
for (const auto& it : parameterConstraints)
|
||||
{
|
||||
// Do we already have that param in the paramInfo set?
|
||||
if (paramInfos.find(it.first) == paramInfos.end())
|
||||
@ -461,7 +461,7 @@ std::string Hazelnupp::GenerateDocumentation() const
|
||||
void Hazelnupp::ApplyConstraints()
|
||||
{
|
||||
// Enforce required parameters / default values
|
||||
for (const auto& pc : constraints)
|
||||
for (const auto& pc : parameterConstraints)
|
||||
// Parameter in question is not supplied
|
||||
if (!HasParam(pc.second.key))
|
||||
{
|
||||
@ -494,12 +494,12 @@ void Hazelnupp::ApplyConstraints()
|
||||
|
||||
ParamConstraint Hazelnupp::GetConstraint(const std::string& parameter) const
|
||||
{
|
||||
return constraints.find(parameter)->second;
|
||||
return parameterConstraints.find(parameter)->second;
|
||||
}
|
||||
|
||||
void Hazelnupp::ClearConstraint(const std::string& parameter)
|
||||
{
|
||||
constraints.erase(parameter);
|
||||
parameterConstraints.erase(parameter);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -519,7 +519,7 @@ const Value& Hazelnupp::operator[](const std::string& key) const
|
||||
|
||||
void Hazelnupp::RegisterAbbreviation(const std::string& abbrev, const std::string& target)
|
||||
{
|
||||
abbreviations.insert(std::pair<std::string, std::string>(abbrev, target));
|
||||
parameterAbreviations.insert(std::pair<std::string, std::string>(abbrev, target));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -528,39 +528,39 @@ std::string Hazelnupp::GetAbbreviation(const std::string& abbrev) const
|
||||
if (!HasAbbreviation(abbrev))
|
||||
return "";
|
||||
|
||||
return abbreviations.find(abbrev)->second;
|
||||
return parameterAbreviations.find(abbrev)->second;
|
||||
}
|
||||
|
||||
bool Hazelnupp::HasAbbreviation(const std::string& abbrev) const
|
||||
{
|
||||
return abbreviations.find(abbrev) != abbreviations.end();
|
||||
return parameterAbreviations.find(abbrev) != parameterAbreviations.end();
|
||||
}
|
||||
|
||||
void Hazelnupp::ClearAbbreviation(const std::string& abbrevation)
|
||||
{
|
||||
abbreviations.erase(abbrevation);
|
||||
parameterAbreviations.erase(abbrevation);
|
||||
return;
|
||||
}
|
||||
|
||||
void Hazelnupp::ClearAbbreviations()
|
||||
{
|
||||
abbreviations.clear();
|
||||
parameterAbreviations.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
void Hazelnupp::RegisterConstraints(const std::vector<ParamConstraint>& constraints)
|
||||
void Hazelnupp::RegisterConstraints(const std::vector<ParamConstraint>& parameterConstraints)
|
||||
{
|
||||
for (const ParamConstraint& pc : constraints)
|
||||
for (const ParamConstraint& pc : parameterConstraints)
|
||||
{
|
||||
// Does this constraint already exist?
|
||||
const auto constraint = this->constraints.find(pc.key);
|
||||
const auto constraint = this->parameterConstraints.find(pc.key);
|
||||
// If yes, replace it.
|
||||
if (constraint != this->constraints.end())
|
||||
if (constraint != this->parameterConstraints.end())
|
||||
constraint->second = pc;
|
||||
|
||||
// Else, create a new pair
|
||||
else
|
||||
this->constraints.insert(std::pair<std::string, ParamConstraint>(
|
||||
this->parameterConstraints.insert(std::pair<std::string, ParamConstraint>(
|
||||
pc.key,
|
||||
pc
|
||||
));
|
||||
@ -571,7 +571,7 @@ void Hazelnupp::RegisterConstraints(const std::vector<ParamConstraint>& constrai
|
||||
|
||||
void Hazelnupp::ClearConstraints()
|
||||
{
|
||||
constraints.clear();
|
||||
parameterConstraints.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -583,9 +583,9 @@ void Hazelnupp::SetCrashOnFail(bool crashOnFail)
|
||||
|
||||
const ParamConstraint* Hazelnupp::GetConstraintForKey(const std::string& key) const
|
||||
{
|
||||
const auto constraint = constraints.find(key);
|
||||
const auto constraint = parameterConstraints.find(key);
|
||||
|
||||
if (constraint == constraints.end())
|
||||
if (constraint == parameterConstraints.end())
|
||||
return nullptr;
|
||||
|
||||
return &constraint->second;
|
||||
|
@ -120,10 +120,10 @@ namespace Hazelnp
|
||||
std::unordered_map<std::string, Parameter*> parameters;
|
||||
|
||||
//! These are abbreviations. Like, -f for --force.
|
||||
std::unordered_map<std::string, std::string> abbreviations;
|
||||
std::unordered_map<std::string, std::string> parameterAbreviations;
|
||||
|
||||
//! Parameter constraints, mapped to keys
|
||||
std::unordered_map<std::string, ParamConstraint> constraints;
|
||||
std::unordered_map<std::string, ParamConstraint> parameterConstraints;
|
||||
|
||||
//! Raw argv
|
||||
std::vector<std::string> rawArgs;
|
||||
|
Loading…
x
Reference in New Issue
Block a user