For this example, we use the class above but we put it in a CMap. The Key field is an int. This is much like the code for the CList.
Declaration:
CMap<int, const int&, FieldData, FieldData &> MyMap;
PD:
FieldData FldData;
int Key;
int MapSize;
POSITION pos;
MapSize = MyMap.GetSize();
ss.Store(MapSize);
pos = MyMap.GetStartPosition();
while (pos != NULL)
{
MyMap.GetNextAssoc( pos, Key, FldData);
ss.Store(Key);
FldData.Store(ss);
}
ss.RetrieveStream(abStatic); // move data from ss to abstatic
GD:
CStaticStorage ss(abStatic); // get data from abStatic
FieldData FldData;
int Key;
int MapSize;
int Indx;
MyMap.RemoveAll();
ss.Get(MapSize);
for(Indx = 0; Indx < MapSize; Indx ++)
{
ss.Get(Key);
FldData.Get(ss);
MyMap[Key] = FieldData (FldData.Var1, FldData.Var2);
}