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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.