Main Page   Class Hierarchy   Compound List   File List   Compound Members  

MFUtil::GetOptions Class Reference

#include <GetOptions.h>

List of all members.

Public Methods

 GetOptions (void)
 GetOptions (const std::string &p_command_line)
void setCommandLine (const std::string &p_command)
void setSeparator (const std::string &p_sep)
std::string getCommandLine (void) const
std::string getSeparator (void) const
void addOption (const std::string &p_option, const bool p_has_argument=false, const bool p_is_optional=true)
bool hasOption (const std::string &p_option) const
bool parse (void)
bool hasArgument (const std::string &p_option) const
bool hasArgument (const std::string &p_option, std::vector< std::string > &p_arguments) const


Detailed Description

Class to help parsing a UNIX like command line where '-' are used to signify a new option: myprogram -a 3.4 -i -d.


Constructor & Destructor Documentation

MFUtil::GetOptions::GetOptions void   
 

Constructor.

MFUtil::GetOptions::GetOptions const std::string &    p_command_line
 

Constructor.

Parameters:
p_command_line  Is the text to be parsed.


Member Function Documentation

void MFUtil::GetOptions::addOption const std::string &    p_option,
const bool    p_has_argument = false,
const bool    p_is_optional = true
 

Define an additional option that is seeked by the parser.

Parameters:
p_option  Option identifier. For example: -hello. Here p_option is "hello"
p_has_argument  Is 'true' if an argument is to be expected. For example -avalue 3.0. If no argument is expected, it is set to 'false'. The more than one argument might also be used when p_has_argument is set to 'true': -values 3.2 1.9 6.4.
p_is_optional  When the defined option is missing, this will constitute a parsing error unless p_is_optional is set to 'true'.

std::string MFUtil::GetOptions::getCommandLine void    const [inline]
 

Return the command line that is being parsed.

std::string MFUtil::GetOptions::getSeparator void    const [inline]
 

Return the character used to identify a new option. Default '-'.

bool MFUtil::GetOptions::hasArgument const std::string &    p_option,
std::vector< std::string > &    p_arguments
const
 

Return 'true' if the option name 'p_option' is found and as at least one argument.

Parameters:
p_option  Option name.
p_arguments  This vector is cleared and filled with the argument list following the option found in the text to parse.

bool MFUtil::GetOptions::hasArgument const std::string &    p_option const
 

Return 'true' if the option name 'p_option' is found and has at least one argument.

bool MFUtil::GetOptions::hasOption const std::string &    p_option const
 

Return 'true' if the option p_option is already part of the option list to be parsed.

bool MFUtil::GetOptions::parse void   
 

Parse the pre-set text (command line).

void MFUtil::GetOptions::setCommandLine const std::string &    p_command [inline]
 

Assign the text to be parsed.

void MFUtil::GetOptions::setSeparator const std::string &    p_sep [inline]
 

Set the character used to identify a new option. Default '-'.


The documentation for this class was generated from the following file:
Generated on Sat Nov 4 15:59:01 2006 for GLARE by doxygen1.2.18