vSMC
vSMC: Scalable Monte Carlo
Public Member Functions | List of all members
vsmc::ProgramOptionMap Class Reference

A map of ProgramOption. More...

#include <vsmc/utility/program_option.hpp>

Public Member Functions

 ProgramOptionMap (bool silent=false, bool auto_help=true)
 
 ProgramOptionMap (const ProgramOptionMap &other)
 
 ProgramOptionMap (ProgramOptionMap &&other)
 
 ~ProgramOptionMap ()
 
template<typename T >
ProgramOptionMapadd (const std::string &name, const std::string &desc, T *ptr)
 Add an option with a single value. More...
 
template<typename T , typename V >
ProgramOptionMapadd (const std::string &name, const std::string &desc, T *ptr, V val)
 Add an option with a single value, with a default value. More...
 
template<typename T >
ProgramOptionMapadd (const std::string &name, const std::string &desc, std::vector< T > *ptr)
 Add an option with multiple value. More...
 
template<typename T , typename V >
ProgramOptionMapadd (const std::string &name, const std::string &desc, std::vector< T > *ptr, V val)
 Add an option with multiple value, with a default value. More...
 
void auto_help (bool flag)
 Set the auto_help flag, if true, help information is printed automatically when the --help option is processed. More...
 
std::size_t count (const std::string &name) const
 Count the number of successful processing of an option. More...
 
ProgramOptionMapoperator= (const ProgramOptionMap &other)
 
ProgramOptionMapoperator= (ProgramOptionMap &&other)
 
const ProgramOptionoption (const std::string &name) const
 Get the underlying option object. More...
 
ProgramOptionoption (const std::string &name)
 Get the underlying option object. More...
 
void print_help (std::ostream &os=std::cout) const
 Print help information for each option. More...
 
void process (int argc, const char **argv, std::ostream &os=std::cout)
 Process the options. More...
 
void process (int argc, char **argv, std::ostream &os=std::cout)
 Process the options. More...
 
ProgramOptionMapremove (const std::string &name)
 
void silent (bool flag)
 Set the silent flag, if true, no warning messages will be printed for unknown options etc.,. More...
 

Detailed Description

A map of ProgramOption.

Definition at line 327 of file program_option.hpp.

Constructor & Destructor Documentation

vsmc::ProgramOptionMap::ProgramOptionMap ( bool  silent = false,
bool  auto_help = true 
)
inlineexplicit

Definition at line 335 of file program_option.hpp.

vsmc::ProgramOptionMap::ProgramOptionMap ( const ProgramOptionMap other)
inline

Definition at line 344 of file program_option.hpp.

vsmc::ProgramOptionMap::ProgramOptionMap ( ProgramOptionMap &&  other)
inline

Definition at line 381 of file program_option.hpp.

vsmc::ProgramOptionMap::~ProgramOptionMap ( )
inline

Definition at line 408 of file program_option.hpp.

Member Function Documentation

template<typename T >
ProgramOptionMap& vsmc::ProgramOptionMap::add ( const std::string &  name,
const std::string &  desc,
T *  ptr 
)
inline

Add an option with a single value.

Parameters
nameName of the option, on command name it shall be specified by --name
descA descritpion stream of the option
ptrThe destination that store the option value

Definition at line 424 of file program_option.hpp.

template<typename T , typename V >
ProgramOptionMap& vsmc::ProgramOptionMap::add ( const std::string &  name,
const std::string &  desc,
T *  ptr,
val 
)
inline

Add an option with a single value, with a default value.

Definition at line 437 of file program_option.hpp.

template<typename T >
ProgramOptionMap& vsmc::ProgramOptionMap::add ( const std::string &  name,
const std::string &  desc,
std::vector< T > *  ptr 
)
inline

Add an option with multiple value.

Definition at line 450 of file program_option.hpp.

template<typename T , typename V >
ProgramOptionMap& vsmc::ProgramOptionMap::add ( const std::string &  name,
const std::string &  desc,
std::vector< T > *  ptr,
val 
)
inline

Add an option with multiple value, with a default value.

Definition at line 463 of file program_option.hpp.

void vsmc::ProgramOptionMap::auto_help ( bool  flag)
inline

Set the auto_help flag, if true, help information is printed automatically when the --help option is processed.

Definition at line 587 of file program_option.hpp.

std::size_t vsmc::ProgramOptionMap::count ( const std::string &  name) const
inline

Count the number of successful processing of an option.

Definition at line 552 of file program_option.hpp.

ProgramOptionMap& vsmc::ProgramOptionMap::operator= ( const ProgramOptionMap other)
inline

Definition at line 357 of file program_option.hpp.

ProgramOptionMap& vsmc::ProgramOptionMap::operator= ( ProgramOptionMap &&  other)
inline

Definition at line 393 of file program_option.hpp.

const ProgramOption* vsmc::ProgramOptionMap::option ( const std::string &  name) const
inline

Get the underlying option object.

Definition at line 562 of file program_option.hpp.

ProgramOption* vsmc::ProgramOptionMap::option ( const std::string &  name)
inline

Get the underlying option object.

Definition at line 572 of file program_option.hpp.

void vsmc::ProgramOptionMap::print_help ( std::ostream &  os = std::cout) const
inline

Print help information for each option.

Definition at line 528 of file program_option.hpp.

void vsmc::ProgramOptionMap::process ( int  argc,
const char **  argv,
std::ostream &  os = std::cout 
)
inline

Process the options.

If the option --help is given at the commad line, help information are printed.

Parameters
argcThe first argument of the main function
argvThe second argument of the main function
osThe output stream used to print help information if auto_help is set to true, and the warning messages if any error occurs when processing the options.

Definition at line 500 of file program_option.hpp.

void vsmc::ProgramOptionMap::process ( int  argc,
char **  argv,
std::ostream &  os = std::cout 
)
inline

Process the options.

Definition at line 514 of file program_option.hpp.

ProgramOptionMap& vsmc::ProgramOptionMap::remove ( const std::string &  name)
inline

Definition at line 474 of file program_option.hpp.

void vsmc::ProgramOptionMap::silent ( bool  flag)
inline

Set the silent flag, if true, no warning messages will be printed for unknown options etc.,.

Definition at line 583 of file program_option.hpp.