MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Data Structures | Public Member Functions
MFM::VArguments Class Reference

#include <VArguments.h>

Public Member Functions

 VArguments ()
 
void Die (const char *format,...)
 
void RegisterArgument (const char *description, const char *filter, VArgumentHandleValue func, void *handlerArg, bool runFunc)
 
void RegisterSection (const char *label)
 
void ProcessArguments (u32 argc, const char **argv)
 
const char * Get (const char *argName) const
 
u32 GetInt (const char *argName) const
 
bool Appeared (const char *argName) const
 
void Usage () const
 

Detailed Description

A class which holds a variable number of command line arguments. This is normally used when a driver needs to have unique command line arguments.

Constructor & Destructor Documentation

MFM::VArguments::VArguments ( )

Constructs a new empty VArguments collection.

Member Function Documentation

bool MFM::VArguments::Appeared ( const char *  argName) const

Checks to see if a particular argument was encountered on the command line during ProcessArguments .

Parameters
argNameThe name of the argument being checked for command line membership.
Returns
true if this argument was encountered on the command line, else false.
void MFM::VArguments::Die ( const char *  format,
  ... 
)

Fails, to be called upon an illegal command line argument. This method terminates wiht exit(0) .

Parameters
formatThe format used to print a printf-style format string describing the failure.
const char * MFM::VArguments::Get ( const char *  argName) const

Retrieve a command line argument which has been generated by Gather. If this argument is not found, FAIL(ILLEGAL_ARGUMENT) is invoked.

Parameters
argNameThe name of the argument to retrieve from this VArguments.
Returns
The value at the specified argument, or NULL if this argument was not specified by the user.
u32 MFM::VArguments::GetInt ( const char *  argName) const

Retrieve a command line argument which has been generated by Gather. If this argument is not found, FAIL(ILLEGAL_ARGUMENT) is invoked. The argument retrieved is passed through atoi and the value is returned.

Parameters
argNameThe name of the argument to retrieve from this VArguments.
Returns
The value at the specified argument after passed through atoi, or NULL if this argument was not specified by the user.
void MFM::VArguments::ProcessArguments ( u32  argc,
const char **  argv 
)

To be called after all arguments are registered. This will parse all command line arguments given into the internally held format.

Parameters
argcThe amount of command line arguments in argv.
argvThe command line arguments.
void MFM::VArguments::RegisterArgument ( const char *  description,
const char *  filter,
VArgumentHandleValue  func,
void *  handlerArg,
bool  runFunc 
)

Registers a new command line argument to this VArguments instance.

Parameters
descriptionThe description of this argument, printed out upon displaying this program's usage.
filterThe filter used to differentiate between command line arguments, separated by the '|' character. For instance, "-h|--help" matches both "-h" and "--help".
funcThe function called upon encounterin this command line argument when given by the user. This is called on the value gotten by the user, unless otherwise specified.
handlerArgThe argument specified to func upon being called.
runFuncIf true, will ask for one command line argument. If not, will treat as a flag and simply execute func with NULL as its argument.
void MFM::VArguments::RegisterSection ( const char *  label)

Defines a new command line argument section in this VArguments instance. Subsequent RegisterArgument calls will be described as part of section label, unless and until another RegisterSection call.

Parameters
labelThe name of the section, printed out as part of program usage help.
void MFM::VArguments::Usage ( ) const

Prints all held arguments to stdout. This is called when the default 'help' command line argument is invoked.


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