equal
deleted
inserted
replaced
|
1 // Copyright (c) 2008-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 ICL_RECORDTABLE_H |
|
17 #define ICL_RECORDTABLE_H |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 /** |
|
22 This class is used for keeping track of the location and size of structures |
|
23 within container file formats to prevent infinite looping on corrupted files. |
|
24 |
|
25 @internalComponent |
|
26 */ |
|
27 class CRecordTable : public CBase |
|
28 { |
|
29 public: |
|
30 static CRecordTable* NewL(); |
|
31 ~CRecordTable(); |
|
32 TInt InsertRecordL(TInt aRecordStart, TInt aRecordLength); |
|
33 void Reset(); |
|
34 TInt Count() |
|
35 { |
|
36 return iTable.Count(); |
|
37 } |
|
38 |
|
39 protected: |
|
40 CRecordTable(); |
|
41 |
|
42 public: |
|
43 |
|
44 class TRecord |
|
45 { |
|
46 public: |
|
47 TInt iOffset; // from start of file. |
|
48 TInt iLength; // in bytes. |
|
49 |
|
50 public: |
|
51 TRecord(TInt aOffset, TInt aLength) |
|
52 : iOffset(aOffset), |
|
53 iLength(aLength) |
|
54 { |
|
55 } |
|
56 |
|
57 TBool Overlaps(const TRecord& aOther) |
|
58 { |
|
59 if (aOther.iOffset == iOffset) |
|
60 { |
|
61 return ETrue; |
|
62 } |
|
63 |
|
64 if (aOther.iOffset < iOffset) |
|
65 { |
|
66 return ((aOther.iOffset + aOther.iLength) >= iOffset); |
|
67 } |
|
68 |
|
69 return ((iOffset + iLength) > aOther.iOffset); |
|
70 } |
|
71 }; |
|
72 |
|
73 private: |
|
74 RArray<TRecord> iTable; |
|
75 }; |
|
76 |
|
77 #endif |