Parses the command line - throws errors. This must be called after the options are in but before the rest of the program.
| 5702 | /// Parses the command line - throws errors. |
| 5703 | /// This must be called after the options are in but before the rest of the program. |
| 5704 | void parse(int argc, const char *const *argv) { |
| 5705 | // If the name is not set, read from command line |
| 5706 | if (name_.empty() || has_automatic_name_) { |
| 5707 | has_automatic_name_ = true; |
| 5708 | name_ = argv[0]; |
| 5709 | } |
| 5710 | |
| 5711 | std::vector<std::string> args; |
| 5712 | args.reserve(static_cast<std::size_t>(argc) - 1); |
| 5713 | for (int i = argc - 1; i > 0; i--) args.emplace_back(argv[i]); |
| 5714 | parse(std::move(args)); |
| 5715 | } |
| 5716 | |
| 5717 | /// Parse a single string as if it contained command line arguments. |
| 5718 | /// This function splits the string into arguments then calls parse(std::vector<std::string> &) |