I have a large, complex struct that is made up of many levels of structs, getting eventually to int, char*, enum, etc. There are also pointers to structs and arrays of pointers. There are no STL types within these structures. I am trying to wrap my head around how I can use boost.serialization for this, without modifying the structures themselves (I can't make changes to the definitions). Does anyone know the best way to do this? I saw several mentions of wrapper classes for serializing a float and figure I could use that approach, but I think I would have to make a mirror structure that's made up of my struct wrappers and copy the data over from the real struct into these classes. Or I guess I could use pointers, but I would still have to create this second monster. Is that really the best possibility? Any help is appreciated! Thanks, Diane
On 26 Aug 2008, at 13:44, Diane wrote:
I have a large, complex struct that is made up of many levels of structs, getting eventually to int, char*, enum, etc. There are also pointers to structs and arrays of pointers. There are no STL types within these structures.
I am trying to wrap my head around how I can use boost.serialization for this, without modifying the structures themselves (I can't make changes to the definitions).
Does anyone know the best way to do this? I saw several mentions of wrapper classes for serializing a float and figure I could use that approach, but I think I would have to make a mirror structure that's made up of my struct wrappers and copy the data over from the real struct into these classes. Or I guess I could use pointers, but I would still have to create this second monster. Is that really the best possibility?
Can't you just write a serialize() function for each of your structs? As you say they are structs I assume that all members are public and a free serialize function should be able to access all members? Matthias
Matthias Troyer
Can't you just write a serialize() function for each of your structs? As you say they are structs I assume that all members are public and a free serialize function should be able to access all members?
Thanks, that seems much easier! I had been analyzing the bus schedule example, but I missed that there was a non-intrusive method. I just need to know how to serialize a char now, without modifying any structures that contain chars. The wrapper class method seems to require that my structures be changed to contain tracked_char instead of char. Is there an alternate way to deal with chars? While we're thinking about chars, how do I serialize a char*? Does Boost treat this as an array? Thanks, Diane
I could answer these questions. But if you get started as I suggested, study the documentation and examples and tests as needed, almost all of these questions - as well as others which will arise, will be answered as you progress. Robert Ramey Diane wrote:
Matthias Troyer
writes: Can't you just write a serialize() function for each of your structs? As you say they are structs I assume that all members are public and a free serialize function should be able to access all members?
Thanks, that seems much easier! I had been analyzing the bus schedule example, but I missed that there was a non-intrusive method.
I just need to know how to serialize a char now, without modifying any structures that contain chars. The wrapper class method seems to require that my structures be changed to contain tracked_char instead of char. Is there an alternate way to deal with chars?
While we're thinking about chars, how do I serialize a char*? Does Boost treat this as an array?
Thanks, Diane
look at the tutorial demo. Make a test program with nothing in it. add serialization for just one class - that doesn't depend on any other classes. when you've got that, add the classes for the next layer up. and so on until you have a test program which tests/demos serializaton of your complex class. Robert Ramey Diane wrote:
I have a large, complex struct that is made up of many levels of structs, getting eventually to int, char*, enum, etc. There are also pointers to structs and arrays of pointers. There are no STL types within these structures.
I am trying to wrap my head around how I can use boost.serialization for this, without modifying the structures themselves (I can't make changes to the definitions).
Does anyone know the best way to do this? I saw several mentions of wrapper classes for serializing a float and figure I could use that approach, but I think I would have to make a mirror structure that's made up of my struct wrappers and copy the data over from the real struct into these classes. Or I guess I could use pointers, but I would still have to create this second monster. Is that really the best possibility?
Any help is appreciated!
Thanks, Diane
participants (3)
-
Diane
-
Matthias Troyer
-
Robert Ramey