34
|
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 FILES
|
|
21 |
#include "cxmlattributes.h"
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
26 |
|
|
27 |
// -----------------------------------------------------------------------------
|
|
28 |
// CXMLAttributes::CXMLAttributes()
|
|
29 |
// C++ default constructor can NOT contain any code, that
|
|
30 |
// might leave.
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
CXMLAttributes::CXMLAttributes()
|
|
34 |
{
|
|
35 |
}
|
|
36 |
|
|
37 |
// -----------------------------------------------------------------------------
|
|
38 |
// CXMLAttributes::ConstructL
|
|
39 |
// Symbian 2nd phase constructor can leave.
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
void CXMLAttributes::ConstructL()
|
|
43 |
{
|
|
44 |
iDescAttName = new (ELeave) CDesCArraySeg(1);
|
|
45 |
iDescAttValue = new (ELeave) CDesCArraySeg(1);
|
|
46 |
}
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// CXMLAttributes::NewL
|
|
50 |
// Two-phased constructor.
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CXMLAttributes* CXMLAttributes::NewL()
|
|
54 |
{
|
|
55 |
CXMLAttributes* self = new( ELeave ) CXMLAttributes;
|
|
56 |
|
|
57 |
CleanupStack::PushL( self );
|
|
58 |
self->ConstructL();
|
|
59 |
CleanupStack::Pop();
|
|
60 |
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
// CXMLAttributes::~CXMLAttributes()
|
|
67 |
// Destructor.
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CXMLAttributes::~CXMLAttributes()
|
|
71 |
{
|
|
72 |
if(iDescAttName)
|
|
73 |
{
|
|
74 |
delete iDescAttName;
|
|
75 |
}
|
|
76 |
|
|
77 |
if(iDescAttValue)
|
|
78 |
{
|
|
79 |
delete iDescAttValue;
|
|
80 |
}
|
|
81 |
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
// CXMLAttributes::GetIndex
|
|
87 |
// ?implementation_description
|
|
88 |
// (other items were commented in a header).
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
TInt CXMLAttributes::GetIndex(TDesC& aName)
|
|
92 |
{
|
|
93 |
|
|
94 |
TInt wIndex = 0;
|
|
95 |
if(iDescAttName->Find(aName,wIndex) != KErrNone)
|
|
96 |
{
|
|
97 |
return KErrNotFound;
|
|
98 |
}
|
|
99 |
else
|
|
100 |
{
|
|
101 |
return wIndex;
|
|
102 |
}
|
|
103 |
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// CXMLAttributes::GetLength
|
|
108 |
// ?implementation_description
|
|
109 |
// (other items were commented in a header).
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
TInt CXMLAttributes::GetLength()
|
|
113 |
{
|
|
114 |
return iDescAttName->Count();
|
|
115 |
}
|
|
116 |
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
// CXMLAttributes::GetName
|
|
119 |
// ?implementation_description
|
|
120 |
// (other items were commented in a header).
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
TPtrC CXMLAttributes::GetName(TInt aIndex)
|
|
124 |
{
|
|
125 |
if(aIndex > iDescAttName->Count() || aIndex < 0)
|
|
126 |
{
|
|
127 |
TPtrC wEmpty = _L(" ");
|
|
128 |
return wEmpty;
|
|
129 |
}
|
|
130 |
return iDescAttName->MdcaPoint(aIndex);
|
|
131 |
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CXMLAttributes::GetValue
|
|
136 |
// ?implementation_description
|
|
137 |
// (other items were commented in a header).
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
TPtrC CXMLAttributes::GetValue(TDesC& aName)
|
|
141 |
{
|
|
142 |
TInt wPos = GetIndex(aName);
|
|
143 |
|
|
144 |
if (wPos < 0)
|
|
145 |
{
|
|
146 |
TPtrC wEmpty = _L(" ");
|
|
147 |
return wEmpty;
|
|
148 |
}
|
|
149 |
return iDescAttValue->MdcaPoint(wPos);
|
|
150 |
|
|
151 |
}
|
|
152 |
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
// CXMLAttributes::GetValue
|
|
155 |
// ?implementation_description
|
|
156 |
// (other items were commented in a header).
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
TPtrC CXMLAttributes::GetValue(TInt& aIndex)
|
|
160 |
{
|
|
161 |
if(aIndex > iDescAttName->Count() || aIndex < 0)
|
|
162 |
{
|
|
163 |
TPtrC wEmpty = _L(" ");
|
|
164 |
return wEmpty;
|
|
165 |
}
|
|
166 |
return iDescAttValue->MdcaPoint(aIndex);
|
|
167 |
}
|
|
168 |
|
|
169 |
// -----------------------------------------------------------------------------
|
|
170 |
// CXMLAttributes::GetType
|
|
171 |
// ?implementation_description
|
|
172 |
// (other items were commented in a header).
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
/// R&D: Feature: GetType missing from Attributes
|
|
175 |
TPtrC CXMLAttributes::GetType(TInt /*aIndex*/)
|
|
176 |
{
|
|
177 |
TPtrC wType = _L(" ");
|
|
178 |
return(wType);
|
|
179 |
}
|
|
180 |
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
// CXMLAttributes::GetType
|
|
183 |
// ?implementation_description
|
|
184 |
// (other items were commented in a header).
|
|
185 |
// -----------------------------------------------------------------------------
|
|
186 |
// R&D: Feature: GetType missing from Attributes
|
|
187 |
TPtrC CXMLAttributes::GetType(TDesC& /*aName*/)
|
|
188 |
{
|
|
189 |
TPtrC wType = _L(" ");
|
|
190 |
return wType;
|
|
191 |
}
|
|
192 |
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
// CXMLAttributes::Append
|
|
195 |
// ?implementation_description
|
|
196 |
// (other items were commented in a header).
|
|
197 |
// -----------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
void CXMLAttributes::AppendL(const TDesC& aName, const TDesC& aValue)
|
|
200 |
{
|
|
201 |
if ( iDescAttName && iDescAttValue )
|
|
202 |
{
|
|
203 |
iDescAttName->AppendL(aName);
|
|
204 |
iDescAttValue->AppendL(aValue);
|
|
205 |
}
|
|
206 |
}
|
|
207 |
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
// CXMLAttributes::Reset()
|
|
210 |
// Resets attribute Name and Value arrays
|
|
211 |
// (other items were commented in a header).
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CXMLAttributes::Reset()
|
|
215 |
{
|
|
216 |
iDescAttName->Reset();
|
|
217 |
iDescAttValue->Reset();
|
|
218 |
}
|
|
219 |
|
|
220 |
// End of File
|