openMSX
CLIOption.cc
Go to the documentation of this file.
1 #include "CLIOption.hh"
2 #include "MSXException.hh"
3 #include <algorithm>
4 
5 using std::string;
6 
7 namespace openmsx {
8 
9 // class CLIOption
10 
11 string CLIOption::getArgument(const string& option, array_ref<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.pop_front();
18  return argument;
19 }
20 
21 string CLIOption::peekArgument(const array_ref<string>& cmdLine) const
22 {
23  return cmdLine.empty() ? "" : cmdLine.front();
24 }
25 
26 } // namespace openmsx
void pop_front()
Definition: array_ref.hh:91
const T & front() const
Definition: array_ref.hh:69
std::string getArgument(const std::string &option, array_ref< std::string > &cmdLine) const
Definition: CLIOption.cc:11
This class implements a subset of the proposal for std::array_ref (proposed for the next c++ standard...
Definition: array_ref.hh:19
bool empty() const
Definition: array_ref.hh:62
std::string peekArgument(const array_ref< std::string > &cmdLine) const
Definition: CLIOption.cc:21