EleFits  5.3.0
A modern C++ API on top of CFITSIO
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Public Member Functions | List of all members
ProgramOptions Class Reference

#include <ProgramOptions.h>

Detailed Description

Helper class to declare positional and named options, and help message.

Here is an example use case for the following command line:

Program <positional> --named1 <value1> --named2 <value2> 

Let's assume that the help message is provided in a file help.txt in the auxiliary directory.

In the associated Elements::Program, override defineProgramArguments() as follows:

auto options = ProgramOptions::from_auxdir("help.txt");
options.positional("positional", value<std::string>(), "Positional option");
options.named("named1", value<int>(), "Named option 1");
options.named("named2", value<int>(), "Named option 2");
return options.as_pair();
}
Examples
EleFitsBintableExample.cpp.

Public Types

using OptionsDescription = boost::program_options::options_description
 Same alias as Elements::Program::OptionsDescription.
 
using PositionalOptionsDescription = boost::program_options::positional_options_description
 Same alias as Elements::Program::PositionalOptionsDescription.
 
using ValueSemantics = boost::program_options::value_semantic
 Shortcut to Boost's class.
 

Static Public Member Functions

static ProgramOptions from_aux_file (const std::string &help_file)
 Create option descriptions from help file. More...
 

Public Member Functions

 ProgramOptions (const std::string &help_message="")
 Create option descriptions with help message. More...
 
 ~ProgramOptions ()=default
 Destructor.
 
std::pair< OptionsDescription, PositionalOptionsDescriptionas_pair () const
 Get the named and positional option descriptions. More...
 
void flag (const char *name, const char *description)
 Add a flag. More...
 
template<typename T >
void named (const char *name, const char *description)
 Add a named option.
 
template<typename T >
void named (const char *name, const char *description, T default_value)
 Add a named option with default value.
 
void named (const char *name, const ValueSemantics *value, const char *description)
 Add a named option. More...
 
template<typename T >
void positional (const char *name, const char *description)
 Add a positional option.
 
template<typename T >
void positional (const char *name, const char *description, T default_value)
 Add a positional option with default value.
 
void positional (const char *name, const ValueSemantics *value, const char *description)
 Add a positional option. More...
 

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