mirror of https://github.com/AxioDL/kabufuda.git
Merge pull request #11 from lioncash/array
General: Use std::array for constructors where applicable
This commit is contained in:
commit
f74f1a3a6c
|
@ -15,9 +15,12 @@ class Directory {
|
||||||
uint16_t m_checksum;
|
uint16_t m_checksum;
|
||||||
uint16_t m_checksumInv;
|
uint16_t m_checksumInv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using RawData = std::array<uint8_t, BlockSize>;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
Data data;
|
Data data;
|
||||||
std::array<uint8_t, BlockSize> raw;
|
RawData raw;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
@ -27,7 +30,7 @@ class Directory {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Directory();
|
Directory();
|
||||||
Directory(uint8_t data[BlockSize]);
|
explicit Directory(const RawData& rawData);
|
||||||
~Directory() = default;
|
~Directory() = default;
|
||||||
|
|
||||||
bool hasFreeFile() const;
|
bool hasFreeFile() const;
|
||||||
|
|
|
@ -10,6 +10,8 @@ class File {
|
||||||
friend class Directory;
|
friend class Directory;
|
||||||
friend class Card;
|
friend class Card;
|
||||||
#pragma pack(push, 4)
|
#pragma pack(push, 4)
|
||||||
|
using RawData = std::array<uint8_t, 0x40>;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
std::array<uint8_t, 4> m_game;
|
std::array<uint8_t, 4> m_game;
|
||||||
|
@ -28,7 +30,7 @@ class File {
|
||||||
uint16_t m_reserved2;
|
uint16_t m_reserved2;
|
||||||
uint32_t m_commentAddr;
|
uint32_t m_commentAddr;
|
||||||
};
|
};
|
||||||
std::array<uint8_t, 0x40> raw;
|
RawData raw;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
@ -36,8 +38,8 @@ class File {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
File();
|
File();
|
||||||
File(char data[0x40]);
|
explicit File(const RawData& rawData);
|
||||||
File(const char* filename);
|
explicit File(const char* filename);
|
||||||
~File() = default;
|
~File() = default;
|
||||||
};
|
};
|
||||||
} // namespace kabufuda
|
} // namespace kabufuda
|
||||||
|
|
|
@ -35,7 +35,7 @@ Directory::Directory() {
|
||||||
updateChecksum();
|
updateChecksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory::Directory(uint8_t data[]) { std::memcpy(raw.data(), data, BlockSize); }
|
Directory::Directory(const RawData& rawData) : raw{rawData} {}
|
||||||
|
|
||||||
bool Directory::hasFreeFile() const {
|
bool Directory::hasFreeFile() const {
|
||||||
return std::any_of(data.m_files.cbegin(), data.m_files.cend(),
|
return std::any_of(data.m_files.cbegin(), data.m_files.cend(),
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
namespace kabufuda {
|
namespace kabufuda {
|
||||||
File::File() { raw.fill(0xFF); }
|
File::File() { raw.fill(0xFF); }
|
||||||
|
|
||||||
File::File(char data[]) { std::memcpy(raw.data(), data, raw.size()); }
|
File::File(const RawData& rawData) : raw{rawData} {}
|
||||||
|
|
||||||
File::File(const char* filename) {
|
File::File(const char* filename) {
|
||||||
raw.fill(0);
|
raw.fill(0);
|
||||||
|
|
Loading…
Reference in New Issue