Symbian3/SDK/Source/GUID-9620407B-0560-5D95-A862-5AE406C48983.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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-9620407B-0560-5D95-A862-5AE406C48983" xml:lang="en"><title>String
resource reader overview</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-AF5A789B-6F00-42A9-86AE-CB972F97BE00"><title>Purpose</title> <p>String
Resource Reader is part of the Symbian Text Utilities component. It reads
strings from resource files without using the <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>CCoeEnv</apiname></xref> instance.
This module is mainly for server usage, where there is a need for reading
resources, but there is no <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>CCoeEnv</apiname></xref> instance
present. </p> </section>
<section id="GUID-F336660C-3F54-4B65-85AA-F6D557FE1DC2"><title>Architectural
Relationships</title> <p>The key relationships between String Resource Reader
and the components in its environment are shown below. It uses the <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>RResourceFile</apiname></xref> class to access
the actual resource files. </p> <fig id="GUID-EF915116-AF30-58ED-A3AC-ED104AF22687">
<title>              String Resource Reader environment            </title>
<image href="GUID-B409C23A-F89E-5D30-B172-1F39C3F6A57F_d0e49332_href.png" placement="inline"/>
</fig> <p>String Resource Reader consists of one class, <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>CTulStringResourceReader</apiname></xref>.
String Resource Reader uses <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>BaflUtils</apiname></xref> and <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>RResourceFile.</apiname></xref>  </p> <fig id="GUID-497C1945-CD4F-5396-8B45-E809380A129C">
<title>              Class diagram            </title>
<image href="GUID-5DB0F7C7-6132-552B-BA42-B47D267D1143_d0e49355_href.png" placement="inline"/>
</fig> </section>
<section id="GUID-9595A884-0840-41D5-9448-E0297941DBA9"><title>Description</title> <p><b>Usage</b> </p> <p>String
Resource Reader is designed to load strings from normal resource files. The
interface can be accessed through the <codeph>tulstringresourcereader.h</codeph> file </p> <ul>
<li id="GUID-9EEA6DC6-06BC-50B3-BB0B-9CCFCE21F852"><p>1. The user must first
create an instance of the <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>CTulStringResourceReader</apiname></xref> class
using one of the factory methods <codeph>NewL()</codeph> or <codeph>NewLC()</codeph>. </p> </li>
<li id="GUID-B35D9F76-F4F8-5B43-8FEA-F044F2D63468"><p>2. The user can then
call the exported <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>ReadResourceString()</apiname></xref> method
to read resources </p> </li>
<li id="GUID-51C7AB86-F420-584A-81A4-F652C7338714"><p>3. After usage the created
instance must be deleted. </p> </li>
</ul> <p>If the resource file that is given to a constructor is not found,
the constructor leaves. The standard Symbian platform error codes are used. </p> <p><b>Example</b> </p> <p>An
example of using the interface is given below: </p> <codeblock id="GUID-D484CAC5-5BA0-5666-B1DF-082E0A2A27BA" xml:space="preserve">#include &lt;tulstringresourcereader.h&gt;
#include &lt;errorres.rsg&gt; // Resource to be read header 

//...
TFileName myFileName( _L("z:\\system\\data\\errorres.rsc") );
TulTextResourceUtils* test = TulTextResourceUtils::NewL( myFileName );

TPtrC buf;
buf.Set(test-&gt; ReadResourceString(R_ERROR_RES_GENERAL)); 
   
// Note that buf will only be valid as long as TulTextResourceUtils 
// instance is alive and no new string is read by the same instance.
// If you need to read multiple strings, make copies.

delete test;
</codeblock> <p>For more information on individual methods, see the reference
API for <xref href="GUID-0AAAEFCF-ACFC-302C-81FA-388AACEE979C.dita"><apiname>CTulStringResourceReader</apiname></xref>. </p> </section>
</conbody></concept>