Constructing a Static String Table

A static string table can be built in any .mmp file; the most common use is as part of building an application.


  1. Add the following lines to the .mmp file:
    START STRINGTABLE ExampleStringTable.st
    EXPORTPATH    /epoc32/include
    END
    This code:
    1. generates the .cpp file and the .h file

    2. copies the generated .h file to epoc/include

    3. handles the generated .cpp file as part of the source of the overall executable.


  2. Include the following in the bld.inf file:
    PRJ_MMPFILES
    .\StringTableExample.mmp

Static string table example

The following is an example .mmp file, StringTableExample.mmp:

// 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

Note: The previous example .mmp file builds the following .cpp file that uses the string pool:

// StringTableExample.cpp

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

void StartL()
    {
    TBuf<100> 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 );
    }