Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

IDEA::CommandLineParser Class Reference
[Utilities]

Base class for command-line parsing. One can extend the class and use registerOption to add command-line options and implement parseInternal (or use getOption) to retrieve the options. More...

#include <CommandLineParser.hh>

Inheritance diagram for IDEA::CommandLineParser:

IDEA::AgentCommandLineParser IDEA::PlasmaCommandLineParser IDEA::PlasmaReactivePlannerParser List of all members.

Public Methods

virtual ~CommandLineParser ()
 Destructor.

void usage (std::ostream &os) const
 Streams the usage of each option registered to the invoking class to os.

bool verify ()
 Returns true if all mandatory options are in the argv char array passed in the constructor (does not do type checking of the arguments). Otherwise returns false.


Protected Methods

 CommandLineParser ()
 Constructor.

bool getOption (int shortOptionChar, std::string &value) const
 Returns true if a commandline option shortOptionChar is present in argv char array and will populate value with the value if the commandline option has an argument. Otherwise will return false.

bool getOptions (int shortOptionChar, StringList &value) const
 Returns true if at least one commandline option shortOptionChar is present in argv char array and will populate value with all the values if the commandline option has an argument. Otherwise will return false.

bool registerOption (int shortOptionChar, bool hasArgument, bool mandatory, const std::string &usage, const StringList &possibleArguments=StringList())
 Registers the command-line option shortOptionChar have an argument if hasArgument is true, must be passed as an argumen if mandatory is true (see verify() ), with usage string usage (see usage() ) and if provided limited to the possible arguments possibleArguments.


Private Types

typedef std::map< int, OptionOptionList

Private Attributes

OptionList m_Options
ACE_Get_Opt m_GetOptions

Friends

std::ostream & operator<< (std::ostream &os, const CommandLineParser::Option &option)

Detailed Description

Base class for command-line parsing. One can extend the class and use registerOption to add command-line options and implement parseInternal (or use getOption) to retrieve the options.

class CommandLineParser


Member Typedef Documentation

typedef std::map< int, Option > IDEA::CommandLineParser::OptionList [private]
 


Constructor & Destructor Documentation

IDEA::CommandLineParser::~CommandLineParser   [virtual]
 

Destructor.

IDEA::CommandLineParser::CommandLineParser   [protected]
 

Constructor.


Member Function Documentation

bool IDEA::CommandLineParser::getOption int    shortOptionChar,
std::string &    value
const [protected]
 

Returns true if a commandline option shortOptionChar is present in argv char array and will populate value with the value if the commandline option has an argument. Otherwise will return false.

bool IDEA::CommandLineParser::getOptions int    shortOptionChar,
StringList   value
const [protected]
 

Returns true if at least one commandline option shortOptionChar is present in argv char array and will populate value with all the values if the commandline option has an argument. Otherwise will return false.

bool IDEA::CommandLineParser::registerOption int    shortOptionChar,
bool    hasArgument,
bool    mandatory,
const std::string &    usage,
const StringList   possibleArguments = StringList()
[protected]
 

Registers the command-line option shortOptionChar have an argument if hasArgument is true, must be passed as an argumen if mandatory is true (see verify() ), with usage string usage (see usage() ) and if provided limited to the possible arguments possibleArguments.

Will return true if arguments passed to this method can be accepted otherwise false. Command-line options can not be accepted if:

  • A command-line option with shortOptionChar already exists
  • hasArgument is true and possibleArguments is not empty

void IDEA::CommandLineParser::usage std::ostream &    os const
 

Streams the usage of each option registered to the invoking class to os.

bool IDEA::CommandLineParser::verify  
 

Returns true if all mandatory options are in the argv char array passed in the constructor (does not do type checking of the arguments). Otherwise returns false.


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &    os,
const CommandLineParser::Option   option
[friend]
 


Member Data Documentation

ACE_Get_Opt IDEA::CommandLineParser::m_GetOptions [private]
 

OptionList IDEA::CommandLineParser::m_Options [private]
 


Contact information
© IDEA
Generated on Fri Feb 3 17:09:45 2006 for IDEA.