mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
includes/type: Added magic number assertion type
This commit is contained in:
19
includes/type/magic.pat
Normal file
19
includes/type/magic.pat
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <std/string.pat>
|
||||
#include <std/sys.pat>
|
||||
|
||||
namespace type {
|
||||
|
||||
struct Magic<auto ExpectedValue> {
|
||||
char value[std::string::length(ExpectedValue)];
|
||||
std::assert(value == ExpectedValue, std::format("Invalid magic value! Expected \"{}\", got \"{}\".", ExpectedValue, value));
|
||||
} [[sealed, format("type::impl::format_magic")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_magic(ref auto magic) {
|
||||
return magic.value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user