Archive 17/01/2023.

[SOLVED] Serialize/Deserialize a VectorBuffer [AS]

Mike

Are the AngelScript bindings for writing/reading a VectorBuffer in Serializer and Deserializer classes missing? (or is it performed otherwise?)

cadaver

You can write and read an array of uint8’s, but it’s not quite the same thing. Should be easy to add.

cadaver

Has been added to master. It’s the user’s responsibility to know the size of the data, for example:

    VectorBuffer test;
    for (int i = 0; i < 10; ++i)
        test.WriteString("Test" + String(i));

    File outFile("Test.bin", FILE_WRITE);
    outFile.WriteUInt(test.size);
    outFile.WriteVectorBuffer(test);
    outFile.Close();

    File inFile("Test.bin");
    uint size = inFile.ReadUInt();
    VectorBuffer test2 = inFile.ReadVectorBuffer(size);
    inFile.Close();
    
    while(!test2.eof)
      Print(test2.ReadString());
Mike

Awesome! Works great, many thanks Cadaver :stuck_out_tongue: