1
0
mirror of synced 2025-01-08 12:41:38 +01:00
ImHex/tests/include/test_patterns/test_pattern_structs.hpp
2021-09-11 23:13:49 +02:00

36 lines
1.1 KiB
C++

#pragma once
#include "test_pattern.hpp"
namespace hex::test {
class TestPatternStructs : public TestPattern {
public:
TestPatternStructs() : TestPattern("Structs") {
auto testStruct = create<PatternDataStruct>(0x100, sizeof(s32) + sizeof(u8[0x10]), "TestStruct", "testStruct");
auto variable = create<PatternDataSigned>(0x100, sizeof(s32), "s32", "variable");
auto array = create<PatternDataStaticArray>(0x100 + sizeof(s32), sizeof(u8[0x10]), "u8", "array");
array->setEntries(create<PatternDataUnsigned>(0x100 + sizeof(s32), sizeof(u8), "u8", ""), 0x10);
testStruct->setMembers({ variable, array });
addPattern(testStruct);
}
~TestPatternStructs() override = default;
[[nodiscard]]
std::string getSourceCode() const override {
return R"(
struct TestStruct {
s32 variable;
u8 array[0x10];
};
TestStruct testStruct @ 0x100;
)";
}
};
}