I have recently written a small dialog based MFC app to carry out a few performance calculations for our product. I have managed to get o/p to the printer and that’s OK.
What I want to do now is to enable the saving of the data from the calculation in some mini database to be reviewed at a later stage?either through an interface which I will add to the program or through an existing app (notepad/excel or whatever).
How should I approach this? Do I create a structure of the data I want to save and serialize it onto one long file on disk? Do I create a class that can serialize itself? I’ll try and figure out the details by myself (I hope) but I am just not sure what the general solution should be.
Looks like you need a serializable class object that can serialize its data into a file and retrieve the data later. Although you can use a full-blown database for this purpose, this is overkill because you will have to consider other RDBMS-related issues such as timeouts, locks, transactions, establishing a database connection, authorization and so on, when in reality, you don’t really need all this complication. Since your application is already based on MFC, you can take advantage of MFC’s built-in support for serialization. Declare the class with the appropriate macros to enable MFC to generate the boilerplate code, and overload the class’s << and >> operators for writing and reading the data from an archive.