![Declare Serial Mfc Declare Serial Mfc](https://media.springernature.com/lw685/springer-static/image/art%3A10.1186%2Fs40486-019-0091-8/MediaObjects/40486_2019_91_Fig1_HTML.png)
Then by default doxygen will feed the following to its parser: #define VERSION
#Declare Serial Mfc code#
So if you have the following code fragment #define VERSION 200
![Declare Serial Mfc Declare Serial Mfc](https://www.frontiersin.org/files/Articles/660645/fmicb-12-660645-HTML/image_m/fmicb-12-660645-g001.jpg)
That is, it evaluates conditional compilation statements (like #if) and evaluates macro definitions, but it does not perform macro expansion. Once you have a serializable class, you can serialize objects of the class, as discussed in the article Serialization: Serializing an Object.Source files that are used as input to doxygen can be parsed by doxygen's built-in C-preprocessor.īy default doxygen does only partial preprocessing.
#Declare Serial Mfc how to#
The following example shows how to use IMPLEMENT_SERIAL for a class, CPerson, that is derived from CObject: IMPLEMENT_SERIAL(CPerson, CObject, 1) For usage information and an example, see the GetObjectSchema member function of class CArchive. If you want your Serialize member function to be able to read multiple versions - that is, files written with different versions of the application - you can use the value VERSIONABLE_SCHEMA as an argument to the IMPLEMENT_SERIAL macro. If the schema number of the object on disk does not match the schema number of the class in memory, the library will throw a CArchiveException, preventing your program from reading an incorrect version of the object. The MFC serialization code checks the schema number when reading objects into memory. (Don't confuse this schema number with database terminology.) Use an integer greater than or equal to 0 for the schema number. The schema number is essentially a version number for objects of the class. The third argument to this macro is a schema number. The first two arguments to the macro are the name of the class and the name of its immediate base class. You use this macro in the implementation file (.CPP) for your class. The IMPLEMENT_SERIAL macro is used to define the various functions needed when you derive a serializable class from CObject. Using the IMPLEMENT_SERIAL Macro in the Implementation File If you forget to define a constructor with no arguments in a class that uses the DECLARE_SERIAL and IMPLEMENT_SERIAL macros, you will get a "no default constructor available" compiler warning on the line where the IMPLEMENT_SERIAL macro is used. The constructor must put the object in a state that allows it to be deleted if necessary. If you make it protected or private, you help make sure that it will only be used by the serialization functions. This constructor can be declared public, protected, or private. The deserialization process will fill in all member variables with the values required to re-create the object. MFC requires a default constructor when it re-creates your objects as they are deserialized (loaded from disk). The DECLARE_SERIAL macro is required in the declaration of classes that will support serialization, as shown here: class CPerson : public CObject You can also use the CArchive::Read and CArchive::Write member functions to read and write large amounts of untyped data. now do the stuff for our specific class The following example shows how to implement Serialize for the CPerson class declared above: void CPerson::Serialize(CArchive& archive)
#Declare Serial Mfc archive#
The insertion and extraction operators interact with the archive class to read and write the data. Insert or extract the member variables specific to your class. To override the Serialize member functionĬall your base class version of Serialize to make sure that the inherited portion of the object is serialized. The following class declaration fragment shows the new member variables and the declaration for the overridden Serialize member function: class CPerson : public CObject If you call Serialize directly rather than through the > and >).Ĭonsider a class that is derived from CObject and has two new member variables, of types CString and WORD.
![Declare Serial Mfc Declare Serial Mfc](https://www.tenouk.com/visualcplusmfc/visualcplusmfc12mdi_files/image034.png)
Using the IMPLEMENT_SERIAL macro in the implementation file for your class. Using the DECLARE_SERIAL macro in the class declaration.ĭefining a constructor that takes no arguments. Overriding the Serialize member function. They are listed below and explained in the following sections:ĭeriving your class from CObject (or from some class derived from CObject). Five main steps are required to make a class serializable.