atilaneves / cerealed

Powerful binary serialisation library for D
BSD 3-Clause "New" or "Revised" License
92 stars 3 forks source link

Feature request: support for multidimensional arrays #3

Closed vicencb closed 9 years ago

vicencb commented 9 years ago

Hello Atila, As you suggested I've signed in and posted my feature request here. I would like to use cerealed with a struct like this:

import cerealed;

struct nested_associative_array { nested_associative_array[int] x; }

struct some_struct {
    string[] x;
    int[][] y;
    nested_associative_array[] z;
};

void main() {
    some_struct original, restored;

    auto enc = Cerealiser();
    enc ~= original;
    auto dec = Decerealiser(enc.bytes);
    restored = dec.value!(some_struct);

    assert(original==restored);
}

The serialization process compiles fine, but the restoring part fails to compile. I've tried to figure out how to do it, but I am still a beginner on D. How difficult do you think it is? The alternative, orange, works fine, but the struct I'm trying to export to disk is a few hundreds of MB in size and orange takes hours to complete and may also run out of memory. Your implementation, instead, is really fast and efficient!

atilaneves commented 9 years ago

Done.

The issue was with deserialising string[] but I kept your example as a unit test just in case.

vicencb commented 9 years ago

Thank you very much. I can confirm it works with the empty test case above and also with a structure that once serialised has a size of 1.6MB. Shortly I'll test it with a bigger one. Your help is greatly appreciated.