|
tgen
|
Registering and opts parsing. More...
Functions | |
| bool | tgen::has_opt (std::size_t index) |
| Checks if opt at some index exists. | |
| bool | tgen::has_opt (const std::string &key) |
| Checks if opt with with some key exists. | |
| template<typename T, typename Key> | |
| T | tgen::opt (const Key &key, std::optional< T > default_value=std::nullopt) |
| Gets opt by key. | |
| void | tgen::register_gen (int argc, char **argv) |
| Sets up the generator. | |
Registering and opts parsing.
The first line of your generator should be:
This does two things:
Opts are a list of either named or positional options.
Named options is given in one of the following formats:
Positional options are numbered from 0 sequentially.
For example, if you compile your code to a.out, calling ./a.out -n 10 str –q=5 -1.1e2 results in the following opts:
You can consume the opts by using opt<>:
|
inline |
Checks if opt with with some key exists.
| key | Key of named opt. |
|
inline |
| T tgen::opt | ( | const Key & | key, |
| std::optional< T > | default_value = std::nullopt ) |
Gets opt by key.
| T | Type of the opt. |
| key | Key to fetch. If it is of type int, considered to be an index. Otherwise, considered to be a std::string named opt key. |
| default_value | Default value to be returned, if key is not found. |
| std::runtime_error | if opt is not found and default_value is not given. |
|
inline |
Sets up the generator.
| argc | Argument count, from the main function. |
| argv | Argument vector, from the main function. |
Sets up the opts, and the seed of the random number generator. The seed is dependent on the arguments (excluding the executable name).