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