Serializing CMAPSTRINGTOOBJECT TYPE Object Pointer

How Can I serialize the CMapStringtoOb Type Pointer Object Using Carchieve Type Object.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

inprasConnect With a Mentor Commented:
Hi kakamna
check this
before doing this U should put in UR class

and in implementation U should do
to hook the Serialize
                  CObject      ::      Serialize(ar);
                  CUserMain::      Serialize(ar);

in Serialize function implementation

            if (ar.IsStoring())
                  nSize = m_strArrUcsScript.GetCount() ;
                  ar            <<            nSize ;
                  for (nIndex = m_strArrUcsScript.GetStartPosition(); nIndex != NULL;)
                        m_strArrUcsScript.GetNextAssoc(nIndex, strCommand, (CObject*&)myClass) ;
                        ar            <<            strCommand ;
                        ar            <<            myClass ;
                  ar            >>            nSize ;
                  for (int nIndex = 0; nIndex < nSize ; nIndex++)
                        ar            >>            strCommand ;
                        ar            >>            myClass ;
                        m_strArrUcsScript.SetAt(strCommand, new CMyClass(myClass)) ;

Hope this helps
kakamnaAuthor Commented:
Hi Inpras
Thank You For U  R reply
can u Please explain why all this is necessary. Because I have red that all the classes drived from cobject support Seialization but when I use the statement
ar << mp;
where mp is Pointer Object of CMaptoStringtoOb class. The result is in the form of an exception. But when I try to use
ar << rc;
where rc is the Object of CRect class It works fine.
Waiting for U r reply
Thanx Again
Hi kakamna
True all object derived from CObject can
be serialized

"CMapStringToOb incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. Each element is serialized in turn if a map is stored to an archive, either with the overloaded insertion (<<) operator or with the Serialize member function."

But CArchive class doesnot support Collection classes properly though every help says U can serialize collection classes having micro IMPLEMENT_SERIAL but U need to do it on UR own take the example of CStringArray one more in the path of UR example.

kakamnaAuthor Commented:
Thank U Inparse
I was able to serialize the objects one by one can you send me
your ifo thrigh mail my mail address is
All Courses

From novice to tech pro — start learning today.