| e8555c89 Andy McCall |
1 |
#ifndef ROMINFO_HH |
| 2 |
#define ROMINFO_HH |
| 3 |
|
| 4 |
#include "RomTypes.hh" |
| 5 |
|
| 6 |
#include "String32.hh" |
| 7 |
#include "stl.hh" |
| 8 |
#include "zstring_view.hh" |
| 9 |
|
| 10 |
#include <ranges> |
| 11 |
#include <string_view> |
| 12 |
|
| 13 |
namespace openmsx { |
| 14 |
|
| 15 |
class RomInfo |
| 16 |
{ |
| 17 |
public: |
| 18 |
|
| 19 |
|
| 20 |
struct RomTypeInfo { |
| 21 |
unsigned blockSize; |
| 22 |
zstring_view name; |
| 23 |
std::string_view description; |
| 24 |
}; |
| 25 |
|
| 26 |
public: |
| 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() { |
| 71 |
return std::views::transform(getRomTypeInfo(), &RomTypeInfo::name); |
| 72 |
} |
| 73 |
[[nodiscard]] static const array_with_enum_index<RomType, RomInfo::RomTypeInfo>& getRomTypeInfo(); |
| 74 |
[[nodiscard]] static const std::array<RomType, size_t(RomType::NUM)>& getSortedRomTypes(); |
| 75 |
|
| 76 |
private: |
| 77 |
String32 title; |
| 78 |
String32 year; |
| 79 |
String32 company; |
| 80 |
String32 country; |
| 81 |
String32 origType; |
| 82 |
String32 remark; |
| 83 |
RomType romType; |
| 84 |
unsigned genMSXid; |
| 85 |
bool original; |
| 86 |
}; |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
#endif |