I think that I'm doing it again - giving away points when I should just RTFM & hack the code. Ah well, that's laziness for you :-)
Basically, I want my users to be able to save/restore the current state of their project. This - obviously - means writing the program's internal data to a file & reading it back at a later time.
My data consists of 3 or 4 different classes, with the data of each class being in an STL <vector> of objects. I'd like to store a few data items as header first (4 bytes to identify my save file, program version of saver, maybe date/time, etc). Then I'll write out the program data.
So, the old Pascal problem - since the file isn't a neat collection of records all of the same type/length ...
Do I have to precede each collection of objects by a few identifying bytes for object type & number of objects so that I will know how many, of what type, to read bacK? I'm thinking that the answer is yes.
Do I have to overload the << operator in each class which I have defined? Again, I am thinking that the answer is yes.
Since I am using <vector> objects I don't have to worry about linkages etc. However, I am using Borland C++ Builder. Who knows about VCL components. If my class has a member which is of type TPanel, can it save & restore itself, or do I have to write the code (maybe some extra points for this part)?
What I think that I am saying here is that I could probably have coded this in straight C in the time that I have taken to write this post. However, I would like to do things 'properly' in C++ ... what's the generic/preferred/not too clever way of saving restoring program data of mixed types?