FreeNOS
|
Generic command-line argument parser. More...
#include <ArgumentContainer.h>
Public Types | |
enum | Result { Success, InvalidArgument, NotFound } |
Result codes. More... | |
Public Member Functions | |
ArgumentContainer () | |
Constructor. More... | |
virtual | ~ArgumentContainer () |
Destructor. More... | |
const char * | get (const char *name) const |
Get argument by name. More... | |
const Vector< Argument * > & | getPositionals () const |
Get positional arguments. More... | |
const HashTable< String, Argument * > & | getFlags () const |
Get flag arguments. More... | |
Result | addPositional (Argument *arg) |
Add positional argument. More... | |
Result | addFlag (Argument *arg) |
Add flag argument. More... | |
Private Attributes | |
HashTable< String, Argument * > | m_flags |
Contains all flag arguments. More... | |
Vector< Argument * > | m_positionals |
Contains all positional arguments. More... | |
Generic command-line argument parser.
Definition at line 40 of file ArgumentContainer.h.
Result codes.
Enumerator | |
---|---|
Success | |
InvalidArgument | |
NotFound |
Definition at line 47 of file ArgumentContainer.h.
ArgumentContainer::ArgumentContainer | ( | ) |
Constructor.
Definition at line 20 of file ArgumentContainer.cpp.
|
virtual |
Destructor.
Definition at line 24 of file ArgumentContainer.cpp.
References Vector< T >::count(), HashIterator< K, V >::hasCurrent(), m_flags, and m_positionals.
ArgumentContainer::Result ArgumentContainer::addFlag | ( | Argument * | arg | ) |
Add flag argument.
arg | Flag argument |
Definition at line 73 of file ArgumentContainer.cpp.
References Argument::getName(), HashTable< K, V >::insert(), m_flags, and Success.
Referenced by ArgumentParser::parse().
ArgumentContainer::Result ArgumentContainer::addPositional | ( | Argument * | arg | ) |
Add positional argument.
arg | Positional argument |
Definition at line 67 of file ArgumentContainer.cpp.
References Vector< T >::insert(), m_positionals, and Success.
Referenced by ArgumentParser::parse().
const char * ArgumentContainer::get | ( | const char * | name | ) | const |
Get argument by name.
name | Name of the argument |
Definition at line 49 of file ArgumentContainer.cpp.
References Vector< T >::count(), String::equals(), HashTable< K, V >::get(), Argument::getName(), Argument::getValue(), m_flags, m_positionals, and ZERO.
Referenced by NetPing::exec(), Init::exec(), Echo::exec(), Mount::exec(), BootImageCreate::exec(), NetSend::initialize(), MpiProxy::initialize(), DhcpClient::initialize(), ListFiles::printSingleFile(), and Application::run().
Get flag arguments.
Definition at line 44 of file ArgumentContainer.cpp.
References m_flags.
Get positional arguments.
Definition at line 39 of file ArgumentContainer.cpp.
References m_positionals.
Referenced by Decompress::exec(), Echo::exec(), CreateFile::exec(), FileStatus::exec(), ListFiles::exec(), Remove::exec(), SysControl::exec(), Shell::exec(), Cat::exec(), Cat::initialize(), and ArgumentParser::parse().
Contains all flag arguments.
Definition at line 110 of file ArgumentContainer.h.
Referenced by addFlag(), get(), getFlags(), and ~ArgumentContainer().
Contains all positional arguments.
Definition at line 113 of file ArgumentContainer.h.
Referenced by addPositional(), get(), getPositionals(), and ~ArgumentContainer().