Skip to content

Cycle over array of different types and sizes #154

Answered by k0tran
k0tran asked this question in Q&A
Discussion options

You must be logged in to vote

All store is data contiguous and in this example it is in order, but it can also be unordered. For example

#pragma example 04 05 02 01 01 00 02 06 0B 01 07 0A 01 61 61 00 00 00 00 00 00 00 00 00 73 74 72 00 00 00 00 00

But I was able to achieve that introducing parent.offset into your solution, big thanks!

Only updated parts:

struct StoreEntry {
    auto i = std::core::array_index();
    auto c = parent.index[i].count;
    auto p = parent.offset + parent.index[i].offset;
    match (parent.index[i].type) {
        (IndexType::_char): char data[c] @ p;
        (IndexType::_int8): s8 data[c] @ p;
        (IndexType::_int16): s16 data[c] @ p;
        (IndexType::_int32): s32 data[c] @ p;
   …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@k0tran
Comment options

Answer selected by k0tran
@paxcut
Comment options

@k0tran
Comment options

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