35
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: XDM Engine node attribute
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include <escapeutils.h>
|
|
23 |
|
|
24 |
#include "XdmEngine.h"
|
|
25 |
#include "XdmNodeFactory.h"
|
|
26 |
#include "XdmNodeAttribute.h"
|
|
27 |
|
|
28 |
// ----------------------------------------------------------
|
|
29 |
// CXdmNodeAttribute::CXdmNodeAttribute
|
|
30 |
//
|
|
31 |
// ----------------------------------------------------------
|
|
32 |
//
|
|
33 |
EXPORT_C CXdmNodeAttribute::CXdmNodeAttribute( CXdmEngine& aXdmEngine,
|
|
34 |
MXdmNodeFactory& aNodeFactory ) :
|
|
35 |
CXdmDocumentNode( aXdmEngine, aNodeFactory )
|
|
36 |
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
// ----------------------------------------------------------
|
|
41 |
// CXdmNodeAttribute::CXdmNodeAttribute
|
|
42 |
//
|
|
43 |
// ----------------------------------------------------------
|
|
44 |
//
|
|
45 |
EXPORT_C CXdmNodeAttribute::CXdmNodeAttribute( CXdmEngine& aXdmEngine,
|
|
46 |
MXdmNodeFactory& aNodeFactory,
|
|
47 |
CXdmDocumentNode* aParentNode ) :
|
|
48 |
CXdmDocumentNode( aXdmEngine, aNodeFactory, aParentNode )
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
// ----------------------------------------------------------
|
|
53 |
// CXdmNodeAttribute::ConstructL
|
|
54 |
//
|
|
55 |
// ----------------------------------------------------------
|
|
56 |
//
|
|
57 |
EXPORT_C void CXdmNodeAttribute::BaseConstructL( const TDesC& aAttributeName )
|
|
58 |
{
|
|
59 |
SetNameL( aAttributeName );
|
|
60 |
}
|
|
61 |
|
|
62 |
// ----------------------------------------------------------
|
|
63 |
// CXdmNodeAttribute::ElementType
|
|
64 |
//
|
|
65 |
// ----------------------------------------------------------
|
|
66 |
//
|
|
67 |
EXPORT_C TXdmElementType CXdmNodeAttribute::ElementType() const
|
|
68 |
{
|
|
69 |
return EXdmElementAttribute;
|
|
70 |
}
|
|
71 |
|
|
72 |
// ----------------------------------------------------
|
|
73 |
// CXdmNodeAttribute::~CXdmNodeAttribute
|
|
74 |
//
|
|
75 |
// ----------------------------------------------------
|
|
76 |
//
|
|
77 |
EXPORT_C CXdmNodeAttribute::~CXdmNodeAttribute()
|
|
78 |
{
|
|
79 |
#ifdef _DEBUG
|
|
80 |
iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::~CXdmNodeAttribute()" ) );
|
|
81 |
#endif
|
|
82 |
delete iAttributeValue;
|
|
83 |
}
|
|
84 |
|
|
85 |
// ----------------------------------------------------
|
|
86 |
// CXdmNodeAttribute::AttributeValue
|
|
87 |
//
|
|
88 |
// ----------------------------------------------------
|
|
89 |
//
|
|
90 |
EXPORT_C TPtrC CXdmNodeAttribute::AttributeValue() const
|
|
91 |
{
|
|
92 |
return iAttributeValue != NULL ? iAttributeValue->Des() : TPtrC();
|
|
93 |
}
|
|
94 |
|
|
95 |
// ----------------------------------------------------
|
|
96 |
// CXdmNodeAttribute::AttributeValue
|
|
97 |
//
|
|
98 |
// ----------------------------------------------------
|
|
99 |
//
|
|
100 |
EXPORT_C HBufC8* CXdmNodeAttribute::EightBitValueLC() const
|
|
101 |
{
|
|
102 |
HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iAttributeValue->Des() );
|
|
103 |
CleanupStack::PushL( eightBit );
|
|
104 |
return eightBit;
|
|
105 |
}
|
|
106 |
|
|
107 |
// ----------------------------------------------------
|
|
108 |
// CXdmNodeAttribute::EscapedValueLC
|
|
109 |
//
|
|
110 |
// ----------------------------------------------------
|
|
111 |
//
|
|
112 |
EXPORT_C HBufC8* CXdmNodeAttribute::EscapedValueLC() const
|
|
113 |
{
|
|
114 |
HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iAttributeValue->Des() );
|
|
115 |
CleanupStack::PushL( eightBit );
|
|
116 |
HBufC8* escape = EscapeDescLC( eightBit->Des() );
|
|
117 |
CleanupStack::Pop(); //escape
|
|
118 |
CleanupStack::PopAndDestroy(); //eightBit
|
|
119 |
CleanupStack::PushL( escape );
|
|
120 |
return escape;
|
|
121 |
}
|
|
122 |
|
|
123 |
// ----------------------------------------------------
|
|
124 |
// CXdmNodeAttribute::SetAttributeValue
|
|
125 |
//
|
|
126 |
// ----------------------------------------------------
|
|
127 |
//
|
|
128 |
EXPORT_C void CXdmNodeAttribute::SetAttributeValueL( const TDesC& aAttributeValue )
|
|
129 |
{
|
|
130 |
#ifdef _DEBUG
|
|
131 |
iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::SetAttributeValueL() - Value: %S" ),
|
|
132 |
&aAttributeValue );
|
|
133 |
#endif
|
|
134 |
delete iAttributeValue;
|
|
135 |
iAttributeValue = NULL;
|
|
136 |
iAttributeValue = HBufC::NewL( aAttributeValue.Length() );
|
|
137 |
iAttributeValue->Des().Copy( aAttributeValue );
|
|
138 |
}
|
|
139 |
|
|
140 |
// ----------------------------------------------------
|
|
141 |
// CXdmNodeAttribute::SetAttributeValue
|
|
142 |
//
|
|
143 |
// ----------------------------------------------------
|
|
144 |
//
|
|
145 |
EXPORT_C void CXdmNodeAttribute::SetAttributeValueL( const TDesC8& aAttributeValue )
|
|
146 |
{
|
|
147 |
// change to UNICODE from UTF8 format
|
|
148 |
HBufC* unicode = EscapeUtils::ConvertToUnicodeFromUtf8L( aAttributeValue );
|
|
149 |
CleanupStack::PushL( unicode );
|
|
150 |
|
|
151 |
#ifdef _DEBUG
|
|
152 |
iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::SetAttributeValueL() - Value: %S" ),
|
|
153 |
unicode );
|
|
154 |
#endif
|
|
155 |
delete iAttributeValue;
|
|
156 |
iAttributeValue = NULL;
|
|
157 |
iAttributeValue = HBufC::NewL( unicode->Length() );
|
|
158 |
iAttributeValue->Des().Copy( *unicode );
|
|
159 |
CleanupStack::PopAndDestroy( unicode );
|
|
160 |
}
|
|
161 |
|
|
162 |
|