//============================================================================ // NNumber::DecodeSelf : Decode the object. //---------------------------------------------------------------------------- void NNumber::DecodeSelf(const NEncoder &theEncoder) { // Decode the object *this = theEncoder.DecodeNumber(kNEncoderValueKey); }
//============================================================================ // NURL::DecodeSelf : Decode the object. //---------------------------------------------------------------------------- void NURL::DecodeSelf(const NEncoder &theEncoder) { // Decode the object mValue = theEncoder.DecodeString(kNEncoderValueKey); }
//============================================================================ // NNumber::EncodeSelf : Encode the object. //---------------------------------------------------------------------------- void NNumber::EncodeSelf(NEncoder &theEncoder) const { // Encode the object theEncoder.EncodeNumber(kNEncoderValueKey, *this); }
//============================================================================ // NURL::EncodeSelf : Encode the object. //---------------------------------------------------------------------------- void NURL::EncodeSelf(NEncoder &theEncoder) const { // Encode the object theEncoder.EncodeString(kNEncoderValueKey, mValue); }
//============================================================================ // NDate::DecodeSelf : Decode the object. //---------------------------------------------------------------------------- void NDate::DecodeSelf(const NEncoder &theEncoder) { // Decode the object mTime = theEncoder.DecodeNumber(kNEncoderValueKey).GetFloat64(); }
//============================================================================ // NDate::EncodeSelf : Encode the object. //---------------------------------------------------------------------------- void NDate::EncodeSelf(NEncoder &theEncoder) const { // Encode the object theEncoder.EncodeNumber(kNEncoderValueKey, mTime); }
// Decode the object void DecodeSelf(const NEncoder &theEncoder) { NArray theArray; NDictionary theDict; NData theData; NN_ASSERT(theEncoder.DecodeBoolean(kKeyBoolean1) == kValueBoolean1); NN_ASSERT(theEncoder.DecodeBoolean(kKeyBoolean2) == kValueBoolean2); NN_ASSERT(theEncoder.DecodeNumber( kKeyNumber1) == kValueNumber1); NN_ASSERT(theEncoder.DecodeNumber( kKeyNumber2) == kValueNumber2); NN_ASSERT(theEncoder.DecodeNumber( kKeyNumber3) == kValueNumber3); NN_ASSERT(theEncoder.DecodeNumber( kKeyNumber4) == kValueNumber4); NN_ASSERT(theEncoder.DecodeString( kKeyString) == kValueString); theData = theEncoder.DecodeData(kKeyData); NN_ASSERT(theData.GetSize() == NN_ARRAY_SIZE(kValueData)); NN_ASSERT(memcmp(theData.GetData(), kValueData, (size_t) theData.GetSize()) == 0); NN_ASSERT(theEncoder.DecodeObject(kKeyArray).GetValue(theArray)); NN_ASSERT(theArray.GetSize() == 3); NN_ASSERT(theArray.GetValueBoolean(0) == kValueBoolean1); NN_ASSERT(theArray.GetValue (1) == kValueNumber1); NN_ASSERT(theArray.GetValueString (2) == kValueString); NN_ASSERT(theEncoder.DecodeObject(kKeyDictionary).GetValue(theDict)); NN_ASSERT(theDict.GetSize() == 6); NN_ASSERT(theDict.GetValueBoolean (kKeyBoolean1) == kValueBoolean1); NN_ASSERT(theDict.GetValue (kKeyNumber1) == kValueNumber1); NN_ASSERT(theDict.GetValueString (kKeyString) == kValueString); NN_ASSERT(theDict.GetValuePoint (kKeyPoint) == kValuePoint); NN_ASSERT(theDict.GetValueSize (kKeySize) == kValueSize); NN_ASSERT(theDict.GetValueRectangle(kKeyRectangle) == kValueRectangle); }
// Encode the object void EncodeSelf(NEncoder &theEncoder) const { NArray theArray; NDictionary theDict; NData theData; theData = NData(NN_ARRAY_SIZE(kValueData), kValueData); theArray.AppendValue(kValueBoolean1); theArray.AppendValue(kValueNumber1); theArray.AppendValue(kValueString); theDict.SetValue(kKeyBoolean1, kValueBoolean1); theDict.SetValue(kKeyNumber1, kValueNumber1); theDict.SetValue(kKeyString, kValueString); theDict.SetValue(kKeyPoint, kValuePoint); theDict.SetValue(kKeySize, kValueSize); theDict.SetValue(kKeyRectangle, kValueRectangle); theEncoder.EncodeBoolean(kKeyBoolean1, kValueBoolean1); theEncoder.EncodeBoolean(kKeyBoolean2, kValueBoolean2); theEncoder.EncodeNumber( kKeyNumber1, kValueNumber1); theEncoder.EncodeNumber( kKeyNumber2, kValueNumber2); theEncoder.EncodeNumber( kKeyNumber3, kValueNumber3); theEncoder.EncodeNumber( kKeyNumber4, kValueNumber4); theEncoder.EncodeString( kKeyString, kValueString); theEncoder.EncodeData( kKeyData, theData); theEncoder.EncodeObject( kKeyArray, theArray); theEncoder.EncodeObject( kKeyDictionary, theDict); }