Original Post
Lately I've been working on using Python's pickling system with my game. I plan on using it to make save files of my game. I'm wrapping C++ classes into Python via Boost::Python. The problem comes when I write the pickle suite class which forms the tuples of information that need to be saved and then translates that information back into the class. This pickler class requires that I know about some of the internals of the class. Usually it's nothing vital - much of it was already part of the public interface. But sometimes it starts to get nastier and nastier exposing things that I had no previous need to expose, even if it doesn't hurt to do so. It feels messy, like a hack. I don't like it. Since boost::python (which I use) basically mandates that you have a separate class so that it can inherit from pickle_suite, I find it forces me to expose this stuff to the whole program. Ick. The obvious solution to me is friend classes, but I'm not so sure that they're a good solution. What is a good solution? On a side note, there are some things that I'm pickling which are part of another library. Some of these things do not give you all the information that you need to completely reconstruct the class nicely. For example, my physics engine's solid class takes in some shapes when you construct it, but there's no way to get those shapes back after it's constructed. It has redundant information and is a little annoying to write, but it works. I've gotten around this by writing a wrapper class which stores the shapes as they are passed in. Again, what is a good solution for this?