FreeNOS
Public Types | Public Member Functions | Private Attributes
ArgumentContainer Class Reference

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...
 

Detailed Description

Generic command-line argument parser.

Definition at line 40 of file ArgumentContainer.h.

Member Enumeration Documentation

◆ Result

Result codes.

Enumerator
Success 
InvalidArgument 
NotFound 

Definition at line 47 of file ArgumentContainer.h.

Constructor & Destructor Documentation

◆ ArgumentContainer()

ArgumentContainer::ArgumentContainer ( )

Constructor.

Definition at line 20 of file ArgumentContainer.cpp.

◆ ~ArgumentContainer()

ArgumentContainer::~ArgumentContainer ( )
virtual

Destructor.

Definition at line 24 of file ArgumentContainer.cpp.

References Vector< T >::count(), HashIterator< K, V >::hasCurrent(), m_flags, and m_positionals.

Member Function Documentation

◆ addFlag()

ArgumentContainer::Result ArgumentContainer::addFlag ( Argument arg)

Add flag argument.

Parameters
argFlag argument
Returns
Result code

Definition at line 73 of file ArgumentContainer.cpp.

References Argument::getName(), HashTable< K, V >::insert(), m_flags, and Success.

Referenced by ArgumentParser::parse().

◆ addPositional()

ArgumentContainer::Result ArgumentContainer::addPositional ( Argument arg)

Add positional argument.

Parameters
argPositional argument
Returns
Result code

Definition at line 67 of file ArgumentContainer.cpp.

References Vector< T >::insert(), m_positionals, and Success.

Referenced by ArgumentParser::parse().

◆ get()

const char * ArgumentContainer::get ( const char *  name) const

◆ getFlags()

const HashTable< String, Argument * > & ArgumentContainer::getFlags ( ) const

Get flag arguments.

Returns
HashTable object reference

Definition at line 44 of file ArgumentContainer.cpp.

References m_flags.

◆ getPositionals()

const Vector< Argument * > & ArgumentContainer::getPositionals ( ) const

Field Documentation

◆ m_flags

HashTable<String, Argument *> ArgumentContainer::m_flags
private

Contains all flag arguments.

Definition at line 110 of file ArgumentContainer.h.

Referenced by addFlag(), get(), getFlags(), and ~ArgumentContainer().

◆ m_positionals

Vector<Argument *> ArgumentContainer::m_positionals
private

Contains all positional arguments.

Definition at line 113 of file ArgumentContainer.h.

Referenced by addPositional(), get(), getPositionals(), and ~ArgumentContainer().


The documentation for this class was generated from the following files: