Re: Can't read CString after serialization
"Alexh" <alexh1@sbcglobal.net> ha scritto nel messaggio
news:20ca5115-dcf9-4d54-997a-b97f18feb16e@e10g2000prf.googlegroups.com...
//AspectArrayHelioData generated here
AspectArrayHelioData.Serialize(archive1);
I think that the problem is that you should define a custom version of
SerializeElements helper.
If you go into afxtempl.h (at least in VC2008, I'm not sure about VC2005,
but I think it is the same...), you will read that:
void AFXAPI SerializeElements(CArchive& ar, TYPE* pElements, INT_PTR
nCount)
this generic template form of SerializeElements does just a bit-wise
serialization. This is good for "primitive" types like int or doubles, but
it fails for more complex types like CString (which stores *pointers*).
So, I think you should write a customized version (template specialization)
of SerializeElements for your particular class CPlanetAspect, i.e. you
should write the body of this template specialization:
template<> void AFXAPI
SerializeElements<CPlanetAspect> (CArchive& ar, CPlanetAspect * pElements,
INT_PTR nCount);
and take care of proper CString serialization.
Giovanni