The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::app::MultiDetailOptions Class Referencefinal

Class for containing multiple levels of boost program options. More...

#include <MultiDetailOptions.hpp>

Classes

class  OptAdder
 Helper class for chained calls to add_options. More...
 

Public Types

typedef uint32_t level_t
 

Public Member Functions

 MultiDetailOptions (const MultiDetailOptions &)=delete
 Not copy-constructable.
 
MultiDetailOptionsoperator= (const MultiDetailOptions &)=delete
 Not assignable.
 
 MultiDetailOptions ()=delete
 Not default-constructable.
 
 MultiDetailOptions (const std::string &name, uint32_t w=80, uint32_t hw=40)
 Construction with group nam.
 
const po::options_description & getOptionsLevelUpTo (level_t level) const
 Gets the description object for a particular level if that level exists. If that level does not exist, returns the highest level less than level where options exist. Will never throw because VERBOSE is guaranteed to exist. Only VERBOSE and BRIEF levels are guaranteed to exist.
 
const po::options_description & getOptionsLevel (level_t level) const
 Gets the description object for a particular level. Only VERBOSE and BRIEF levels are guaranteed to exist.
 
const po::options_description & getVerboseOptions () const noexcept
 Gets the description object for the VERBOSE level.
 
size_t getNumLevels () const
 Returns the number of levels that have an options description which can be retrieved through getLevel.
 
template<typename ... Args>
OptAdderadd_options (const char *name, const char *verbose_desc, const Args &...args)
 Add an option with NO value semantic and any number of descriptions. See the other add_options signature for details.
 
template<typename ... Args>
OptAdderadd_options (const char *name, const boost::program_options::value_semantic *s, const char *verbose_desc, const Args &...args)
 Add an option with a value semantic and any number of descriptions.
 
OptAdderadd_options ()
 Empty add_options shell allowing the start of chained calls (exists solely to mimic boost's syntax)
 

Static Public Attributes

static const level_t VERBOSE = 0
 
static const level_t BRIEF = 1
 

Friends

class OptAdded
 Allow access to private adding methods.
 

Detailed Description

Class for containing multiple levels of boost program options.

Definition at line 293 of file MultiDetailOptions.hpp.

Member Typedef Documentation

◆ level_t

typedef uint32_t sparta::app::MultiDetailOptions::level_t

Definition at line 297 of file MultiDetailOptions.hpp.

Constructor & Destructor Documentation

◆ MultiDetailOptions()

sparta::app::MultiDetailOptions::MultiDetailOptions ( const std::string &  name,
uint32_t  w = 80,
uint32_t  hw = 40 
)
inline

Construction with group nam.

Postcondition
Ensures that the VERBOSE options entry and BRIEF entries exist

Definition at line 367 of file MultiDetailOptions.hpp.

Member Function Documentation

◆ add_options() [1/3]

OptAdder & sparta::app::MultiDetailOptions::add_options ( )
inline

Empty add_options shell allowing the start of chained calls (exists solely to mimic boost's syntax)

Example:

// MultiDetailOptions opts("foo");
opts.add_option()("bar",
"verbose description of bar",
"brief bar desc")

Definition at line 483 of file MultiDetailOptions.hpp.

◆ add_options() [2/3]

template<typename ... Args>
OptAdder & sparta::app::MultiDetailOptions::add_options ( const char *  name,
const boost::program_options::value_semantic *  s,
const char *  verbose_desc,
const Args &...  args 
)
inline

Add an option with a value semantic and any number of descriptions.

Template Parameters
...Argsvariadic argument container type. Automatically deduced by call signature
Parameters
nameName of the option to be interpreted by boost::program_options::options_description (e.g. "help,h").
sValue semantic. Typically something generated by the helper sparta::app::named_value or boost::program_options::value<T>().
verbose_descVerbose description. All options have a required verbose description so they show up in verbose help (which is practically a man page) and can be appropriately parsed by boost
...argsAdditional const char* description arguments (like verbose_desc). Each additional argument is assigned to the next higher options level for this option (name). If no additional descriptions are given, this option will not have an entry when the options are printed for that level. Generally, each additional level becomes more brief.

Example:

// MultiDetailOptions opts("foo");
opts.add_option("bar",
"verbose description of bar",
"brief bar desc")

Definition at line 461 of file MultiDetailOptions.hpp.

◆ add_options() [3/3]

template<typename ... Args>
OptAdder & sparta::app::MultiDetailOptions::add_options ( const char *  name,
const char *  verbose_desc,
const Args &...  args 
)
inline

Add an option with NO value semantic and any number of descriptions. See the other add_options signature for details.

Definition at line 425 of file MultiDetailOptions.hpp.

◆ getNumLevels()

size_t sparta::app::MultiDetailOptions::getNumLevels ( ) const
inline

Returns the number of levels that have an options description which can be retrieved through getLevel.

Definition at line 416 of file MultiDetailOptions.hpp.

◆ getOptionsLevel()

const po::options_description & sparta::app::MultiDetailOptions::getOptionsLevel ( level_t  level) const
inline

Gets the description object for a particular level. Only VERBOSE and BRIEF levels are guaranteed to exist.

Note
When actually parsing using these options, use the VERBOSE level
Exceptions
Exceptionif there is no options set at level

Definition at line 401 of file MultiDetailOptions.hpp.

◆ getOptionsLevelUpTo()

const po::options_description & sparta::app::MultiDetailOptions::getOptionsLevelUpTo ( level_t  level) const
inline

Gets the description object for a particular level if that level exists. If that level does not exist, returns the highest level less than level where options exist. Will never throw because VERBOSE is guaranteed to exist. Only VERBOSE and BRIEF levels are guaranteed to exist.

Note
When actually parsing using these options, use the VERBOSE level

Definition at line 386 of file MultiDetailOptions.hpp.

◆ getVerboseOptions()

const po::options_description & sparta::app::MultiDetailOptions::getVerboseOptions ( ) const
inlinenoexcept

Gets the description object for the VERBOSE level.

Definition at line 408 of file MultiDetailOptions.hpp.

Friends And Related Symbol Documentation

◆ OptAdded

friend class OptAdded
friend

Allow access to private adding methods.

Definition at line 346 of file MultiDetailOptions.hpp.

Member Data Documentation

◆ BRIEF

const level_t sparta::app::MultiDetailOptions::BRIEF = 1
static

Definition at line 300 of file MultiDetailOptions.hpp.

◆ VERBOSE

const level_t sparta::app::MultiDetailOptions::VERBOSE = 0
static

Definition at line 299 of file MultiDetailOptions.hpp.


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