|
1 /* |
|
2 * Copyright (c) 2005-2006 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 #include "caicontentitemarrayiterator.h" |
|
20 |
|
21 CAiContentItemArrayIterator::CAiContentItemArrayIterator( |
|
22 const TAiContentItem* aArray, |
|
23 TInt aCount ) |
|
24 : iArray( aArray ), |
|
25 iCount( aCount ), |
|
26 iIndex( 0 ) |
|
27 { |
|
28 } |
|
29 |
|
30 CAiContentItemArrayIterator* CAiContentItemArrayIterator::NewL( |
|
31 const TAiContentItem* aArray, |
|
32 TInt aCount ) |
|
33 { |
|
34 CAiContentItemArrayIterator* self = |
|
35 new( ELeave ) CAiContentItemArrayIterator( aArray, aCount ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CAiContentItemArrayIterator::~CAiContentItemArrayIterator() |
|
40 { |
|
41 } |
|
42 |
|
43 void CAiContentItemArrayIterator::Release() |
|
44 { |
|
45 delete this; |
|
46 } |
|
47 |
|
48 TBool CAiContentItemArrayIterator::HasNext() const |
|
49 { |
|
50 return ( iIndex < iCount ); |
|
51 } |
|
52 |
|
53 const TAiContentItem& CAiContentItemArrayIterator::NextL() |
|
54 { |
|
55 if ( iIndex >= iCount ) |
|
56 { |
|
57 User::Leave( KErrOverflow ); |
|
58 } |
|
59 |
|
60 return iArray[iIndex++]; |
|
61 } |
|
62 |
|
63 |
|
64 const TAiContentItem& CAiContentItemArrayIterator::ItemL( TInt aId ) const |
|
65 { |
|
66 TInt i; |
|
67 |
|
68 for ( i = 0; i < iCount; ++i ) |
|
69 { |
|
70 if ( iArray[i].id == aId ) |
|
71 { |
|
72 break; |
|
73 } |
|
74 } |
|
75 |
|
76 if ( i >= iCount ) |
|
77 { |
|
78 User::Leave( KErrNotFound ); |
|
79 } |
|
80 |
|
81 return iArray[i]; |
|
82 } |
|
83 |
|
84 const TAiContentItem& CAiContentItemArrayIterator::ItemL( const TDesC& aCid ) const |
|
85 { |
|
86 TInt i; |
|
87 |
|
88 for ( i = 0; i < iCount; ++i ) |
|
89 { |
|
90 if ( ContentCid( iArray[i] ) == aCid ) |
|
91 { |
|
92 break; |
|
93 } |
|
94 } |
|
95 |
|
96 if ( i >= iCount ) |
|
97 { |
|
98 User::Leave( KErrNotFound ); |
|
99 } |
|
100 |
|
101 return iArray[i]; |
|
102 } |
|
103 |
|
104 |
|
105 void CAiContentItemArrayIterator::Reset() |
|
106 { |
|
107 iIndex = 0; |
|
108 } |
|
109 |