Page 1 of 1
[SF] How serialize C-array of fundamental type ?
Posted: Wed Oct 09, 2013 7:16 pm
by acDev
Code: Select all
class MyClass
{
public:
int size;
char buffer[64]; // StaticArray
void serialize(SF::Archive &ar)
{
ar & size & ??????;
}
}
Documentation on this subject is empty.
PS. preserialize -> SerializeStaticArray ?
Re: [SF] How serialize C-array of fundamental type ?
Posted: Thu Oct 10, 2013 4:08 am
by jarl
You can include this file:
Code: Select all
#include <SF/SerializeStaticArray.hpp>
, and your serialization function will then work as expected:
Code: Select all
void serialize(SF::Archive & ar)
{
ar & size & buffer;
}
The entire 64 bytes of "buffer" will be serialized.
C-style arrays are somewhat error-prone, so we generally try to point our users at other data structures, such as std::array<> or std::vector<>.