#include "input_parsing.h" #include "constants.h" #include #include #include ProgramOptions get_params(int argc, char *argv[]) { int max_range = MAX_VALUES, num_entries = DEFAULT_NR_ENTRIES; bool is_seed_specified = false; static struct option long_options[] = { {"max-range", required_argument, 0, 'm' }, {"num-entries", required_argument, 0, 'n' }, {"seed", required_argument, 0, 's' }, {0, 0, 0, 0 } }; int option, option_index, seed = 0; while (( option = getopt_long(argc, argv, "m:n:s:", long_options, &option_index))) { if (option == -1) { break; } switch (option) { case 'm': max_range = atoi(optarg); break; case 'n': num_entries = atoi(optarg); break; case 's': is_seed_specified = true; seed = atoi(optarg); break; default: std::cerr << "Incorrect character code returned: %d" << option; } } using return_type = std::optional; return {max_range, num_entries, is_seed_specified ? return_type(seed): std::nullopt}; }