diff options
author | 2022-04-12 08:52:44 -0400 | |
---|---|---|
committer | 2022-04-12 14:52:44 +0200 | |
commit | 97dcbb964ef62ba4b6f86dc162b1c34cbbfbbbd6 (patch) | |
tree | dae64fed1cc4a92ecb9b00282580bf4082f584e4 /src/lib/formats/fs_vtech.cpp | |
parent | ce68a1d711a952a815833856b00bd7a00e28bb1f (diff) |
Fixed some issues involving fs::meta_description construction (#9546)
* Fixed some issues involving fs::meta_description constructing
With the recent change to use std::variant more closely, I noticed a problem where meta_descriptions of type meta_type::String got defaults of type 't'. This was because the templated ctor for meta_description would convert 'const char *' to 'bool'. This change adds another overload to catch 'const char *', along with asserts to catch problems.
In the process I corrected a few meta_description ctors
It is possible that this change does not go far enough. Perhaps the meta_type argument should be removed, and we should instead create distinct ctor types (rather than relying on templates) and specify the precise meta_type in the overload. Or even go further and remove m_type from meta_description, and instead create an overload that calculates meta_type based on calling std::visit on the variant
* Taking this change a bit further, and removing m_type from fs::meta_description; it was superfluous. Also doing some minor C++-ifications
Diffstat (limited to 'src/lib/formats/fs_vtech.cpp')
-rw-r--r-- | src/lib/formats/fs_vtech.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/formats/fs_vtech.cpp b/src/lib/formats/fs_vtech.cpp index 8c6a4e94f82..e294e657801 100644 --- a/src/lib/formats/fs_vtech.cpp +++ b/src/lib/formats/fs_vtech.cpp @@ -83,10 +83,10 @@ meta_data vtech_image::impl::metadata() std::vector<meta_description> vtech_image::file_meta_description() const { std::vector<meta_description> res; - res.emplace_back(meta_description(meta_name::name, meta_type::string, "", false, [](const meta_value &m) { return m.as_string().size() <= 8; }, "File name, 8 chars")); - res.emplace_back(meta_description(meta_name::loading_address, meta_type::number, 0x7ae9, false, [](const meta_value &m) { return m.as_number() < 0x10000; }, "Loading address of the file")); - res.emplace_back(meta_description(meta_name::length, meta_type::number, 0, true, nullptr, "Size of the file in bytes")); - res.emplace_back(meta_description(meta_name::basic, meta_type::flag, true, true, nullptr, "Basic file")); + res.emplace_back(meta_description(meta_name::name, "", false, [](const meta_value &m) { return m.as_string().size() <= 8; }, "File name, 8 chars")); + res.emplace_back(meta_description(meta_name::loading_address, 0x7ae9, false, [](const meta_value &m) { return m.as_number() < 0x10000; }, "Loading address of the file")); + res.emplace_back(meta_description(meta_name::length, 0, true, nullptr, "Size of the file in bytes")); + res.emplace_back(meta_description(meta_name::basic, true, true, nullptr, "Basic file")); return res; } |