|
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: Represent single xmluiml attribute |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "hspsdomattribute.h" |
|
22 #include "hspsdomstringpool.h" |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 // ----------------------------------------------------------------------------- |
|
26 // ChspsDomAttribute::ChspsDomAttribute |
|
27 // C++ default constructor can NOT contain any code, that |
|
28 // might leave. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 ChspsDomAttribute::ChspsDomAttribute( ChspsDomStringPool& aStringPool ): |
|
32 iStringPool( aStringPool ), |
|
33 iNameRef( KErrNotFound ), |
|
34 iValueRef( KErrNotFound ) |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // ChspsDomAttribute::ConstructL |
|
40 // Symbian 2nd phase constructor can leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 void ChspsDomAttribute::ConstructL( const TDesC8& aName ) |
|
44 { |
|
45 iNameRef = iStringPool.AddStringL( aName ); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // ChspsDomAttribute::ConstructL |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void ChspsDomAttribute::ConstructL( const TInt aName ) |
|
54 { |
|
55 iNameRef = aName; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // ChspsDomAttribute::NewL |
|
60 // Two-phased constructor. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C ChspsDomAttribute* ChspsDomAttribute::NewL( |
|
64 const TDesC8& aName, |
|
65 ChspsDomStringPool& aStringPool ) |
|
66 { |
|
67 ChspsDomAttribute* self = new( ELeave ) ChspsDomAttribute( aStringPool ); |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL( aName ); |
|
71 CleanupStack::Pop( self ); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // ChspsDomAttribute::NewL |
|
78 // Two-phased constructor. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C ChspsDomAttribute* ChspsDomAttribute::NewL( |
|
82 const TInt aName, |
|
83 ChspsDomStringPool& aStringPool ) |
|
84 { |
|
85 ChspsDomAttribute* self = new( ELeave ) ChspsDomAttribute( aStringPool ); |
|
86 |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL( aName ); |
|
89 CleanupStack::Pop( self ); |
|
90 |
|
91 return self; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // ChspsDomAttribute::NewL |
|
96 // Two-phased stream constructor. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 ChspsDomAttribute* ChspsDomAttribute::NewL( |
|
100 RReadStream& aStream, |
|
101 ChspsDomStringPool& aStringPool ) |
|
102 { |
|
103 ChspsDomAttribute* self = new( ELeave ) ChspsDomAttribute( aStringPool ); |
|
104 CleanupStack::PushL( self ); |
|
105 aStream >> *self; |
|
106 CleanupStack::Pop( self ); |
|
107 |
|
108 return self; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // ChspsDomAttribute::~ChspsDomAttribute |
|
113 // Destructor |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C ChspsDomAttribute::~ChspsDomAttribute() |
|
117 { |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // ChspsDomAttribute::CloneL |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C ChspsDomAttribute* ChspsDomAttribute::CloneL() |
|
125 { |
|
126 ChspsDomAttribute* clone = new (ELeave)ChspsDomAttribute( iStringPool ); |
|
127 clone->iNameRef = iNameRef; |
|
128 clone->iValueRef = iValueRef; |
|
129 return clone; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // ChspsDomAttribute::CloneL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 ChspsDomAttribute* ChspsDomAttribute::CloneL( ChspsDomStringPool& aStringPool, |
|
137 const TBool aFastClone ) |
|
138 { |
|
139 ChspsDomAttribute* clone = NULL; |
|
140 |
|
141 if( aFastClone ) |
|
142 { |
|
143 clone = ChspsDomAttribute::NewL( iNameRef, aStringPool ); |
|
144 } |
|
145 else |
|
146 { |
|
147 const TDesC8& name = iStringPool.String( iNameRef ); |
|
148 clone = ChspsDomAttribute::NewL( name, aStringPool ); |
|
149 } |
|
150 |
|
151 CleanupStack::PushL( clone ); |
|
152 |
|
153 if ( iValueRef > KErrNotFound ) |
|
154 { |
|
155 if( aFastClone ) |
|
156 { |
|
157 clone->SetValueL( iValueRef ); |
|
158 } |
|
159 else |
|
160 { |
|
161 const TDesC8& value = iStringPool.String( iValueRef ); |
|
162 clone->SetValueL( value ); |
|
163 } |
|
164 } |
|
165 |
|
166 CleanupStack::Pop( clone ); |
|
167 |
|
168 return clone; |
|
169 |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // ChspsDomAttribute::Name |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 EXPORT_C const TDesC8& ChspsDomAttribute::Name() |
|
177 { |
|
178 return iStringPool.String( iNameRef ); |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // ChspsDomAttribute::NameStringPoolIndex |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C TInt16 ChspsDomAttribute::NameStringPoolIndex()const |
|
186 { |
|
187 return iNameRef; |
|
188 } |
|
189 // ----------------------------------------------------------------------------- |
|
190 // ChspsDomAttribute::Value |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 EXPORT_C const TDesC8& ChspsDomAttribute::Value() |
|
194 { |
|
195 if ( iValueRef > KErrNotFound ) |
|
196 { |
|
197 return iStringPool.String( iValueRef ); |
|
198 } |
|
199 return KNullDesC8; |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // ChspsDomAttribute::ValueStringPoolIndex |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C TInt16 ChspsDomAttribute::ValueStringPoolIndex()const |
|
207 { |
|
208 return iValueRef; |
|
209 } |
|
210 // ----------------------------------------------------------------------------- |
|
211 // ChspsDomAttribute::SetValueL |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 EXPORT_C void ChspsDomAttribute::SetValueL( const TDesC8& aValue ) |
|
215 { |
|
216 iValueRef = iStringPool.AddStringL( aValue ); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // ChspsDomAttribute::SetValueL |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 EXPORT_C void ChspsDomAttribute::SetValueL( const TInt aValue ) |
|
224 { |
|
225 iValueRef = aValue; |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // ChspsDomAttribute::Size |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 TInt ChspsDomAttribute::Size() const |
|
233 { |
|
234 TInt size( 0 ); |
|
235 |
|
236 size += sizeof(TInt16); // iNameRef |
|
237 |
|
238 size += sizeof(TInt16); // iValueRef |
|
239 |
|
240 return size; |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // ChspsDomAttribute::ExternalizeL |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void ChspsDomAttribute::ExternalizeL( RWriteStream& aStream ) const |
|
248 { |
|
249 aStream.WriteInt16L( iNameRef ); |
|
250 aStream.WriteInt16L( iValueRef ); |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // ChspsDomAttribute::InternalizeL |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 void ChspsDomAttribute::InternalizeL( RReadStream& aStream ) |
|
258 { |
|
259 iNameRef = aStream.ReadInt16L(); |
|
260 iValueRef = aStream.ReadInt16L(); |
|
261 } |
|
262 // End of File |