1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Avoids storing or printing a CRC if none is known.

This commit is contained in:
Thomas Harte 2021-06-04 22:03:08 -04:00
parent ccd82591aa
commit fbee74e1fe
3 changed files with 26 additions and 14 deletions

View File

@ -9,6 +9,7 @@
#ifndef ROMCatalogue_hpp
#define ROMCatalogue_hpp
#include <functional>
#include <map>
#include <optional>
#include <string>
@ -144,8 +145,12 @@ struct Description {
private:
template <typename FileNameT, typename CRC32T> Description(
Name name, std::string machine_name, std::string descriptive_name, FileNameT file_names, size_t size, CRC32T crc32s
) : name{name}, machine_name{machine_name}, descriptive_name{descriptive_name}, file_names{file_names}, size{size}, crc32s{crc32s} {}
Name name, std::string machine_name, std::string descriptive_name, FileNameT file_names, size_t size, CRC32T crc32s = CRC32T(0)
) : name{name}, machine_name{machine_name}, descriptive_name{descriptive_name}, file_names{file_names}, size{size}, crc32s{crc32s} {
if(this->crc32s.size() == 1 && !this->crc32s[0]) {
this->crc32s.clear();
}
}
};
struct Request {

View File

@ -58,7 +58,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "--rompath=~/ROMs"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--has-disk-drive"

View File

@ -799,10 +799,15 @@ int main(int argc, char *argv[]) {
}, [&indentation_level, indent] (ROM::Request::ListType type, const ROM::Description &rom, bool is_optional, size_t remaining) {
indent();
if(is_optional) std::cerr << "optionally, ";
std::cerr << rom.machine_name << '/' << rom.file_names[0] << " (";
std::cerr << rom.machine_name << '/' << rom.file_names[0];
if(!rom.descriptive_name.empty() || !rom.crc32s.empty()) {
std::cerr << " (";
if(!rom.descriptive_name.empty()) {
std::cerr << rom.descriptive_name << "; ";
std::cerr << rom.descriptive_name;
if(!rom.crc32s.empty()) std::cerr << "; ";
}
if(!rom.crc32s.empty()) {
std::cerr << ((rom.crc32s.size() > 1) ? "usual crc32s: " : "usual crc32: ");
bool is_first = true;
for(const auto crc32: rom.crc32s) {
@ -810,7 +815,9 @@ int main(int argc, char *argv[]) {
is_first = false;
std::cerr << std::hex << std::setfill('0') << std::setw(8) << crc32;
}
}
std::cerr << ")";
}
if(remaining) {
std::cerr << ";";