openMSX
RomInfoTopic.cc
Go to the documentation of this file.
1 #include "RomInfoTopic.hh"
2 #include "RomInfo.hh"
3 #include "TclObject.hh"
4 #include "CommandException.hh"
5 
6 using std::vector;
7 using std::string;
8 
9 namespace openmsx {
10 
12  : InfoTopic(openMSXInfoCommand, "romtype")
13 {
14 }
15 
17 {
18  switch (tokens.size()) {
19  case 2: {
21  break;
22  }
23  case 3: {
24  RomType type = RomInfo::nameToRomType(tokens[2].getString());
25  if (type == ROM_UNKNOWN) {
26  throw CommandException("Unknown rom type");
27  }
28  result.addDictKeyValues("description", RomInfo::getDescription(type),
29  "blocksize", int(RomInfo::getBlockSize(type)));
30  break;
31  }
32  default:
33  throw CommandException("Too many parameters");
34  }
35 }
36 
37 string RomInfoTopic::help(const vector<string>& /*tokens*/) const
38 {
39  return "Shows a list of supported rom types. "
40  "Or show info on a specific rom type.";
41 }
42 
43 void RomInfoTopic::tabCompletion(vector<string>& tokens) const
44 {
45  if (tokens.size() == 3) {
46  completeString(tokens, RomInfo::getAllRomTypes(), false);
47  }
48 }
49 
50 } // namespace openmsx
openmsx::CommandException
Definition: CommandException.hh:8
openmsx::RomInfoTopic::tabCompletion
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this topic.
Definition: RomInfoTopic.cc:43
TclObject.hh
openmsx::InfoTopic
Definition: InfoTopic.hh:15
openmsx::RomInfoTopic::help
std::string help(const std::vector< std::string > &tokens) const override
Print help for this topic.
Definition: RomInfoTopic.cc:37
span
Definition: span.hh:34
openmsx::TclObject::addListElements
void addListElements(ITER first, ITER last)
Definition: TclObject.hh:122
openmsx::Completer::completeString
static void completeString(std::vector< std::string > &tokens, ITER begin, ITER end, bool caseSensitive=true)
Definition: Completer.hh:125
openmsx::InfoCommand
Definition: InfoCommand.hh:11
openmsx::TclObject::addDictKeyValues
void addDictKeyValues(Args &&... args)
Definition: TclObject.hh:138
openmsx::RomInfoTopic::RomInfoTopic
RomInfoTopic(InfoCommand &openMSXInfoCommand)
Definition: RomInfoTopic.cc:11
openmsx::RomInfo::nameToRomType
static RomType nameToRomType(std::string_view name)
Definition: RomInfo.cc:190
openmsx::RomInfo::getAllRomTypes
static std::vector< std::string_view > getAllRomTypes()
Definition: RomInfo.cc:207
span::size
constexpr index_type size() const noexcept
Definition: span.hh:296
RomInfo.hh
openmsx::RomInfo::getBlockSize
static unsigned getBlockSize(RomType type)
Definition: RomInfo.cc:227
openmsx::RomInfoTopic::execute
void execute(span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
Definition: RomInfoTopic.cc:16
openmsx::RomInfo::getDescription
static std::string_view getDescription(RomType type)
Definition: RomInfo.cc:218
openmsx::ROM_UNKNOWN
@ ROM_UNKNOWN
Definition: RomTypes.hh:92
openmsx::TclObject
Definition: TclObject.hh:21
openmsx::RomType
RomType
Definition: RomTypes.hh:6
CommandException.hh
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
RomInfoTopic.hh