CLIOption.cc 557 B

123456789101112131415161718192021222324252627
  1. #include "CLIOption.hh"
  2. #include "MSXException.hh"
  3. #include <utility>
  4. using std::string;
  5. namespace openmsx {
  6. // class CLIOption
  7. string CLIOption::getArgument(const string& option, span<string>& cmdLine) const
  8. {
  9. if (cmdLine.empty()) {
  10. throw FatalError("Missing argument for option \"", option, '\"');
  11. }
  12. string argument = std::move(cmdLine.front());
  13. cmdLine = cmdLine.subspan(1);
  14. return argument;
  15. }
  16. string CLIOption::peekArgument(const span<string>& cmdLine) const
  17. {
  18. return cmdLine.empty() ? string{} : cmdLine.front();
  19. }
  20. } // namespace openmsx