Serialization & STL

Started by
2 comments, last by jonboym 20 years, 9 months ago
Hi, Right I''m getting a little confused with saving my data objects to file. I''m new to STL and basically trying to replicate MFC style (or better!) serialization. Firstly I have a class which contains all the main actors for my game in STL vectors (actually the vectors contain pointers to the actors as they are created on the heap). I want to know how to serialize them using C++ streams & STL. BUT some of the classes contained in the vectors need pointers to other objects of different class in different vector containers and some have static data members (so only need serializing once). Advice? Jon
Advertisement
Anyone ???
IIRC, Boost has some libraries related to serialization.

How appropriate. You fight like a cow.
I don''t see anything in Boost, but maybe I missed it.

There''s no simple solution - you have to explicitly write input and output functionality for each class, writing each separate data member out to the file. Writing out the classname or a magic number first helps catch loading errors, but you don''t get around needing to do it all by hand really. The key is to write generic functions that read and write as many different types as possible or at least share code, and make good use of your object hierarchy so that you don''t have to implement much more when you derive a new class.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

This topic is closed to new replies.

Advertisement