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  [[nodiscard]] std::string_view getTitle (const char* buf) const {
33  return fromString32(buf, title);
34  }
35  [[nodiscard]] std::string_view getYear (const char* buf) const {
36  return fromString32(buf, year);
37  }
38  [[nodiscard]] std::string_view getCompany (const char* buf) const {
39  return fromString32(buf, company);
40  }
41  [[nodiscard]] std::string_view getCountry (const char* buf) const {
42  return fromString32(buf, country);
43  }
44  [[nodiscard]] std::string_view getOrigType(const char* buf) const {
45  return fromString32(buf, origType);
46  }
47  [[nodiscard]] std::string_view getRemark (const char* buf) const {
48  return fromString32(buf, remark);
49  }
50  [[nodiscard]] RomType getRomType() const { return romType; }
51  [[nodiscard]] bool getOriginal() const { return original; }
52  [[nodiscard]] int getGenMSXid() const { return genMSXid; }
53 
54  [[nodiscard]] static RomType nameToRomType(std::string_view name);
55  [[nodiscard]] static std::vector<std::string_view> getAllRomTypes();
56  [[nodiscard]] static std::string_view romTypeToName (RomType type);
57  [[nodiscard]] static std::string_view getDescription(RomType type);
58  [[nodiscard]] 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::conditional_t<(sizeof(char *) > sizeof(uint32_t)), uint32_t, const char * > String32
Definition: String32.hh:22
constexpr const char * fromString32(const char *buffer, uint32_t str32)
Definition: String32.hh:35
std::string_view getYear(const char *buf) const
Definition: RomInfo.hh:35
bool getOriginal() const
Definition: RomInfo.hh:51
static unsigned getBlockSize(RomType type)
Definition: RomInfo.cc:205
int getGenMSXid() const
Definition: RomInfo.hh:52
static std::string_view getDescription(RomType type)
Definition: RomInfo.cc:200
std::string_view getTitle(const char *buf) const
Definition: RomInfo.hh:32
std::string_view getCompany(const char *buf) const
Definition: RomInfo.hh:38
RomInfo(String32 title_, String32 year_, String32 company_, String32 country_, bool original_, String32 origType_, String32 remark_, RomType romType_, int genMSXid_)
Definition: RomInfo.hh:15
std::string_view getRemark(const char *buf) const
Definition: RomInfo.hh:47
std::string_view getCountry(const char *buf) const
Definition: RomInfo.hh:41
RomType getRomType() const
Definition: RomInfo.hh:50
static std::vector< std::string_view > getAllRomTypes()
Definition: RomInfo.cc:190
static RomType nameToRomType(std::string_view name)
Definition: RomInfo.cc:179
static std::string_view romTypeToName(RomType type)
Definition: RomInfo.cc:195
std::string_view getOrigType(const char *buf) const
Definition: RomInfo.hh:44
This file implemented 3 utility functions:
Definition: Autofire.cc:9