|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "CXMLObserver.h" |
|
21 |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS =============================== |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CXMLObserver::CXMLObserver |
|
27 // C++ default constructor can NOT contain any code, that |
|
28 // might leave. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CXMLObserver::CXMLObserver() |
|
32 { |
|
33 |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CXMLObserver::ConstructL |
|
38 // Symbian 2nd phase constructor can leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void CXMLObserver::ConstructL() |
|
42 { |
|
43 iCurrentAttribute = new(ELeave) TPtrC(); |
|
44 iAttributes = CXMLAttributes::NewL(); |
|
45 iDescElements = new (ELeave) CDesCArraySeg(1); |
|
46 iNSextensions = new (ELeave) CDesCArraySeg(1); |
|
47 iURIs = new (ELeave) CDesCArraySeg(1); |
|
48 iContentHandler = NULL; |
|
49 iBinaryContentHandler = NULL; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CXMLObserver::NewL |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CXMLObserver* CXMLObserver::NewL() |
|
58 { |
|
59 CXMLObserver* self = new( ELeave ) CXMLObserver(); |
|
60 |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(); |
|
64 |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CXMLObserver::~CXMLObserver |
|
71 // Destructor. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CXMLObserver::~CXMLObserver() |
|
75 { |
|
76 if (iCurrentAttribute) |
|
77 { |
|
78 delete iCurrentAttribute; |
|
79 } |
|
80 if(iAttributes) |
|
81 { |
|
82 delete iAttributes; |
|
83 } |
|
84 if(iDescElements) |
|
85 { |
|
86 delete iDescElements; |
|
87 } |
|
88 if(iNSextensions) |
|
89 { |
|
90 delete iNSextensions; |
|
91 } |
|
92 if(iURIs) |
|
93 { |
|
94 delete iURIs; |
|
95 } |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CXMLObserver::SetElement |
|
100 // |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CXMLObserver::SetElementL(const TPtrC &aName) |
|
104 { |
|
105 if(iDescElements) |
|
106 { |
|
107 iDescElements->AppendL(aName); |
|
108 } |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CXMLObserver::GetElement |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TPtrC CXMLObserver::GetElement() const |
|
117 { |
|
118 TInt wIndex = iDescElements->Count()-1; |
|
119 if(wIndex < 0) |
|
120 { |
|
121 TPtrC wEmpty = _L(" "); |
|
122 return wEmpty; |
|
123 |
|
124 } |
|
125 return iDescElements->MdcaPoint(wIndex); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CXMLObserver::GetElement |
|
130 // |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CXMLObserver::RemoveElement() |
|
134 { |
|
135 TInt wIndex = iDescElements->Count()-1; |
|
136 if(wIndex > -1) |
|
137 { |
|
138 iDescElements->Delete(wIndex); |
|
139 iDescElements->Compress(); |
|
140 } |
|
141 } |
|
142 |
|
143 void CXMLObserver::SetURIL(const TPtrC &aURI, const TPtrC &aNSextension) |
|
144 { |
|
145 iNSextensions->AppendL(aNSextension); |
|
146 iURIs->AppendL(aURI); |
|
147 } |
|
148 |
|
149 TPtrC CXMLObserver::GetURI(const TPtrC &aNSextension) const |
|
150 { |
|
151 TInt wIndex = 0; |
|
152 TInt wRes = 0; |
|
153 |
|
154 wRes = iNSextensions->Find(aNSextension,wIndex); |
|
155 if(wRes != 0) |
|
156 { |
|
157 TPtrC wEmpty = _L(" "); |
|
158 return wEmpty; |
|
159 } |
|
160 return iURIs->MdcaPoint(wIndex); |
|
161 } |
|
162 void CXMLObserver::ResetURI() |
|
163 { |
|
164 iNSextensions->Reset(); |
|
165 iURIs->Reset(); |
|
166 } |
|
167 |
|
168 // End of File |