|
Boost Users : |
Subject: [Boost-users] [serialization] Serializing array of POD or custom type
From: Kim Gadecki (gadecki_at_[hidden])
Date: 2012-06-26 01:58:33
Hi everyone.
I'm trying to work out how you serialize arrays using the boost
serializer. Here's a simplified example:
struct node_link
{
u32 node_A;
u32 node_B;
};
struct Node {
node_link* m_node_links_array;
int m_node_links_size;
};
// non-intrusive serialization
template<class Archive>
void serialize(Archive & ar, node_link& link, const unsigned
int version)
{
ar & link.node_A;
ar & link.node_B;
}
template<class Archive>
void serialize(Archive & ar, Node& node_data, const unsigned
int version)
{
ar &
boost::serialization::array<node_link>(node_data.m_node_links_array,
node_data.m_node_links_size);
ar & node_data.m_node_links_size;
}
This seems to work for serializing but I get an error on de-serialization.
Can anyone tell me the correct way to do this?
Thanks
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net