Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
CommandLineParser Class Reference

Easy management of command line. More...

#include <CommandLineParser.h>

Public Member Functions

void addOption (std::string optionName, std::string description)
 add an option (use –optionName on the command line to activate it)
 CommandLineParser (int argc, char *argv[])
 default constructor
std::vector< std::string > & getRemainingArguments ()
 get the remaining parameters (useful to open files by giving their names on the command line)
void help ()
 print help (but do not exit the application)
bool option (std::string)
 check for option
void parse ()
 parse command line and exit if application was call with help or version arguments or if an parsing error occurs
void setDescription (std::string description)
 set help string
void version ()
 print version (but do not exit the application)
virtual ~CommandLineParser ()
 destructor

Private Attributes

std::vector< std::string > arguments
 argv given from command line
std::string description
 the usage/help message
std::string name
 application name
std::map< std::string,
std::string > 
options
 list of all options+description
std::vector< std::string > remainingArguments
 position of remaining parameters (arguments)

Detailed Description

Easy management of command line.

By default –help displays the usage and –version displays the version.

Constructor & Destructor Documentation

CommandLineParser::CommandLineParser ( int  argc,
char *  argv[] 
)

default constructor

virtual CommandLineParser::~CommandLineParser ( )
inlinevirtual

destructor

Member Function Documentation

void CommandLineParser::addOption ( std::string  optionName,
std::string  description 
)

add an option (use –optionName on the command line to activate it)

Referenced by main().

std::vector< std::string > & CommandLineParser::getRemainingArguments ( )

get the remaining parameters (useful to open files by giving their names on the command line)

Referenced by main().

void CommandLineParser::help ( )

print help (but do not exit the application)

References description, and camitk::Core::version.

bool CommandLineParser::option ( std::string  option)

check for option

Referenced by main().

void CommandLineParser::parse ( )

parse command line and exit if application was call with help or version arguments or if an parsing error occurs

Referenced by main().

void CommandLineParser::setDescription ( std::string  description)

set help string

References description.

Referenced by main().

void CommandLineParser::version ( )

print version (but do not exit the application)

References camitk::Core::version.

Member Data Documentation

std::vector<std::string> CommandLineParser::arguments
private

argv given from command line

std::string CommandLineParser::description
private

the usage/help message

std::string CommandLineParser::name
private

application name

std::map<std::string, std::string> CommandLineParser::options
private

list of all options+description

std::vector<std::string> CommandLineParser::remainingArguments
private

position of remaining parameters (arguments)


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