|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __BARSCIMPL_H__ |
|
17 #define __BARSCIMPL_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <f32file.h> |
|
21 |
|
22 //Forward declarations |
|
23 struct SDictionaryCompressionData; |
|
24 class RDictionaryCompressionBitStream; |
|
25 class TBaAssert; |
|
26 |
|
27 /** Accesses a resource file and reads the resource data into a buffer. |
|
28 |
|
29 It is the implementation class for RResourceFile and CResourceFile classes. |
|
30 |
|
31 Because of BC reasons, the size of RResourceFileImpl must be the same as |
|
32 the size of RResourceFile class. |
|
33 |
|
34 It is expected that all resources deallocation must be done in Close() method. |
|
35 (BC reasons - RResourceFile reserves enough space for the RResourceFileImpl |
|
36 instance and uses placement new operator to create it. But RResourceFile doesn't have a |
|
37 destructor, so there is no predictable way how the RResourceFileImpl |
|
38 destructor might be called, even if the class has user defined destructor). |
|
39 |
|
40 Expected behaviour when assignment operator or copy constructor is called: |
|
41 The class doesn't have assignment operator and copy constructor, so the compiler generated |
|
42 ones will be used. The heap buffers used by the source class instance will be shared with the |
|
43 destination class instance. |
|
44 |
|
45 Methods panic/leave behaviour: "L" methods panics/leave behaviour depends on iAssertObj |
|
46 member (iExtra data member actually). If iAssertObj internal state is TBaAssert::EPanic - |
|
47 "L" methods will panic, otherwise they will leave if something goes wrong. |
|
48 |
|
49 @internalComponent |
|
50 @see RResourceFile |
|
51 @see CResourceFile */ |
|
52 class RResourceFileImpl |
|
53 { |
|
54 public: |
|
55 RResourceFileImpl(); |
|
56 ~RResourceFileImpl(); |
|
57 void OpenL( |
|
58 RFs& aFs, |
|
59 const TDesC& aName, |
|
60 const TBaAssert& aAssert, |
|
61 TUint aFileOffset = 0, |
|
62 TInt aFileSize = 0); |
|
63 void OpenL(const TDesC8& aRscArchive,const TBaAssert& aAssert); |
|
64 void Close(); |
|
65 TUidType UidType() const; |
|
66 void ReadL(TDes8 &aDes, TInt aResourceId) const; |
|
67 HBufC8 *AllocReadLC(TInt aResourceId) const; |
|
68 void ConfirmSignatureL(TInt aSignature); |
|
69 void ConfirmSignatureL(); |
|
70 TInt SignatureL() const; |
|
71 TBool OwnsResourceIdL(TInt aResourceId) const; |
|
72 TInt Offset() const; |
|
73 private: |
|
74 struct SSigRecord |
|
75 { |
|
76 TInt signature; |
|
77 TInt offset; |
|
78 }; |
|
79 enum |
|
80 { |
|
81 EFlagIsRomFile =0x80000000, |
|
82 EFlagPotentiallyContainsCompressedUnicode =0x40000000, |
|
83 EFlagDictionaryCompressed =0x20000000, |
|
84 EFlagThirdUidIsOffset =0x10000000, |
|
85 EFlagGenerate_RSS_SIGNATURE_ForFirstUserResource =0x08000000, |
|
86 EFlagFirstResourceIsGeneratedBitArrayOfResourcesContainingCompressedUnicode =0x04000000, |
|
87 EFlagCalypsoFileFormat =0x02000000, |
|
88 EFlagIsBufferRscFile =0x01000000, |
|
89 EAllFlags =0xff000000 |
|
90 }; |
|
91 enum |
|
92 { |
|
93 EOffsetBits =0xfffff000, |
|
94 EIdBits =0x00000fff |
|
95 }; |
|
96 class TExtra; |
|
97 private: |
|
98 void ReadL(TInt aPos,TDes8& aDes,TInt aLength) const; |
|
99 SSigRecord FirstRecordL() const; |
|
100 |
|
101 void AppendDecompressedUnicodeL(TDes8& aBuffer,const TDesC8& aCompressedUnicode) const; |
|
102 HBufC8* DecompressUnicodeL( |
|
103 const TDesC8& aDictionaryDecompressedResourceData, |
|
104 TInt aSizeOfLargestResourceWhenCompletelyUncompressed) const; |
|
105 HBufC8* DictionaryDecompressedResourceDataLC( |
|
106 TInt aResourceIndex, |
|
107 TUint aFlags, |
|
108 const SDictionaryCompressionData& aDictionaryCompressionData, |
|
109 const TDesC16& aIndex) const; |
|
110 void AppendDictionaryCompressionBitStreamL( |
|
111 RArray<RDictionaryCompressionBitStream>& aStackOfDictionaryCompressionBitStreams, |
|
112 TUint aFlags, |
|
113 const SDictionaryCompressionData& aDictionaryCompressionData, |
|
114 TInt aStartOfBitData, |
|
115 TInt aStartOfIndex, |
|
116 TInt aIndexEntry) const; |
|
117 TInt LittleEndianTwoByteIntegerL(const TDesC8& aBuffer,TInt aIndexOfFirstByte) const; |
|
118 void ReadL(TUint aFlags,TInt aPos,TDes8& aDes,TInt aLength) const; |
|
119 void ReadHeaderAndResourceIndexL(); |
|
120 |
|
121 private: |
|
122 TAny* iFile; // either an RFile*, or a const TUint8* pointing into ROM |
|
123 TInt iSizeOfLargestResourceWhenCompletelyUncompressed; |
|
124 //basically an array of (unsigned) 16-bit file-positions - |
|
125 //this is only used for non-dictionary-compressed resource files |
|
126 HBufC16* iIndex; |
|
127 //the position of this member in the class is exposed because RResourceFile::Offset() is |
|
128 //an inline function accessing "iOffset". RResourceFileImpl is an implementation class for |
|
129 //RResourceFile class. The "iOffset" offset from the beginning of the class must be exactly |
|
130 //12 bytes. |
|
131 TInt iOffset; |
|
132 TExtra* iExtra; |
|
133 TUint iFlagsAndNumberOfResources; |
|
134 }; |
|
135 |
|
136 #endif//__BARSCIMPL_H__ |