Link to home
Start Free TrialLog in
Avatar of st2599
st2599

asked on

Serialization

How can I serialize the mixed implementation data structure of Graph? Thanks!
ASKER CERTIFIED SOLUTION
Avatar of RONSLOW
RONSLOW

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Additional info: If you have e.g. a nonfixed number of "objects", you can do the following:
CMyDoc::Serialize(CArchive& ar)
{
 CGraph::Serialize(ar)
 // ... continue with normal serialize-stuff
}

CGraph::Serialize(CArchive& ar)
{
 if (ar.IsStoring())
 {
  ar << m_amountOfObjects;
  for( int i=0 ; i< m_amountOfObjects ; i++ )
  {
    CMyObject *pObject = GetMyObject(i);
    pObject->Serialize(ar);
  }
 }
 else
 {
  ar >> m_amountOfObjects;
  for( int i=0 ; i< m_amountOfObjects ; i++ )
  {
    CMyObject *pObject = new CMyObject();
    pObject->Serialize(ar);
    AddMyObject(pObject);
   }
 }
}

CMyObject::Serialize() ...
Avatar of RONSLOW
RONSLOW

I suggest you post further info about your particular case if the more general answer/comments are not detailed enough.
I suggest you post further info about your particular case if the more general answer/comments are not detailed enough.