openMSX
RomInfo.hh
Go to the documentation of this file.
1 #ifndef ROMINFO_HH
2 #define ROMINFO_HH
3 
4 #include "RomTypes.hh"
5 #include "String32.hh"
6 #include <string_view>
7 #include <utility>
8 #include <vector>
9 
10 namespace openmsx {
11 
12 class RomInfo
13 {
14 public:
15  RomInfo(String32 title_, String32 year_,
16  String32 company_, String32 country_,
17  bool original_, String32 origType_,
18  String32 remark_, RomType romType_,
19  int genMSXid_)
20  : title (title_)
21  , year (year_)
22  , company (company_)
23  , country (country_)
24  , origType(origType_)
25  , remark (std::move(remark_))
26  , romType(romType_)
27  , genMSXid(genMSXid_)
28  , original(original_)
29  {
30  }
31 
32  std::string_view getTitle (const char* buf) const {
33  return fromString32(buf, title);
34  }
35  std::string_view getYear (const char* buf) const {
36  return fromString32(buf, year);
37  }
38  std::string_view getCompany (const char* buf) const {
39  return fromString32(buf, company);
40  }
41  std::string_view getCountry (const char* buf) const {
42  return fromString32(buf, country);
43  }
44  std::string_view getOrigType(const char* buf) const {
45  return fromString32(buf, origType);
46  }
47  std::string_view getRemark (const char* buf) const {
48  return fromString32(buf, remark);
49  }
50  RomType getRomType() const { return romType; }
51  bool getOriginal() const { return original; }
52  int getGenMSXid() const { return genMSXid; }
53 
54  static RomType nameToRomType(std::string_view name);
55  static std::string_view romTypeToName(RomType type);
56  static std::vector<std::string_view> getAllRomTypes();
57  static std::string_view getDescription(RomType type);
58  static unsigned getBlockSize (RomType type);
59 
60 private:
61  String32 title;
62  String32 year;
63  String32 company;
64  String32 country;
65  String32 origType;
66  String32 remark;
67  RomType romType;
68  int genMSXid;
69  bool original;
70 };
71 
72 } // namespace openmsx
73 
74 #endif
std::string_view getTitle(const char *buf) const
Definition: RomInfo.hh:32
std::string_view getCompany(const char *buf) const
Definition: RomInfo.hh:38
STL namespace.
const char * fromString32(const char *buffer, uint32_t str32)
Definition: String32.hh:35
static unsigned getBlockSize(RomType type)
Definition: RomInfo.cc:226
std::conditional_t<(sizeof(char *) > sizeof(uint32_t)), uint32_t, const char * > String32
Definition: String32.hh:22
std::string_view getOrigType(const char *buf) const
Definition: RomInfo.hh:44
std::string_view getRemark(const char *buf) const
Definition: RomInfo.hh:47
static std::string_view romTypeToName(RomType type)
Definition: RomInfo.cc:195
static RomType nameToRomType(std::string_view name)
Definition: RomInfo.cc:189
RomInfo(String32 title_, String32 year_, String32 company_, String32 country_, bool original_, String32 origType_, String32 remark_, RomType romType_, int genMSXid_)
Definition: RomInfo.hh:15
static std::vector< std::string_view > getAllRomTypes()
Definition: RomInfo.cc:206
RomType getRomType() const
Definition: RomInfo.hh:50
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
std::string_view getCountry(const char *buf) const
Definition: RomInfo.hh:41
bool getOriginal() const
Definition: RomInfo.hh:51
static std::string_view getDescription(RomType type)
Definition: RomInfo.cc:217
int getGenMSXid() const
Definition: RomInfo.hh:52
std::string_view getYear(const char *buf) const
Definition: RomInfo.hh:35