-
Let’s say that we have three variables A, B and C. A and C we will always save but B only part of the time. We would save A & C and then conditionally save B. In GD, we would ask for A, C and then B. B might not be there and there is no problem. We can also create and save flags that tell us whether something else was saved. GD is going to have to know whether to request data.
We can’t save more than 32,000 bytes.
if (m_abMyString.GetSize() < 32000)
ss.Store(m_ abMyString);
else
{
Abyte abTruncatedString;
abTruncatedString.Append(m_ abMyString);
abTruncatedString.SetSize(32000);
ss.Store(abTruncatedString);
}
-
Saving an array of ints or pretty much anything else (CList, CMap): We must first save the size of the array. Then using that size, we must traverse the array and save each value. In GD, we get the array size and we know how many ints to get. With CMap, we would traverse the map, saving our key and then our value.
Some real world examples:
No cheat sheet would be worth anything without something from which to cheat. Offered next are some examples that can be lifted into a static. In each case, we show three sections: Declaration, GD, and PD. OD is up to the programmer.