diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-DA4160B0-7B63-5C84-B3C6-190100530EDE.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-DA4160B0-7B63-5C84-B3C6-190100530EDE.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,40 @@ + + + + + +How to use templated stream operators

Templated stream operators are straight forward to use. For example, given the class TSimple defined as:

class TSimple + { + public : + void InternalizeL(RReadStream& aStream); + void ExternalizeL(RWriteStream& aStream) const; + ... + TInt8 iInt8Value; + TInt64 iInt64Value; + TRect iRectangle; + TUid iUid; + CBufSeg* iSegBuffer; + }

ExternalizeL() and InternalizeL() might be implemented as:

void TSimple::ExternalizeL(RWriteStream& aStream) const + { + aStream << iInt8Value; + aStream << iInt64Value; + aStream << iRectangle + aStream << iUid; + aStream << *iSegBuffer; + } void TSimple::InternalizeL(RReadStream& aStream) + { + aStream >> iInt8Value; + aStream >> iInt64Value; + aStream >> iRectangle + aStream >> iUid; + aStream >> *iSegBuffer; + }

The templated operators can also be used on an object of type TSimple. For example:

TSimple simple; +... +aStream << simple; +...

The operator<< results in call to TSimple::ExternalizeL() function and this, in turn, calls operator<< on TSimple's data members.

\ No newline at end of file