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
Definition: span.hh:34
void execute(span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
Definition: RomInfoTopic.cc:16
static unsigned getBlockSize(RomType type)
Definition: RomInfo.cc:226
static RomType nameToRomType(std::string_view name)
Definition: RomInfo.cc:189
static std::vector< std::string_view > getAllRomTypes()
Definition: RomInfo.cc:206
RomInfoTopic(InfoCommand &openMSXInfoCommand)
Definition: RomInfoTopic.cc:11
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this topic.
Definition: RomInfoTopic.cc:43
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
std::string help(const std::vector< std::string > &tokens) const override
Print help for this topic.
Definition: RomInfoTopic.cc:37
static void completeString(std::vector< std::string > &tokens, ITER begin, ITER end, bool caseSensitive=true)
Definition: Completer.hh:125
void addDictKeyValues(Args &&... args)
Definition: TclObject.hh:138
static std::string_view getDescription(RomType type)
Definition: RomInfo.cc:217
void addListElements(ITER first, ITER last)
Definition: TclObject.hh:122