Symbian3/PDK/Source/GUID-7830BAAB-40DD-5E55-84B5-8DCA888E68E7.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?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-7830BAAB-40DD-5E55-84B5-8DCA888E68E7" xml:lang="en"><title>Using
TDesC</title><shortdesc>Use TDesC for interfaces which take narrow or wide (Unicode) text,
depending on the build variant, but does not change the data.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-235E272D-6F5A-5740-8150-9698C8C8D55D"><title>Usage in a
function interface</title> <p>An interface which needs access to either narrow
text or wide (Unicode) text, depending on the build variant, but which does
not need to change that data in any way, can use a <xref href="GUID-52D07F46-2162-380C-A775-C3BB335C42F5.dita"><apiname>TDesC</apiname></xref> as
the argument type. All build independent concrete descriptors are derived
from <codeph>TDesC</codeph> which means that the interface can accept any
build independent descriptor.</p> <p>The following code fragment shows the
most common function prototype pattern.</p> <codeblock id="GUID-1FAB92F0-D8D1-51C9-B993-9F0FF93659B3" xml:space="preserve">void ClassX::foo(const TDesC&amp; anArg);</codeblock> <p>The use of <codeph>TDesC</codeph> ensures that the data cannot be modified
through the descriptor; <codeph>const</codeph> is an extra guarantee that
the data cannot be changed.</p> <p>If the interface is to handle explicit
8 bit or explicit 16 bit data, regardless of the build variant, then use <codeph>TDesC8</codeph> or <codeph>TDesC16</codeph> instead.</p> </section>
</conbody></concept>