Gromacs
2024.4
|
#include <gromacs/options/basicoptions.h>
Specifies an option that provides string values.
Examples:
Public methods in this class do not throw.
Public Types | |
typedef StringOptionInfo | InfoType |
OptionInfo subclass corresponding to this option type. | |
typedef std::string | ValueType |
Type that stores a single option value. | |
typedef StringOption | MyClass |
Alias for the derived class type. | |
Public Member Functions | |
StringOption (const char *name) | |
Initializes an option with the given name. | |
template<size_t count> | |
MyClass & | enumValue (const char *const (&values)[count]) |
Sets the option to only accept one of a fixed set of strings. More... | |
MyClass & | enumValueFromNullTerminatedArray (const char *const *values) |
Sets the option to only accept one of a fixed set of strings. More... | |
MyClass & | defaultEnumIndex (int index) |
Sets the default value using an index into the enumeration table. More... | |
MyClass & | description (const char *descr) |
Sets a description for the option. More... | |
MyClass & | hidden (bool bHidden=true) |
Hides the option from normal help output. | |
MyClass & | required (bool bRequired=true) |
Requires the option to be specified explicitly. More... | |
MyClass & | allowMultiple (bool bMulti=true) |
Allows the option to be specified multiple times. | |
MyClass & | valueCount (int count) |
Requires exactly count values for the option. | |
MyClass & | multiValue (bool bMulti=true) |
Allows any number of values for the option. | |
MyClass & | defaultValue (const std::string &defaultValue) |
Sets a default value for the option. More... | |
MyClass & | defaultValueIfSet (const std::string &defaultValue) |
Sets a default value for the option when it is set. More... | |
MyClass & | store (std::string *store) |
Stores value(s) in memory pointed by store . More... | |
MyClass & | storeCount (int *countptr) |
Stores number of values in the value pointed by countptr . More... | |
MyClass & | storeVector (std::vector< std::string > *store) |
Stores option values in the provided vector. More... | |
MyClass & | storeIsSet (bool *store) |
Stores whether the option was explicitly set. More... | |
|
inline |
Sets the default value using an index into the enumeration table.
Cannot be specified without enumValue().
|
inlineinherited |
Sets a default value for the option.
[in] | defaultValue | Default value. |
If the option is never set, the default value is copied to the assigned storage. Note that if the option is not set and there is no default value, the storage is not altered, which can also be used to provide a default value. The latter method has to be used if the option can take multiple values.
defaultValue
is copied when the option is created.
|
inlineinherited |
Sets a default value for the option when it is set.
[in] | defaultValue | Default value. |
This value is used if the option is set, but no value is provided. If the option is never set, the value set with defaultValue() is used. Can only be used for options that accept a single value.
defaultValue
is copied when the option is created.
|
inlineinherited |
Sets a description for the option.
[in] | descr | Description to set. |
String in descr
is copied when the option is created.
|
inline |
Sets the option to only accept one of a fixed set of strings.
[in] | values | Array of strings to accept. |
Also accepts prefixes of the strings; if a prefix matches more than one of the possible strings, the shortest one is used (in a tie, the first one is).
The strings are copied once the option is created.
|
inline |
Sets the option to only accept one of a fixed set of strings.
[in] | values | Array of strings to accept, with a NULL pointer following the last string. |
Works otherwise as the array version, but accepts a pointer to an array of undetermined length. The end of the array is indicated by a NULL pointer in the array.
|
inlineinherited |
Requires the option to be specified explicitly.
Note that if you specify defaultValue() together with required(), the user is not required to explicitly provide the option. In this case, required() only affects possible help output.
|
inlineinherited |
Stores value(s) in memory pointed by store
.
[in] | store | Storage for option value(s). |
The caller is responsible for allocating enough memory such that the any allowed number of values fits into the array pointed by store
. If there is no maximum allowed number or if the maximum is inconveniently large, storeVector() should be used.
For information on when values are available in the storage, see storeVector().
The pointer provided should remain valid as long as the associated Options object exists.
|
inlineinherited |
Stores number of values in the value pointed by countptr
.
[in] | countptr | Storage for the number of values. |
For information on when values are available in the storage, see storeVector().
The pointers provided should remain valid as long as the associated Options object exists.
|
inlineinherited |
Stores whether the option was explicitly set.
[in] | store | Variable to store the flag in. |
The value is set to false
on creation of the option, and to true
as soon as a value is assigned to the option. A default value does not set the flag to true
, but assignment that uses defaultValueIfSet() does.
The pointer provided should remain valid as long as the associated Options object exists.
|
inlineinherited |
Stores option values in the provided vector.
[in] | store | Vector to store option values in. |
Values are added to the vector after each successful set of values is parsed. Note that for some options, the value may be changed later, and is only guaranteed to be correct after Options::finish() has been called.
The pointer provided should remain valid as long as the associated Options object exists.