|
1 /* |
|
2 * Copyright (c) 2004 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: Stack to hold the data start and end markers |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngParserStack.h" |
|
20 |
|
21 |
|
22 // ============================ MEMBER FUNCTIONS =============================== |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CPEngParserStack::CPEngParserStack |
|
26 // C++ default constructor can NOT contain any code, that |
|
27 // might leave. |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CPEngParserStack::CPEngParserStack() |
|
31 { |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CPEngParserStack::NewL |
|
36 // Two-phased constructor. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CPEngParserStack* CPEngParserStack::NewL() |
|
40 { |
|
41 CPEngParserStack* self = new( ELeave ) CPEngParserStack; |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 // Destructor |
|
47 CPEngParserStack::~CPEngParserStack() |
|
48 { |
|
49 iStartArray.Reset(); |
|
50 iEndArray.Reset(); |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CPEngParserStack::PushStartL |
|
56 // Pushes a start element to the stack |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 TInt CPEngParserStack::PushStart( TUint aItem ) |
|
60 { |
|
61 return iStartArray.Append( aItem ); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CPEngParserStack::PushEndL |
|
66 // Pushes an end element to the stack |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 TInt CPEngParserStack::PushEnd( TUint aItem ) |
|
70 { |
|
71 return iEndArray.Append( aItem ); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CPEngParserStack::PopStart |
|
76 // Pops a start element from the stack |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 TUint CPEngParserStack::PopStart() |
|
80 { |
|
81 TUint pos( iStartArray.Count() - 1 ); // take the last one |
|
82 TUint returnable( iStartArray[pos] ); |
|
83 |
|
84 iStartArray.Remove( pos ); |
|
85 |
|
86 return returnable; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // CPEngParserStack::PopEnd |
|
91 // Pops an end element from the stack |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 TUint CPEngParserStack::PopEnd() |
|
95 { |
|
96 TUint pos( iEndArray.Count() - 1 ); // take the last one |
|
97 TUint returnable( iEndArray[pos] ); |
|
98 |
|
99 iEndArray.Remove( pos ); |
|
100 |
|
101 return returnable; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CPEngParserStack::Pop |
|
106 // Pops the start&end markers pair from the stack. |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 TPoint CPEngParserStack::Pop() |
|
110 { |
|
111 TPoint returnablePoint; |
|
112 |
|
113 if ( ( iStartArray.Count() > 0 ) && |
|
114 ( iEndArray.Count() > 0 ) ) |
|
115 { |
|
116 returnablePoint.iX = PopStart(); |
|
117 returnablePoint.iY = PopEnd(); |
|
118 } |
|
119 else // something wrong with the array, set negative values |
|
120 { // shouldn't happen, because the WV engine checks the XML |
|
121 returnablePoint.iX = KErrCorrupt; |
|
122 returnablePoint.iY = KErrCorrupt; |
|
123 } |
|
124 |
|
125 return returnablePoint; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CPEngParserStack::Reset |
|
130 // Resets the element arrays |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 void CPEngParserStack::Reset() |
|
134 { |
|
135 iEndArray.Reset(); |
|
136 iStartArray.Reset(); |
|
137 } |
|
138 |
|
139 // End of File |