epoc32/include/mw/tulstringresourcereader.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
#ifndef TULSTRINGRESOURCEREADER_H
williamr@2
    21
#define TULSTRINGRESOURCEREADER_H
williamr@2
    22
williamr@2
    23
#include <coemain.h> // RResourceReader
williamr@2
    24
williamr@2
    25
/**
williamr@2
    26
CTulStringResourceReader reads strings from resource without CCoeEnv.
williamr@2
    27
If resource file given to the constructor is not found, the constructor leaves.
williamr@2
    28
This module is mainly for server usage, where there is the need to read resources,
williamr@2
    29
but no CCoeEnv instance is present.     
williamr@2
    30
williamr@2
    31
Usage:
williamr@2
    32
 
williamr@2
    33
@code
williamr@4
    34
#include <platform/stringresourcereader.h>
williamr@2
    35
#include <errorres.rsg> // Resource to be read header 
williamr@2
    36
williamr@2
    37
TFileName myFileName( _L("z:\\resource\\errorres.rsc") );
williamr@2
    38
CTulStringResourceReader* test = CTulStringResourceReader::NewL( myFileName );
williamr@2
    39
williamr@2
    40
TPtrC buf;
williamr@2
    41
buf.Set(test-> ReadResourceString(R_ERROR_RES_GENERAL)); 
williamr@2
    42
  
williamr@2
    43
// Note that buf will only be valid as long as CTulStringResourceReader 
williamr@2
    44
// instance is alive and no new string is read by the same instance.
williamr@2
    45
// If you need to read multiple strings, make copies.
williamr@2
    46
williamr@2
    47
delete test;
williamr@2
    48
@endcode
williamr@2
    49
williamr@2
    50
@publishedAll
williamr@2
    51
@released 
williamr@2
    52
*/
williamr@2
    53
class CTulStringResourceReader : public CBase
williamr@2
    54
    {
williamr@2
    55
public:  // Constructors and destructor
williamr@2
    56
    IMPORT_C static CTulStringResourceReader* NewL(TFileName& aResFile);
williamr@2
    57
    IMPORT_C static CTulStringResourceReader* NewLC(TFileName& aResFile);     
williamr@2
    58
    IMPORT_C static CTulStringResourceReader* NewL(TFileName& aResFile, RFs& aFs);
williamr@2
    59
    IMPORT_C static CTulStringResourceReader* NewLC(TFileName& aResFile, RFs& aFs);         
williamr@2
    60
    ~CTulStringResourceReader();
williamr@2
    61
public:
williamr@2
    62
	IMPORT_C const TDesC& ReadResourceString( TInt aResourceId );
williamr@2
    63
private:
williamr@2
    64
    CTulStringResourceReader();
williamr@2
    65
    void ConstructL(TFileName& aResFile);
williamr@2
    66
    void ConstructL(TFileName& aResFile, RFs& aFs);
williamr@2
    67
private:
williamr@2
    68
    RResourceFile iResourceFile;
williamr@2
    69
    HBufC* iResourceBuffer;
williamr@2
    70
    RFs iFsSession;
williamr@2
    71
    TPtrC iTruncatedTextPointer;
williamr@2
    72
    TBool iFsConnected; // ETrue if connected to the file server, else EFalse
williamr@2
    73
    };
williamr@2
    74
williamr@2
    75
#endif      // TULSTRINGRESOURCEREADER_H
williamr@2
    76