Click here to Skip to main content
15,891,136 members
Articles / Desktop Programming / MFC

C++ Class Mapping - An XML Parser example

Rate me:
Please Sign up or sign in to vote.
3.71/5 (8 votes)
21 Nov 20045 min read 82.6K   985   36  
How to use C++ macros to map class members for serialization or other purposes.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CMGServer Message Objects and XML Mapping
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "afxcmn.h"
#include "XMLMessage.h"

class CMsgDestinationInfo : public CXMLMessage
{
	public:

	// Default constructor is required
	CMsgDestinationInfo(){}
	~CMsgDestinationInfo();

	CString m_destination;
	CString m_filePathRoot;

	DECLARE_XML_MAP(CMsgDestinationInfo);
};

class CMsgMediaCopy : public CXMLMessage
{
	public:

	// Default constructor is required
	CMsgMediaCopy();
	~CMsgMediaCopy();

	CString m_mediaName;
	CString m_mediaType;

	CArray<CMsgDestinationInfo*,CMsgDestinationInfo*> m_destinations;

	int     m_securityLevel;
	int     m_priorityLevel;
	CString m_copyOptions;
	int     m_requestNumber;

	// So we can test all combinations...
	CArray<int,int>           m_intArray;
	int*							  m_intPtr;
	CArray<int*,int*>         m_intPtrArray;
	CArray<CString,CString>   m_stringArray;
	CString*                  m_stringPtr;
	CArray<CString*,CString*> m_stringPtrArray;
	CMsgDestinationInfo       m_class;
	CMsgDestinationInfo*      m_classPtr;

	DECLARE_XML_MAP(CMsgMediaCopy);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions