|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef TULSTRINGRESOURCEREADER_H |
|
21 #define TULSTRINGRESOURCEREADER_H |
|
22 |
|
23 #include <coemain.h> // RResourceReader |
|
24 |
|
25 /** |
|
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. |
|
30 |
|
31 Usage: |
|
32 |
|
33 @code |
|
34 #include <platform/stringresourcereader.h> |
|
35 #include <errorres.rsg> // Resource to be read header |
|
36 |
|
37 TFileName myFileName( _L("z:\\resource\\errorres.rsc") ); |
|
38 CTulStringResourceReader* test = CTulStringResourceReader::NewL( myFileName ); |
|
39 |
|
40 TPtrC buf; |
|
41 buf.Set(test-> ReadResourceString(R_ERROR_RES_GENERAL)); |
|
42 |
|
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. |
|
46 |
|
47 delete test; |
|
48 @endcode |
|
49 |
|
50 @publishedAll |
|
51 @released |
|
52 */ |
|
53 class CTulStringResourceReader : public CBase |
|
54 { |
|
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(); |
|
61 public: |
|
62 IMPORT_C const TDesC& ReadResourceString( TInt aResourceId ); |
|
63 private: |
|
64 CTulStringResourceReader(); |
|
65 void ConstructL(TFileName& aResFile); |
|
66 void ConstructL(TFileName& aResFile, RFs& aFs); |
|
67 private: |
|
68 RResourceFile iResourceFile; |
|
69 HBufC* iResourceBuffer; |
|
70 RFs iFsSession; |
|
71 TPtrC iTruncatedTextPointer; |
|
72 TBool iFsConnected; // ETrue if connected to the file server, else EFalse |
|
73 }; |
|
74 |
|
75 #endif // TULSTRINGRESOURCEREADER_H |
|
76 |