|
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 // ----------------------------------------------------------------------------- |
|
40 // ChspsDomAttribute::ConstructL |
|
41 // Symbian 2nd phase constructor can leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void ChspsDomAttribute::ConstructL( const TDesC8& aName ) |
|
45 { |
|
46 iNameRef = iStringPool.AddStringL( aName ); |
|
47 } |
|
48 // ----------------------------------------------------------------------------- |
|
49 // ChspsDomAttribute::NewL |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C ChspsDomAttribute* ChspsDomAttribute::NewL( |
|
54 const TDesC8& aName, |
|
55 ChspsDomStringPool& aStringPool ) |
|
56 { |
|
57 ChspsDomAttribute* self = new( ELeave ) ChspsDomAttribute( aStringPool ); |
|
58 |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL( aName ); |
|
61 CleanupStack::Pop( self ); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // ChspsDomAttribute::NewL |
|
69 // Two-phased stream constructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 ChspsDomAttribute* ChspsDomAttribute::NewL( |
|
73 RReadStream& aStream, |
|
74 ChspsDomStringPool& aStringPool ) |
|
75 { |
|
76 ChspsDomAttribute* self = new( ELeave ) ChspsDomAttribute( aStringPool ); |
|
77 CleanupStack::PushL( self ); |
|
78 aStream >> *self; |
|
79 CleanupStack::Pop( self ); |
|
80 |
|
81 return self; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // ChspsDomAttribute::~ChspsDomAttribute |
|
86 // Destructor |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 EXPORT_C ChspsDomAttribute::~ChspsDomAttribute() |
|
90 { |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // ChspsDomAttribute::CloneL |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C ChspsDomAttribute* ChspsDomAttribute::CloneL() |
|
98 { |
|
99 ChspsDomAttribute* clone = new (ELeave)ChspsDomAttribute( iStringPool ); |
|
100 clone->iNameRef = iNameRef; |
|
101 clone->iValueRef = iValueRef; |
|
102 return clone; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // ChspsDomAttribute::CloneL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 ChspsDomAttribute* ChspsDomAttribute::CloneL( ChspsDomStringPool& aStringPool ) |
|
110 { |
|
111 const TDesC8& name = iStringPool.String( iNameRef ); |
|
112 |
|
113 ChspsDomAttribute* clone = ChspsDomAttribute::NewL( name, aStringPool ); |
|
114 CleanupStack::PushL( clone ); |
|
115 if ( iValueRef > KErrNotFound ) |
|
116 { |
|
117 const TDesC8& value = iStringPool.String( iValueRef ); |
|
118 clone->SetValueL( value ); |
|
119 } |
|
120 CleanupStack::Pop( clone ); |
|
121 return clone; |
|
122 |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // ChspsDomAttribute::Name |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C const TDesC8& ChspsDomAttribute::Name() |
|
130 { |
|
131 return iStringPool.String( iNameRef ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // ChspsDomAttribute::NameStringPoolIndex |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C TInt16 ChspsDomAttribute::NameStringPoolIndex()const |
|
139 { |
|
140 return iNameRef; |
|
141 } |
|
142 // ----------------------------------------------------------------------------- |
|
143 // ChspsDomAttribute::Value |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C const TDesC8& ChspsDomAttribute::Value() |
|
147 { |
|
148 if ( iValueRef > KErrNotFound ) |
|
149 { |
|
150 return iStringPool.String( iValueRef ); |
|
151 } |
|
152 return KNullDesC8; |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // ChspsDomAttribute::ValueStringPoolIndex |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 EXPORT_C TInt16 ChspsDomAttribute::ValueStringPoolIndex()const |
|
160 { |
|
161 return iValueRef; |
|
162 } |
|
163 // ----------------------------------------------------------------------------- |
|
164 // ChspsDomAttribute::SetValueL |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C void ChspsDomAttribute::SetValueL( const TDesC8& aValue ) |
|
168 { |
|
169 iValueRef = iStringPool.AddStringL( aValue ); |
|
170 } |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // ChspsDomAttribute::Size |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt ChspsDomAttribute::Size() const |
|
178 { |
|
179 TInt size( 0 ); |
|
180 |
|
181 size += sizeof(TInt16); // iNameRef |
|
182 |
|
183 size += sizeof(TInt16); // iValueRef |
|
184 |
|
185 return size; |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // ChspsDomAttribute::ExternalizeL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void ChspsDomAttribute::ExternalizeL( RWriteStream& aStream ) const |
|
193 { |
|
194 aStream.WriteInt16L( iNameRef ); |
|
195 aStream.WriteInt16L( iValueRef ); |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // ChspsDomAttribute::InternalizeL |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void ChspsDomAttribute::InternalizeL( RReadStream& aStream ) |
|
203 { |
|
204 iNameRef = aStream.ReadInt16L(); |
|
205 iValueRef = aStream.ReadInt16L(); |
|
206 } |
|
207 // End of File |