[SF] How serialize C-array of fundamental type ?

RCF support and general discussion.
Post Reply
acDev
Posts: 27
Joined: Tue Oct 08, 2013 3:08 pm
Location: Moscow
Contact:

[SF] How serialize C-array of fundamental type ?

Post 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 ?

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: [SF] How serialize C-array of fundamental type ?

Post 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<>.
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

Post Reply