Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-4F882837-0DA1-5243-BA7B-696B418A160E" xml:lang="en"><title>How to
use a package buffer</title><shortdesc>Explains how to use <codeph>TPckg< ></codeph>.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>The following code fragments show an object or a C type struct being written
to a file:</p>
<codeblock id="GUID-852DE4D2-DF5B-50BD-B347-627809FBFA22" xml:space="preserve">TXxx x; // some structure
TPtr8 xDes(&x, sizeof(x)); // descriptor of that structure
file.Write(xDes); // write structure to file</codeblock>
<p>While this approach works, it is not type safe. The descriptor could be
mistaken as referring to an object which is not of type <codeph>TXxx</codeph>.</p>
<p>Use a package buffer which works in a similar way but enforces type safety,
as the following code fragment shows:</p>
<codeblock id="GUID-7EBF5473-C9C8-5056-AEFA-6B3CC8822765" xml:space="preserve">TXxx x; // some structure
TPckg<TXxx> xDes(x); // make into a package
file.Write(xDes); // now write structure t file</codeblock>
</conbody></concept>