112 Function to read specified bytes from the RSC file |
118 Function to read specified bytes from the RSC file |
113 @param aFlags Integer conatainig no of resource and status flags. |
119 @param aFlags Integer conatainig no of resource and status flags. |
114 @param aPos Offset from where to begin reading |
120 @param aPos Offset from where to begin reading |
115 @param aData Buffer to store read values |
121 @param aData Buffer to store read values |
116 @param aLength Length of the bytes to be read. |
122 @param aLength Length of the bytes to be read. |
117 */ |
123 @return Length of the bytes to be read. |
118 void ReadL(const TUint32& aFlags, TInt aPos, TUint8* aData, const TInt& aLength); |
124 */ |
|
125 TInt ReadL(const TUint32& aFlags, TInt aPos, TUint8* aData, const TInt& aLength); |
119 |
126 |
120 /** @internalComponent |
127 /** @internalComponent |
121 @return The first resource record. |
128 @return The first resource record. |
122 @panic Some BAFL panic codes, if the file is corrupted. |
129 @panic Some BAFL panic codes, if the file is corrupted. |
123 @leave KErrCorrupt The file is corrupted. |
130 @leave KErrCorrupt The file is corrupted. |
153 responsibility to deallocate the allocated memory. |
160 responsibility to deallocate the allocated memory. |
154 @param aInputResourceData Compressed data. |
161 @param aInputResourceData Compressed data. |
155 @return Pointer to decompressed data |
162 @return Pointer to decompressed data |
156 */ |
163 */ |
157 Ptr8* DecompressUnicodeL(const Ptr8* aInputResourceData) const; |
164 Ptr8* DecompressUnicodeL(const Ptr8* aInputResourceData) const; |
|
165 |
|
166 |
|
167 /** |
|
168 The method will decompress the dictionary compressed data, allocate enough |
|
169 memory from the heap for the decompressed data, copy the data there and return a pointer |
|
170 to the decompressed data. |
|
171 The method doesn't own the allocated heap memory for the decompressed data. It's a caller |
|
172 responsibility to deallocate the allocated memory. |
|
173 @pre OpenL() is called. |
|
174 @leave KErrCorrupt The file is corrupted. |
|
175 @leave KErrNoMemory There is not enough memory for the decompressed data. |
|
176 Some other error codes are possible too. |
|
177 */ |
|
178 Ptr8* DictionaryDecompressedResourceDataL( |
|
179 TInt aResourceIndex, |
|
180 TUint aFlags, |
|
181 const SDictionaryCompressionData& aDictionaryCompressionData, |
|
182 const Ptr16* aIndex) const; |
|
183 |
|
184 |
|
185 /** |
|
186 The method will decomress the dictionary compressed data (aDictionaryCompressionData argument) and append |
|
187 the decompressed data to the end of std::vector<RDictionaryCompressionBitStream> |
|
188 (aStackOfDictionaryCompressionBitStreams argument). |
|
189 */ |
|
190 void AppendDictionaryCompressionBitStreamL( |
|
191 std::vector<RDictionaryCompressionBitStream>& aStackOfDictionaryCompressionBitStreams, |
|
192 TUint aFlags, |
|
193 const SDictionaryCompressionData& aDictionaryCompressionData, |
|
194 TInt aStartOfBitData, |
|
195 TInt aStartOfIndex, |
|
196 TInt aIndexEntry) const; |
158 |
197 |
159 /** |
198 /** |
160 Get the two bytes(in Little Endian format) from the specified buffer |
199 Get the two bytes(in Little Endian format) from the specified buffer |
161 @param aBuffer Buffer address from which 2-bytes are to be achieved. |
200 @param aBuffer Buffer address from which 2-bytes are to be achieved. |
162 @param aIndexOfFirstByte Offset of the first byte to be retrieved from the |
201 @param aIndexOfFirstByte Offset of the first byte to be retrieved from the |
163 buffer. |
202 buffer. |
164 @return 2-bytes read from the buffer. |
203 @return 2-bytes read from the buffer. |
165 */ |
204 */ |
166 TInt LittleEndianTwoByteInteger(TUint8* aBuffer,const TInt& aIndexOfFirstByte) const; |
205 |
167 Ptr8* GetDecompressedResourceDataL( |
206 TInt LittleEndianTwoByteInteger(const TUint8* aBuffer,const TInt& aIndexOfFirstByte,TInt aLength) const; |
168 const TInt& aResourceIndex, |
207 |
169 const TUint32& aFlags); |
|
170 |
208 |
171 private: |
209 private: |
172 std::ifstream* iResourceContents; |
210 std::ifstream* iResourceContents; |
173 TInt iSizeOfLargestResourceWhenCompletelyUncompressed; |
211 TInt iSizeOfLargestResourceWhenCompletelyUncompressed; |
174 // An array of (unsigned) 16-bit file-positions |
212 //basically an array of (unsigned) 16-bit file-positions - |
175 TUint16* iIndex; |
213 //this is only used for non-dictionary-compressed resource files |
|
214 Ptr16* iIndex; |
|
215 |
|
216 //the position of this member in the class is exposed because RResourceFile::Offset() is |
|
217 //an inline function accessing "iOffset". RResourceFileImpl is an implementation class for |
|
218 //RResourceFile class. The "iOffset" offset from the beginning of the class must be exactly |
|
219 //12 bytes. |
176 TInt iOffset; |
220 TInt iOffset; |
177 TExtra* iExtra; |
221 TExtra* iExtra; |
178 TUint32 iFlagsAndNumberOfResources; |
222 TUint32 iFlagsAndNumberOfResources; |
|
223 }; |
|
224 |
|
225 |
|
226 struct SDictionaryCompressionData |
|
227 { |
|
228 inline SDictionaryCompressionData() : |
|
229 iStartOfDictionaryData(0), |
|
230 iStartOfDictionaryIndex(0), |
|
231 iNumberOfDictionaryEntries(0), |
|
232 iStartOfResourceData(0), |
|
233 iStartOfResourceIndex(0), |
|
234 iNumberOfBitsUsedForDictionaryTokens(0), |
|
235 iCachedDictionaryIndex(0), |
|
236 iCachedResourceBuffer(0)// = NULL; |
|
237 { |
|
238 } |
|
239 TInt iStartOfDictionaryData; |
|
240 TInt iStartOfDictionaryIndex; |
|
241 TInt iNumberOfDictionaryEntries; |
|
242 TInt iStartOfResourceData; |
|
243 TInt iStartOfResourceIndex; |
|
244 TInt iNumberOfBitsUsedForDictionaryTokens; |
|
245 TUint16* iCachedDictionaryIndex; |
|
246 TUint8* iCachedResourceBuffer; |
|
247 |
179 }; |
248 }; |
180 |
249 |
181 |
250 |
182 /** |
251 /** |
183 Stores the RSC filesize, offset and the bit-array |
252 Stores the RSC filesize, offset and the bit-array |
192 /** |
261 /** |
193 Finds whether the specified resource contain compressed unicode |
262 Finds whether the specified resource contain compressed unicode |
194 @param aRscIdx Resource Index |
263 @param aRscIdx Resource Index |
195 @return Status of whether the resource is actually present or not. |
264 @return Status of whether the resource is actually present or not. |
196 */ |
265 */ |
197 TInt32 ContainsCompressedUnicode(const TInt& aRscIdx) const; |
266 TInt32 ContainsCompressedUnicode(TInt& aRscIdx, TBool aFirstRscIsGen) const; |
198 |
267 |
199 private: |
268 private: |
200 // Prevent default copy constructor |
269 // Prevent default copy constructor |
201 TExtra(const TExtra&); |
270 TExtra(const TExtra&); |
202 // Prevent default "=" operator |
271 // Prevent default "=" operator |
203 TExtra& operator=(const TExtra&); |
272 TExtra& operator=(const TExtra&); |
204 |
273 |
205 public: |
274 public: |
206 // RSC file UID |
275 // RSC file UID |
207 sTUid iUid; |
276 TUidType iUidType; |
208 // An array of bits, one for each resource in the resource file |
277 // An array of bits, one for each resource in the resource file |
209 TUint8* iBitArrayOfResourcesContainingCompressedUnicode; |
278 Ptr8* iBitArrayOfResourcesContainingCompressedUnicode; |
|
279 SDictionaryCompressionData iDictionaryCompressionData; |
210 // Offset of RSC chunk |
280 // Offset of RSC chunk |
211 TInt iFileOffset; |
281 TInt iFileOffset; |
212 // RSC file size |
282 // RSC file size |
213 TUint32 iFileSize; |
283 TUint32 iFileSize; |
214 }; |
284 }; |
215 |
285 |
|
286 |
216 #endif//__BARSCIMPL_H__ |
287 #endif//__BARSCIMPL_H__ |