Symbian3/PDK/Source/GUID-A7D95E53-67DA-54C7-B093-995CA9CC39B5.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     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-A7D95E53-67DA-54C7-B093-995CA9CC39B5" xml:lang="en"><title>How to
       
    13 represent general binary data</title><shortdesc>Construct an 8 bit variant descriptor to represent general binary
       
    14 data.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    15 <p>The kind of data represented or contained by descriptors is not restricted
       
    16 to text. Descriptors can also handle general binary data.</p>
       
    17 <p>Binary data should always be treated as 8 bit data regardless of the build.</p>
       
    18 <p>For example, starting with an area in memory initialised with binary data
       
    19 as follows:</p>
       
    20 <codeblock id="GUID-2541B451-E008-5AD7-A8F7-4A19B76AB2A2" xml:space="preserve">TUint8 data[6] = {0x00,0x01,0x02,0xAD,0xAE,0xAF};</codeblock>
       
    21 <p>construct a modifiable buffer descriptor using the default constructor
       
    22 as follows:</p>
       
    23 <codeblock id="GUID-DDAF1F08-29EC-572F-83B0-0A4437EF1DB9" xml:space="preserve">TBuf8&lt;32&gt; buffer;</codeblock>
       
    24 <p>The following code fragment puts the binary data into the descriptor and
       
    25 appends a number of single byte values. The length of the buffer is 9, the
       
    26 maximum length is 32 and the size is 9 regardless of the build.</p>
       
    27 <codeblock id="GUID-B9AB3D57-1EFB-5A10-882E-E29301FF8759" xml:space="preserve">TInt index;
       
    28 TInt counter;</codeblock>
       
    29 <p>Text and general binary data can be freely mixed and the following code
       
    30 is acceptable:</p>
       
    31 <codeblock id="GUID-2D7B1A85-82F6-5B67-8A49-5E79745602A3" xml:space="preserve">buffer.Append('A');
       
    32 buffer.Append('B');
       
    33 buffer.Append(0x11);</codeblock>
       
    34 <p>Note that fixed length C++ arrays such as <codeph>data</codeph> above can
       
    35 be packaged inside a thin wrapper class, a <codeph>TFixedArray&lt;class T,TInt
       
    36 S&gt;</codeph> type, to guarantee that all array accesses are safe.</p>
       
    37 <section id="GUID-A0922DAD-0D96-4758-8ABA-4C33DC6FE01B"><title>See also</title> <p><xref href="GUID-E41C4E77-C48B-548E-A2F5-14FA5CC68982.dita">Using
       
    38 wrappers</xref> </p> </section>
       
    39 </conbody></concept>