|
1 /* |
|
2 * Copyright (c) 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 #include "tsidlist.h" |
|
18 |
|
19 //------------------------------------------------------------------------------ |
|
20 CTsIdList* CTsIdList::NewLC() |
|
21 { |
|
22 CTsIdList* self = new(ELeave)CTsIdList(); |
|
23 CleanupStack::PushL( self ); |
|
24 return self; |
|
25 } |
|
26 |
|
27 //------------------------------------------------------------------------------ |
|
28 CTsIdList* CTsIdList::NewL() |
|
29 { |
|
30 CTsIdList* self = CTsIdList::NewLC(); |
|
31 CleanupStack::Pop( self ); |
|
32 return self; |
|
33 } |
|
34 |
|
35 //------------------------------------------------------------------------------ |
|
36 CTsIdList* CTsIdList::NewLC(RReadStream& aStream) |
|
37 { |
|
38 CTsIdList* self = CTsIdList::NewLC(); |
|
39 aStream >> (*self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 //------------------------------------------------------------------------------ |
|
44 CTsIdList::CTsIdList() |
|
45 { |
|
46 //No implementation required |
|
47 } |
|
48 |
|
49 //------------------------------------------------------------------------------ |
|
50 CTsIdList::~CTsIdList() |
|
51 { |
|
52 iIds.Reset(); |
|
53 } |
|
54 |
|
55 //------------------------------------------------------------------------------ |
|
56 TBool CTsIdList::IsPresent( TInt aId ) const |
|
57 { |
|
58 return KErrNotFound != iIds.Find(aId); |
|
59 } |
|
60 |
|
61 //------------------------------------------------------------------------------ |
|
62 void CTsIdList::AppendL(const TInt aArray[], TInt aSize ) |
|
63 { |
|
64 for( TInt iter(0); iter < aSize; ++iter ) |
|
65 { |
|
66 AppendL( aArray[iter] ); |
|
67 } |
|
68 } |
|
69 |
|
70 //------------------------------------------------------------------------------ |
|
71 void CTsIdList::AppendL(const TArray<TInt>& aArray) |
|
72 { |
|
73 for( TInt iter(0); iter < aArray.Count(); ++iter ) |
|
74 { |
|
75 AppendL( aArray[iter] ); |
|
76 } |
|
77 } |
|
78 |
|
79 //------------------------------------------------------------------------------ |
|
80 void CTsIdList::AppendL(TInt aId) |
|
81 { |
|
82 if( !IsPresent( aId ) ) |
|
83 { |
|
84 iIds.AppendL( aId ); |
|
85 } |
|
86 } |
|
87 |
|
88 //------------------------------------------------------------------------------ |
|
89 void CTsIdList::Reset() |
|
90 { |
|
91 iIds.Reset(); |
|
92 } |
|
93 |
|
94 //------------------------------------------------------------------------------ |
|
95 TInt CTsIdList::Size() const |
|
96 { |
|
97 return ( iIds.Count() + 1 ) * sizeof( TInt ); |
|
98 } |
|
99 |
|
100 //------------------------------------------------------------------------------ |
|
101 void CTsIdList::ExternalizeL(RWriteStream &aStream) const |
|
102 { |
|
103 aStream.WriteInt32L(iIds.Count()); |
|
104 for( TInt iter(0); iter < iIds.Count(); ++iter ) |
|
105 { |
|
106 aStream.WriteInt32L(iIds[iter]); |
|
107 } |
|
108 } |
|
109 |
|
110 //------------------------------------------------------------------------------ |
|
111 void CTsIdList::InternalizeL(RReadStream &aStream) |
|
112 { |
|
113 Reset(); |
|
114 const TInt count( aStream.ReadInt32L()); |
|
115 for( TInt iter(0); iter < count; ++iter ) |
|
116 { |
|
117 AppendL( aStream.ReadInt32L() ); |
|
118 } |
|
119 } |
|
120 |