Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to externalise and internalise compound objects

Compound objects can be externalised and internalised. The only assumption is that all component objects (and their component objects) must be capable of being externalised and internalised.

In this example, a compound object, an instance of the CCompound class, is externalised to, and internalised from, a single stream. The class is defined as:

class CCompound : public CBase
    {
public :
    void ExternalizeL(RWriteStream& aStream) const;
    void ExternalizeL(RReadStream& aStream);
    ...
    CClassA* iCa;
    CClassB* iCb;
    TClassC  iTc;
    };

[Top]


Externalising

The preferred implementation of the ExternalizeL() function is:

void CCompound::ExternalizeL(RWriteStream& aStream) const
    {
    aStream << *iCa;
    aStream << *iCb;
    aStream << iTc;
    }

The following implementation is also correct:

void CCompound::ExternalizeL(RWriteStream& aStream) const
    {
    iCa->ExternalizeL(aStream);
    iCb->ExternalizeL(aStream);
    iTc.ExternalizeL(aStream);
    }

[Top]


Internalising

The preferred implementation of the InternalizeL() function is:

void CCompound::InternalizeL(RReadStream& aStream)
    {
    aStream >> *iCa;
    aStream >> *iCb;
    aStream >>  iTc;
    }

The following implementation is also correct:

void CCompound::InternalizeL(RReadStream& aStream)
    {
    iCa->InternalizeL(aStream);
    iCb->InternalizeL(aStream);
    iTc.InternalizeL(aStream);
    }