Easiest way to convert CArchive to use SQL database for serialization?

I have an existing application that uses CArchive to serialize an object structure to a file. I am wondering if the use of CArchive could be replaced with some special class to write to the database in the same way as serialized. Before I get down to figuring out how doable this is, I was wondering if other people have done the same - what's the best approach to this problem? I would like to be able to create a replacement for using CArchive so that the existing object structure just reads / writes to / from the database and not to a serialized file. Is it as easy as overwriting the Serialize method for each class?

0


source to share


1 answer


Short answer: forget about it.

Longer answer:

CArchive has no virtual members. Even the destructor is not virtual, which means that you shouldn't leave that class (C # programmers say they are sealed).



There is only one possibility I can think of to customize how CArchive works (and without rewriting all the serialization code in CDocument): Create your CArchive object by passing it a pointer to a derived CFile class that will handle the data connection for you.

From there, how you manage your database by simply overriding CFile Read () and Write () is beyond my imagination: --(

0


source







All Articles