17 bool requireModulePrefix,
bool isAdvanced, std::vector<std::shared_ptr<ArgumentBase>>
const&
optionArguments)
30 "Unable to unify two options, because their argument count differs.");
32 for (
size_t i = 0; i != this->arguments.size(); i++) {
37 "Unable to unify two options, because their arguments are incompatible.");
66 return this->arguments.size();
82 "Unable to retrieve argument with unknown name '" <<
argumentName <<
"'.");
89 "Unable to retrieve argument with unknown name '" <<
argumentName <<
"'.");
94 return this->longName;
98 return this->hasShortName;
102 return this->shortName;
106 return this->description;
110 return this->moduleName;
114 return this->isRequired;
118 return this->requireModulePrefix;
122 return this->isAdvanced;
126 return this->hasBeenSet;
130 return this->hasBeenSetWithModulePrefix;
140 moduleName(moduleName),
142 requireModulePrefix(requireModulePrefix),
143 isAdvanced(isAdvanced),
145 hasBeenSetWithModulePrefix(
false),
149 STORM_LOG_THROW(!longName.empty(), storm::exceptions::IllegalArgumentException,
"Unable to construct option with empty name.");
150 STORM_LOG_THROW(!moduleName.empty(), storm::exceptions::IllegalArgumentException,
"Unable to construct option with empty module name.");
153 std::find_if(longName.begin(), longName.end(), [](
char c) { return !(std::isalpha(c) || std::isdigit(c) || c ==
'-' || c ==
'_'); }) != longName.end();
155 "Unable to construct option with illegal long name '" << longName <<
"'.");
158 return !(std::isalpha(c) || std::isdigit(c) || c ==
'c' || c ==
'_');
159 }) != shortName.end();
161 "Unable to construct option with illegal short name '" << shortName <<
"'.");
164 for (
auto const&
argument : arguments) {
169void Option::setHasOptionBeenSet(
bool newValue) {
173void Option::setHasOptionBeenSetWithModulePrefix(
bool newValue) {
174 this->hasBeenSetWithModulePrefix =
newValue;
190 length +=
argument->getName().size() + 3;
197 return this->arguments;
204 out << std::setw(0) <<
"--";
206 if (!
option.getRequiresModulePrefix()) {
212 if (!
option.getRequiresModulePrefix()) {
218 if (
option.getHasShortName()) {
219 out <<
" (" <<
option.getShortName() <<
")";
223 if (
option.getArgumentCount() > 0) {
This class serves as the (untemplated) base class of argument classes.
This class subclasses the argument base to actually implement the pure virtual functions.
This class represents one command-line option.
bool getHasShortName() const
Retrieves whether this option has a short name.
std::string const & getModuleName() const
Retrieves the name of the module to which this option belongs.
std::string const & getDescription() const
Retrieves the description of the option.
uint_fast64_t getArgumentCount() const
Retrieves the argument count this option expects.
ArgumentBase const & getArgumentByName(std::string const &argumentName) const
Returns a reference to the argument with the specified long name.
bool getHasOptionBeenSetWithModulePrefix() const
Retrieves whether the option has been set by including the module prefix.
std::string const & getShortName() const
Retrieves the short name of this option.
std::vector< std::shared_ptr< ArgumentBase > > const & getArguments() const
Retrieves the arguments of the option.
bool getIsAdvanced() const
Retrieves whether the option is only displayed in the advanced help.
ArgumentBase const & getArgument(uint_fast64_t argumentIndex) const
Retrieves the i-th argument of this option.
std::string const & getLongName() const
Retrieves the long name of this option.
uint_fast64_t getPrintLength() const
Retrieves the (print) length of the option.
bool getRequiresModulePrefix() const
Retrieves whether the option requires the module name as a prefix.
Option(std::string const &moduleName, std::string const &longOptionName, std::string const &optionDescription, bool isOptionRequired, bool requireModulePrefix, bool isAdvanced, std::vector< std::shared_ptr< ArgumentBase > > const &optionArguments=std::vector< std::shared_ptr< ArgumentBase > >())
Creates an option with the given parameters.
bool getIsRequired() const
Retrieves whether the option is required.
bool getHasOptionBeenSet() const
Retrieves whether the option has been set.
bool isCompatibleWith(Option const &other)
Checks whether the given option is compatible with the current one.
#define STORM_LOG_THROW(cond, exception, message)
SettingsType const & getModule()
Get module.
std::ostream & operator<<(std::ostream &out, ArgumentBase const &argument)