Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Oct 30, 2000

Mini Database Strategy

Question:
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.

Answer:
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.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap