Skip to content

Custom struct parsing depending on previously read value #2154

Answered by paxcut
MathiasLui asked this question in Get Help

You must be logged in to vote

you can write the example you wrote as the following pattern:

struct File {
    MyStruct data;
    if (data.Offset > sizeof(data)) {
    // We have additional data before the actual payload
        s32 extraDataSize = data.Offset - sizeof(data);
        if (extraDataSize < 4) {
            sDataValid = false; // This is an out-variable
           // return; //you may not want to use return because that stops the evaluation. use break to simply exit out of the struct.
        } else
            MyOtherStruct<extraDataSize> mySecondStruct;
    }
};
File file@0;
isDataValid = true;

When File is placed it will first read data struct then check its size and compare it to the offset, If the off…

Replies: 1 comment 13 replies

You must be logged in to vote
13 replies
@paxcut

@MathiasLui

@paxcut

@paxcut

Answer selected by MathiasLui
@MathiasLui

@MathiasLui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants