openMSX
CLIOption.cc
Go to the documentation of this file.
1 #include "CLIOption.hh"
2 #include "MSXException.hh"
3 #include <utility>
4 
5 using std::string;
6 
7 namespace openmsx {
8 
9 // class CLIOption
10 
11 string CLIOption::getArgument(const string& option, span<string>& cmdLine) const
12 {
13  if (cmdLine.empty()) {
14  throw FatalError("Missing argument for option \"", option, '\"');
15  }
16  string argument = std::move(cmdLine.front());
17  cmdLine = cmdLine.subspan(1);
18  return argument;
19 }
20 
21 string CLIOption::peekArgument(const span<string>& cmdLine) const
22 {
23  return cmdLine.empty() ? string{} : cmdLine.front();
24 }
25 
26 } // namespace openmsx
span::empty
constexpr bool empty() const noexcept
Definition: span.hh:300
openmsx::CLIOption::peekArgument
std::string peekArgument(const span< std::string > &cmdLine) const
Definition: CLIOption.cc:21
MSXException.hh
span::subspan
constexpr subspan_return_t< Offset, Count > subspan() const
Definition: span.hh:266
span::front
constexpr reference front() const
Definition: span.hh:310
span
Definition: span.hh:126
openmsx::FatalError
Definition: MSXException.hh:31
CLIOption.hh
openmsx::CLIOption::getArgument
std::string getArgument(const std::string &option, span< std::string > &cmdLine) const
Definition: CLIOption.cc:11
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5