2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #ifndef TULSTRINGRESOURCEREADER_H
21 #define TULSTRINGRESOURCEREADER_H
23 #include <coemain.h> // RResourceReader
26 CTulStringResourceReader reads strings from resource without CCoeEnv.
27 If resource file given to the constructor is not found, the constructor leaves.
28 This module is mainly for server usage, where there is the need to read resources,
29 but no CCoeEnv instance is present.
34 #include <platform/stringresourcereader.h>
35 #include <errorres.rsg> // Resource to be read header
37 TFileName myFileName( _L("z:\\resource\\errorres.rsc") );
38 CTulStringResourceReader* test = CTulStringResourceReader::NewL( myFileName );
41 buf.Set(test-> ReadResourceString(R_ERROR_RES_GENERAL));
43 // Note that buf will only be valid as long as CTulStringResourceReader
44 // instance is alive and no new string is read by the same instance.
45 // If you need to read multiple strings, make copies.
53 class CTulStringResourceReader : public CBase
55 public: // Constructors and destructor
56 IMPORT_C static CTulStringResourceReader* NewL(TFileName& aResFile);
57 IMPORT_C static CTulStringResourceReader* NewLC(TFileName& aResFile);
58 IMPORT_C static CTulStringResourceReader* NewL(TFileName& aResFile, RFs& aFs);
59 IMPORT_C static CTulStringResourceReader* NewLC(TFileName& aResFile, RFs& aFs);
60 ~CTulStringResourceReader();
62 IMPORT_C const TDesC& ReadResourceString( TInt aResourceId );
64 CTulStringResourceReader();
65 void ConstructL(TFileName& aResFile);
66 void ConstructL(TFileName& aResFile, RFs& aFs);
68 RResourceFile iResourceFile;
69 HBufC* iResourceBuffer;
71 TPtrC iTruncatedTextPointer;
72 TBool iFsConnected; // ETrue if connected to the file server, else EFalse
75 #endif // TULSTRINGRESOURCEREADER_H