Symbian3/SDK/Source/GUID-4F882837-0DA1-5243-BA7B-696B418A160E.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 id="GUID-4F882837-0DA1-5243-BA7B-696B418A160E" xml:lang="en"><title>How to
       
    13 use a package buffer</title><shortdesc>Explains how to use <codeph>TPckg&lt; &gt;</codeph>.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>The following code fragments show an object or a C type struct being written
       
    15 to a file:</p>
       
    16 <codeblock id="GUID-852DE4D2-DF5B-50BD-B347-627809FBFA22" xml:space="preserve">TXxx x;                    // some structure
       
    17 TPtr8 xDes(&amp;x, sizeof(x)); // descriptor of that structure
       
    18 file.Write(xDes);          // write structure to file</codeblock>
       
    19 <p>While this approach works, it is not type safe. The descriptor could be
       
    20 mistaken as referring to an object which is not of type <codeph>TXxx</codeph>.</p>
       
    21 <p>Use a package buffer which works in a similar way but enforces type safety,
       
    22 as the following code fragment shows:</p>
       
    23 <codeblock id="GUID-7EBF5473-C9C8-5056-AEFA-6B3CC8822765" xml:space="preserve">TXxx x;                    // some structure
       
    24 TPckg&lt;TXxx&gt; xDes(x);       // make into a package
       
    25 file.Write(xDes);          // now write structure t file</codeblock>
       
    26 </conbody></concept>