Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Serialization & STL

This topic is 5490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!