Virtual CRuntimeClass* GetRuntimeClass() const ĪFX_API friend CArchive& AFXAPI operator > (CArchive& ar, CRoot* &pOb)
Declare Serial Mfc code#
To make a CObject class serializable all you need is to add a macro:Ĭopy Code // // DECLARE_SERIAL(CRoot) expands to // public:
Declare Serial Mfc windows#
Declare Serial Mfc how to#
Also I will demonstrate how to use MFC Serialization with or without Document/View architecture such as inside the console applications and TCP/IP servers. I will cover in this article plain old MFC serialization with MFC provided classes, how to serialize STL collections, how to serialize plain Windows SDK data structures, how to serialize C style arrays, how to serialize to process and shared memory and how to serialize to and from sockets. Writing to the memory is very useful for inter process communications such as clipboard cut/copy/paste operations and writing to sockets is useful when networking with remote machines. MFC Serialization supports read write to the disk, memory, and sockets. It is undoubtedly is the most powerful, efficient, and blazingly fast way to store and retrieve hierarchical data to and from the disk, memory, or sockets. However with the right extensions we can serialize any data structure in existence, STL collections, user defined collections, any collections (including flat C style arrays). SDK samples that demonstrated the serialization were very limited and covered serialization of the plain old data and CObject derived classes and collections.
Serialization was part of the MFC (Microsoft Foundation Classes) library since its very first introduction, but I felt it has never received its proper dues because it was largely undocumented. And when we need to write and read those enormous blobs of data to or from the disk, memory, or sockets, MFC serialization is a powerful tool in every programmer’s tool box. The world of data structures is a vast one.