Symbian3/SDK/Source/GUID-DA4160B0-7B63-5C84-B3C6-190100530EDE.dita
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept xml:lang="en" id="GUID-DA4160B0-7B63-5C84-B3C6-190100530EDE"><title>How to use templated stream operators</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Templated stream operators are straight forward to use. For example, given the class <codeph>TSimple</codeph> defined as:</p> <codeblock id="GUID-E705AC6E-6671-552D-90A3-6BEF66E30A0C" xml:space="preserve">    class TSimple
       
    13           {
       
    14     public :
       
    15           void InternalizeL(RReadStream&amp; aStream);
       
    16           void ExternalizeL(RWriteStream&amp; aStream) const;
       
    17           ...
       
    18           TInt8     iInt8Value;
       
    19           TInt64    iInt64Value;
       
    20           TRect     iRectangle;
       
    21           TUid      iUid;
       
    22           CBufSeg*  iSegBuffer;
       
    23           }</codeblock> <p><codeph>ExternalizeL()</codeph> and <codeph>InternalizeL()</codeph> might be implemented as:</p> <codeblock id="GUID-F89A6EEB-FA20-5A2B-A3DB-33630212DD70" xml:space="preserve">void TSimple::ExternalizeL(RWriteStream&amp; aStream) const
       
    24           {
       
    25           aStream &lt;&lt;  iInt8Value;
       
    26           aStream &lt;&lt;  iInt64Value;
       
    27           aStream &lt;&lt;  iRectangle
       
    28           aStream &lt;&lt;  iUid;
       
    29           aStream &lt;&lt;  *iSegBuffer;
       
    30           }</codeblock> <codeblock id="GUID-DABABB0C-435F-594C-9424-F27EBDC00F17" xml:space="preserve">void TSimple::InternalizeL(RReadStream&amp; aStream)
       
    31           {
       
    32           aStream &gt;&gt;  iInt8Value;
       
    33           aStream &gt;&gt;  iInt64Value;
       
    34           aStream &gt;&gt;  iRectangle
       
    35           aStream &gt;&gt;  iUid;
       
    36           aStream &gt;&gt;  *iSegBuffer;
       
    37           }</codeblock> <p>The templated operators can also be used on an object of type <codeph>TSimple</codeph>. For example:</p> <codeblock id="GUID-326FFA1F-3614-5257-A3F9-1908F25E5DC8" xml:space="preserve">TSimple simple;
       
    38 ...
       
    39 aStream &lt;&lt; simple;
       
    40 ...</codeblock> <p>The <codeph>operator&lt;&lt;</codeph> results in call to <codeph>TSimple::ExternalizeL()</codeph> function and this, in turn, calls <codeph>operator&lt;&lt;</codeph> on <codeph>TSimple</codeph>'s data members.</p> </conbody></concept>