-
June 9th, 2009, 04:00 AM
#1
Serialization of GUID variable in MFC
I'm trying to serialize a GUID object in MFC. When I try to archive, I get the following error
binary '<<' : no operator defined which takes a right-hand operand of type 'struct _GUID' (or there is no acceptable conversion)
My code snippet is this
Code:
void MyClass :: Serialize(CArchive &ar)
{
CObject::Serialize( ar );
if( ar.IsStoring())
{
ar << m_GUIDVariable;
}
else
{
ar >> m_GUIDVariable;
}
}
How shall I proceed?
Rate the posts which you find useful
-
June 9th, 2009, 04:09 AM
#2
Re: Serialization of GUID variable in MFC
struct _GUID is a structure. 'ar <<' doesn't know what to do with structures. So you will have to do member by member.
Code:
ar << m_GUIDVariable.Data1;
ar << m_GUIDVariable.Data2;
... etc
-
June 9th, 2009, 04:12 AM
#3
Re: Serialization of GUID variable in MFC
Originally Posted by Skizmo
struct _GUID is a structure. 'ar <<' doesn't know what to do with structures. So you will have to do member by member.
Code:
ar << m_GUIDVariable.Data1;
ar << m_GUIDVariable.Data2;
... etc
OK. Thanks.
Rate the posts which you find useful
-
June 9th, 2009, 07:45 AM
#4
Re: Serialization of GUID variable in MFC
GUID is a structure of PODS so you should be able to serialize with CArchive::Write() and Read():
Code:
void MyClass :: Serialize(CArchive &ar)
{
CObject::Serialize( ar );
if( ar.IsStoring())
{
ar.Write(&m_GUIDVariable,sizeof(GUID));
}
else
{
ar.Read(&m_GUIDVariable,sizeof(GUID));
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|