mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Overloaded operator[] to get argument pointer from parser
This commit is contained in:
parent
2d6fe42141
commit
855aced999
@ -293,6 +293,16 @@ class ArgumentParser {
|
||||
return mArgumentMap;
|
||||
}
|
||||
|
||||
std::shared_ptr<Argument> operator[](const std::string& aArgumentName) {
|
||||
std::map<std::string, std::shared_ptr<Argument>>::iterator tIterator = mArgumentMap.find(aArgumentName);
|
||||
if (tIterator != mArgumentMap.end()) {
|
||||
return tIterator->second;
|
||||
}
|
||||
else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Argument& add_argument_internal(std::shared_ptr<Argument> aArgument) {
|
||||
return *aArgument;
|
||||
|
Loading…
Reference in New Issue
Block a user