LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
Public Member Functions | List of all members
loos::OptionsFramework::RequiredArguments Class Reference

Provides simple way to add command-line arguments (required options) More...

#include <OptionsFramework.hpp>

Inheritance diagram for loos::OptionsFramework::RequiredArguments:
Inheritance graph
[legend]
Collaboration diagram for loos::OptionsFramework::RequiredArguments:
Collaboration graph
[legend]

Public Member Functions

 RequiredArguments (const std::string &argname, const std::string &argdesc)
 
void addArgument (const std::string &name, const std::string &description)
 Add a required argument given a name (tag) and a description (currently unused)
 
void addVariableArguments (const std::string &name, const std::string &description)
 Add a required argument that can be an arbitrary number of items.
 
std::string value (const std::string &s) const
 Retrieve the value for an argument.
 
std::vector< std::string > variableValues (const std::string &s) const
 Retrieve the variable-number argument.
 
- Public Member Functions inherited from loos::OptionsFramework::OptionsPackage
virtual void addGeneric (po::options_description &opts)
 Appends generic options (those that the user can see)
 

Detailed Description

Provides simple way to add command-line arguments (required options)

This class handles required command-line options (also known as command line arguments). Each argument is defined by a string tag and a description and is parsed from the command line as a string. Arguments are added via the addOption() method and the values are retrieved using value().

Since these are required options, the class will automatically generate a parsing error if any argument is unset.

The value returned for options are strings and must be parsed into the appropriate type. A simple way to do this is to use loos::parseStringAs<>.

Example:

ropts->addArgument("name", "Name of data file");
ropts->addArgument("scale", "Scaling to apply to data");
...
string name = ropts->value("name");
double scale = parseStringAs<double>(ropts->value("scale"));
Simple matrix template class using policy classes to determine behavior.
Definition MatrixImpl.hpp:148
Provides simple way to add command-line arguments (required options)
Definition OptionsFramework.hpp:664

The case where one or more arguments are required is supported via the RequiredArguments::addVariableArguments() and RequiredArguments::variableValues(). If this feature is used, then the RequiredArguments object must be the last OptionsPackage chained together in the AggregateOptions object.

Member Function Documentation

◆ addVariableArguments()

void loos::OptionsFramework::RequiredArguments::addVariableArguments ( const std::string & name,
const std::string & description )

Add a required argument that can be an arbitrary number of items.

This argument will always appear at the end of the command line, after all other required arguments. It also means that the RequiredOptions object should be the last one added to the AggregateOptions object, otherwise any subsequence positional arguments will be missed.

Example:

ropts->addVariableArguments("selection", "selection");
...
vector<string> selections = ropts->variableValues("selection");

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