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