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