Link to home
Start Free TrialLog in
Avatar of dagan
dagan

asked on

serialize a CUIntArray?

Hi all,
I am trying to serialize a CUIntArray, but as far as I can see, CUIntArray.Serialize() is not implemented and so CObject.Serialize() is called.
I also tried to override :
CArchive& operator<<( CArchive& ar, const CUIntArray arrUint );
CArchive& operator>>( CArchive& ar, CUIntArray arrUint );
but then I get a
"binary '<<' : no operator defined which takes a left-hand operand of type 'class CArchive' (or there is no acceptable conversion)" errors on compile.
so,
1. Is there a proper way to serialize a non-template array?
2. Is there a reason why CUIntArray.Serialize is not implemented?
3. Is my "operator<<(...)" syntax incorrect?
4. Any other ideas?

thanxs in advance,
        Dagan
ASKER CERTIFIED SOLUTION
Avatar of PIG
PIG

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
Avatar of dagan
dagan

ASKER

hi pig,
Eventually I believe that this is what I'll do... meanwhile you'll excuse me for not giving you the points since I wanna give others the chance to answer THE OTHER QUESTIONS.
I promise that if I won't get better answers, you'll be rewarded for yours.
It's just that it seems a little weird that there's no pretty solution built in.
OK.
void CYurUIntArray::Serialize(CArchive& ar){
 ASSERT_VALID(this);

 CObject::Serialize(ar);

 if (ar.IsStoring()){
   ar.WriteCount(m_nSize);
   for (int i = 0; i < m_nSize; i++)
     ar << m_pData[i];
 }else{
  DWORD nOldSize = ar.ReadCount();
  SetSize(nOldSize);
  for (int i = 0; i < m_nSize; i++)
    ar >> m_pData[i];
 }
}
That can be sufficient for You.