openMSX
RomInfo.hh
Go to the documentation of this file.
1#ifndef ROMINFO_HH
2#define ROMINFO_HH
3
4#include "RomTypes.hh"
5
6#include "String32.hh"
7#include "stl.hh"
8#include "view.hh"
9#include "zstring_view.hh"
10
11#include <string_view>
12
13namespace openmsx {
14
16{
17public:
18 // This contains extra information for each RomType. This structure only
19 // contains the primary (non-alias) rom types.
20 struct RomTypeInfo {
21 unsigned blockSize;
23 std::string_view description;
24 };
25
26public:
27 RomInfo(String32 title_, String32 year_,
28 String32 company_, String32 country_,
29 bool original_, String32 origType_,
30 String32 remark_, RomType romType_,
31 unsigned genMSXid_)
32 : title (title_)
33 , year (year_)
34 , company (company_)
35 , country (country_)
36 , origType(origType_)
37 , remark (remark_)
38 , romType (romType_)
39 , genMSXid(genMSXid_)
40 , original(original_)
41 {
42 }
43
44 [[nodiscard]] std::string_view getTitle (const char* buf) const {
45 return fromString32(buf, title);
46 }
47 [[nodiscard]] std::string_view getYear (const char* buf) const {
48 return fromString32(buf, year);
49 }
50 [[nodiscard]] std::string_view getCompany (const char* buf) const {
51 return fromString32(buf, company);
52 }
53 [[nodiscard]] std::string_view getCountry (const char* buf) const {
54 return fromString32(buf, country);
55 }
56 [[nodiscard]] std::string_view getOrigType(const char* buf) const {
57 return fromString32(buf, origType);
58 }
59 [[nodiscard]] std::string_view getRemark (const char* buf) const {
60 return fromString32(buf, remark);
61 }
62 [[nodiscard]] RomType getRomType() const { return romType; }
63 [[nodiscard]] bool getOriginal() const { return original; }
64 [[nodiscard]] unsigned getGenMSXid() const { return genMSXid; }
65
66 [[nodiscard]] static RomType nameToRomType(std::string_view name);
67 [[nodiscard]] static zstring_view romTypeToName (RomType type);
68 [[nodiscard]] static std::string_view getDescription(RomType type);
69 [[nodiscard]] static unsigned getBlockSize (RomType type);
70 [[nodiscard]] static auto getAllRomTypes() {
72 }
74
75private:
76 String32 title;
77 String32 year;
78 String32 company;
79 String32 country;
80 String32 origType;
81 String32 remark;
82 RomType romType;
83 unsigned genMSXid;
84 bool original;
85};
86
87} // namespace openmsx
88
89#endif
constexpr const char * fromString32(const char *buffer, uint32_t str32)
Definition String32.hh:34
std::conditional_t<(sizeof(char *) > sizeof(uint32_t)), uint32_t, const char * > String32
Definition String32.hh:22
static const array_with_enum_index< RomType, RomInfo::RomTypeInfo > & getRomTypeInfo()
Definition RomInfo.cc:114
std::string_view getYear(const char *buf) const
Definition RomInfo.hh:47
bool getOriginal() const
Definition RomInfo.hh:63
static unsigned getBlockSize(RomType type)
Definition RomInfo.cc:202
unsigned getGenMSXid() const
Definition RomInfo.hh:64
std::string_view getTitle(const char *buf) const
Definition RomInfo.hh:44
static std::string_view getDescription(RomType type)
Definition RomInfo.cc:197
static zstring_view romTypeToName(RomType type)
Definition RomInfo.cc:192
std::string_view getCompany(const char *buf) const
Definition RomInfo.hh:50
std::string_view getRemark(const char *buf) const
Definition RomInfo.hh:59
static auto getAllRomTypes()
Definition RomInfo.hh:70
RomInfo(String32 title_, String32 year_, String32 company_, String32 country_, bool original_, String32 origType_, String32 remark_, RomType romType_, unsigned genMSXid_)
Definition RomInfo.hh:27
std::string_view getCountry(const char *buf) const
Definition RomInfo.hh:53
RomType getRomType() const
Definition RomInfo.hh:62
static RomType nameToRomType(std::string_view name)
Definition RomInfo.cc:182
std::string_view getOrigType(const char *buf) const
Definition RomInfo.hh:56
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
Definition Autofire.cc:11
constexpr auto transform(Range &&range, UnaryOp op)
Definition view.hh:520
std::string_view description
Definition RomInfo.hh:23