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 namespace openmsx {
7 
9  : InfoTopic(openMSXInfoCommand, "romtype")
10 {
11 }
12 
14 {
15  switch (tokens.size()) {
16  case 2: {
18  break;
19  }
20  case 3: {
21  RomType type = RomInfo::nameToRomType(tokens[2].getString());
22  if (type == ROM_UNKNOWN) {
23  throw CommandException("Unknown rom type");
24  }
25  result.addDictKeyValues("description", RomInfo::getDescription(type),
26  "blocksize", int(RomInfo::getBlockSize(type)));
27  break;
28  }
29  default:
30  throw CommandException("Too many parameters");
31  }
32 }
33 
34 std::string RomInfoTopic::help(span<const TclObject> /*tokens*/) const
35 {
36  return "Shows a list of supported rom types. "
37  "Or show info on a specific rom type.";
38 }
39 
40 void RomInfoTopic::tabCompletion(std::vector<std::string>& tokens) const
41 {
42  if (tokens.size() == 3) {
43  completeString(tokens, RomInfo::getAllRomTypes(), false);
44  }
45 }
46 
47 } // namespace openmsx
static void completeString(std::vector< std::string > &tokens, ITER begin, ITER end, bool caseSensitive=true)
Definition: Completer.hh:133
void execute(span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
Definition: RomInfoTopic.cc:13
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this topic.
Definition: RomInfoTopic.cc:40
RomInfoTopic(InfoCommand &openMSXInfoCommand)
Definition: RomInfoTopic.cc:8
std::string help(span< const TclObject > tokens) const override
Print help for this topic.
Definition: RomInfoTopic.cc:34
static unsigned getBlockSize(RomType type)
Definition: RomInfo.cc:195
static std::string_view getDescription(RomType type)
Definition: RomInfo.cc:190
static auto getAllRomTypes()
Definition: RomInfo.hh:69
static RomType nameToRomType(std::string_view name)
Definition: RomInfo.cc:174
void addListElements(ITER first, ITER last)
Definition: TclObject.hh:130
void addDictKeyValues(Args &&... args)
Definition: TclObject.hh:146
Definition: span.hh:126
constexpr index_type size() const noexcept
Definition: span.hh:296
This file implemented 3 utility functions:
Definition: Autofire.cc:9
@ ROM_UNKNOWN
Definition: RomTypes.hh:90