RobWorkProject  24.5.15-
Public Member Functions | List of all members
ProgramOptions Class Reference

a class for parsing program command line into a PropertyMap More...

#include <ProgramOptions.hpp>

Public Member Functions

 ProgramOptions (const std::string &applicationName, const std::string &version)
 Construct new set of program options. More...
 
void initOptions ()
 this initialize default options that can add simple properties to the propertymap.
 
void addStringOption (const std::string &name, const std::string &defval, const std::string &desc)
 add a string option that is only allowed to occur once on the command line More...
 
void addBoolOption (const std::string &name, bool defval, const std::string &desc)
 add a bool option that is only allowed to occur once on the command line More...
 
void setPositionalOption (const std::string &name, int i)
 Set name of option number i. More...
 
int parse (int argc, char **argv)
 parses input, if More...
 
int parse (const std::string &string)
 Parses input from a string. More...
 
boost::program_options::options_description & getOptionDescription ()
 Get the underlying program options description from boost. More...
 
boost::program_options::positional_options_description & getPosOptionDescription ()
 Get the underlying positional program options description from boost. More...
 
rw::core::PropertyMap getPropertyMap ()
 Get parsed properties in RobWork format in the form of a PropertyMap. More...
 

Detailed Description

a class for parsing program command line into a PropertyMap

Constructor & Destructor Documentation

◆ ProgramOptions()

ProgramOptions ( const std::string &  applicationName,
const std::string &  version 
)
inline

Construct new set of program options.

Parameters
applicationName[in] the name of the application.
version[in] the version of the application.

Member Function Documentation

◆ addBoolOption()

void addBoolOption ( const std::string &  name,
bool  defval,
const std::string &  desc 
)

add a bool option that is only allowed to occur once on the command line

Parameters
name[in] name of option
defval[in] the default value when arg not present
desc[in] description of commandline option

◆ addStringOption()

void addStringOption ( const std::string &  name,
const std::string &  defval,
const std::string &  desc 
)

add a string option that is only allowed to occur once on the command line

Parameters
name[in] name of option
defval[in] the default string value if any
desc[in] description of commandline option

◆ getOptionDescription()

boost::program_options::options_description& getOptionDescription ( )
inline

Get the underlying program options description from boost.

Returns
reference to options_description.

◆ getPosOptionDescription()

boost::program_options::positional_options_description& getPosOptionDescription ( )
inline

Get the underlying positional program options description from boost.

Returns
reference to positional_options_description.

◆ getPropertyMap()

rw::core::PropertyMap getPropertyMap ( )
inline

Get parsed properties in RobWork format in the form of a PropertyMap.

Returns
the property map with parsed options.

◆ parse() [1/2]

int parse ( const std::string &  string)

Parses input from a string.

Parameters
string[in] input line.
Returns
0 if success.

◆ parse() [2/2]

int parse ( int  argc,
char **  argv 
)

parses input, if

Parameters
argc
argv
Returns
if 0 is returned then help or an error

◆ setPositionalOption()

void setPositionalOption ( const std::string &  name,
int  i 
)

Set name of option number i.

Parameters
name[in] the name.
i[in] index of the option.

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