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 "view.hh"
7#include <array>
8#include <string_view>
9#include <utility>
10#include <vector>
11
12namespace openmsx {
13
15{
16public:
17 // This contains extra information for each RomType. This structure only
18 // contains the primary (non-alias) rom types.
19 struct RomTypeInfo {
20 unsigned blockSize;
21 std::string_view name;
22 std::string_view description;
23 };
24
25public:
26 RomInfo(String32 title_, String32 year_,
27 String32 company_, String32 country_,
28 bool original_, String32 origType_,
29 String32 remark_, RomType romType_,
30 unsigned genMSXid_)
31 : title (title_)
32 , year (year_)
33 , company (company_)
34 , country (country_)
35 , origType(origType_)
36 , remark (std::move(remark_))
37 , romType(romType_)
38 , genMSXid(genMSXid_)
39 , original(original_)
40 {
41 }
42
43 [[nodiscard]] std::string_view getTitle (const char* buf) const {
44 return fromString32(buf, title);
45 }
46 [[nodiscard]] std::string_view getYear (const char* buf) const {
47 return fromString32(buf, year);
48 }
49 [[nodiscard]] std::string_view getCompany (const char* buf) const {
50 return fromString32(buf, company);
51 }
52 [[nodiscard]] std::string_view getCountry (const char* buf) const {
53 return fromString32(buf, country);
54 }
55 [[nodiscard]] std::string_view getOrigType(const char* buf) const {
56 return fromString32(buf, origType);
57 }
58 [[nodiscard]] std::string_view getRemark (const char* buf) const {
59 return fromString32(buf, remark);
60 }
61 [[nodiscard]] RomType getRomType() const { return romType; }
62 [[nodiscard]] bool getOriginal() const { return original; }
63 [[nodiscard]] unsigned getGenMSXid() const { return genMSXid; }
64
65 [[nodiscard]] static RomType nameToRomType(std::string_view name);
66 [[nodiscard]] static std::string_view romTypeToName (RomType type);
67 [[nodiscard]] static std::string_view getDescription(RomType type);
68 [[nodiscard]] static unsigned getBlockSize (RomType type);
69 [[nodiscard]] static auto getAllRomTypes() {
71 }
72 [[nodiscard]] static const std::array<RomInfo::RomTypeInfo, RomType::ROM_LAST>& getRomTypeInfo();
73
74private:
75 String32 title;
76 String32 year;
77 String32 company;
78 String32 country;
79 String32 origType;
80 String32 remark;
81 RomType romType;
82 unsigned genMSXid;
83 bool original;
84};
85
86} // namespace openmsx
87
88#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
std::string_view getYear(const char *buf) const
Definition RomInfo.hh:46
bool getOriginal() const
Definition RomInfo.hh:62
static unsigned getBlockSize(RomType type)
Definition RomInfo.cc:199
static const std::array< RomInfo::RomTypeInfo, RomType::ROM_LAST > & getRomTypeInfo()
Definition RomInfo.cc:110
unsigned getGenMSXid() const
Definition RomInfo.hh:63
std::string_view getTitle(const char *buf) const
Definition RomInfo.hh:43
static std::string_view getDescription(RomType type)
Definition RomInfo.cc:194
std::string_view getCompany(const char *buf) const
Definition RomInfo.hh:49
std::string_view getRemark(const char *buf) const
Definition RomInfo.hh:58
static auto getAllRomTypes()
Definition RomInfo.hh:69
RomInfo(String32 title_, String32 year_, String32 company_, String32 country_, bool original_, String32 origType_, String32 remark_, RomType romType_, unsigned genMSXid_)
Definition RomInfo.hh:26
static std::string_view romTypeToName(RomType type)
Definition RomInfo.cc:189
std::string_view getCountry(const char *buf) const
Definition RomInfo.hh:52
RomType getRomType() const
Definition RomInfo.hh:61
static RomType nameToRomType(std::string_view name)
Definition RomInfo.cc:178
std::string_view getOrigType(const char *buf) const
Definition RomInfo.hh:55
This file implemented 3 utility functions:
Definition Autofire.cc:9
STL namespace.
constexpr auto transform(Range &&range, UnaryOp op)
Definition view.hh:520
std::string_view description
Definition RomInfo.hh:22
std::string_view name
Definition RomInfo.hh:21