Symbian3/SDK/Source/GUID-24D509E8-CF46-58D3-85E9-27DA7AB22012.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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 task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-24D509E8-CF46-58D3-85E9-27DA7AB22012" xml:lang="en"><title>Constructing
a Static String Table</title><shortdesc>A static string table can be built in any <codeph>.mmp</codeph> file;
the most common use is as part of building an application.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<steps id="GUID-522E1898-F5A8-522F-BFC1-6FF4D7547B71">
<step id="GUID-E113FD8F-BAA7-5E8E-9A26-297151674B89"><cmd/>
<info>Add the following lines to the <codeph>.mmp</codeph> file: </info>
<stepxmp><codeblock id="GUID-C24ECE5F-06A6-5555-8DAE-9D495B119F03" xml:space="preserve">START STRINGTABLE ExampleStringTable.st
EXPORTPATH    /epoc32/include
END</codeblock> </stepxmp>
<info>This code: <ol>
<li id="GUID-C5B75902-2B29-4877-A635-CC1ECF66015C"><p>generates the <codeph>.cpp</codeph> file
and the <codeph>.h</codeph> file </p></li>
<li id="GUID-238CE0F1-088D-4697-AC97-E559B5FC6F9C"><p>copies the generated <codeph>.h</codeph> file
to epoc/include </p></li>
<li id="GUID-9ED42789-193B-4B16-9837-1603D25B4FA4"><p>handles the generated <codeph>.cpp</codeph> file
as part of the source of the overall executable. </p></li>
</ol></info>
</step>
<step id="GUID-123E3BC4-B651-5E1E-AAAD-4F2D56377D1E"><cmd/>
<info>Include the following in the <codeph>bld.inf</codeph> file: </info>
<stepxmp><codeblock id="GUID-595765F3-2AB5-5BAA-91D0-5318EC61DFED" xml:space="preserve">PRJ_MMPFILES
.\StringTableExample.mmp</codeblock> </stepxmp>
</step>
</steps>
<example><title>Static string table example</title> <p>The following is an
example <codeph>.mmp</codeph> file, <codeph>StringTableExample.mmp</codeph>: <filepath/>  </p> <codeblock id="GUID-7227206D-F3D6-5A08-9323-B434E32DD3D9" xml:space="preserve">// StringTableExample.MMP


TARGET          StringTableExample.exe
TARGETTYPE      exe

SYSTEMINCLUDE   \epoc32\include

SOURCEPATH .
SOURCE StringTableExample.cpp

START STRINGTABLE ExampleStringTable.st
EXPORTPATH    /epoc32/include
END

LIBRARY EUSER.LIB BAFL.LIB
VENDORID 0x70000001</codeblock> <p> <b>Note</b>: The previous example <codeph>.mmp</codeph> file
builds the following <codeph>.cpp</codeph> file that uses the string pool: </p> <codeblock id="GUID-6C97F6E5-0C11-5D47-9C1E-B1D9846E0809" xml:space="preserve">// StringTableExample.cpp

#include "e32base.h"
#include "e32svr.h"
#include "StringPool.h"
#include "ExampleStringTable.h"

void StartL()
    {
    TBuf&lt;100&gt; buf;
    RStringPool pool;
    pool.OpenL( ExampleStringTable::Table );
    buf.Copy( pool.StringF( ExampleStringTable::EApple,ExampleStringTable::Table ).DesC() );
    RDebug::Print( buf );
    }

// main loop
//
GLDEF_C TInt E32Main()
    {
    // Install exception handler
    CTrapCleanup* theCleanup = CTrapCleanup::New(); 
    TRAPD( err,StartL() );
    delete theCleanup;
    return( KErrNone );
    }</codeblock> </example>
</taskbody><related-links>
<link href="GUID-27340D18-A31D-512E-920A-B06C784A978A.dita"><linktext>String Pools</linktext>
</link>
<link href="GUID-2B6D7221-A23E-562E-9D9C-5EC197F1CB78.dita"><linktext>Using string
pool</linktext></link>
</related-links></task>