String resource reader overview

Purpose

String Resource Reader is part of the Symbian Text Utilities component. It reads strings from resource files without using the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]CCoeEnv instance. This module is mainly for server usage, where there is a need for reading resources, but there is no [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]CCoeEnv instance present.

Architectural Relationships

The key relationships between String Resource Reader and the components in its environment are shown below. It uses the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]RResourceFile class to access the actual resource files.

Figure: String Resource Reader environment

String Resource Reader consists of one class, [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]CTulStringResourceReader. String Resource Reader uses [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]BaflUtils and [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]RResourceFile.

Figure: Class diagram

Description

Usage

String Resource Reader is designed to load strings from normal resource files. The interface can be accessed through the tulstringresourcereader.h file

  • 1. The user must first create an instance of the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]CTulStringResourceReader class using one of the factory methods NewL() or NewLC().

  • 2. The user can then call the exported [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]ReadResourceString() method to read resources

  • 3. After usage the created instance must be deleted.

If the resource file that is given to a constructor is not found, the constructor leaves. The standard Symbian platform error codes are used.

Example

An example of using the interface is given below:

#include <tulstringresourcereader.h>
#include <errorres.rsg> // Resource to be read header 

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

TPtrC buf;
buf.Set(test-> 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;

For more information on individual methods, see the reference API for [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CTulStringResourceReader']]]CTulStringResourceReader.