XDMEngine/src/XdmNodeAttribute.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 01:05:17 +0200
changeset 0 c8caa15ef882
child 14 de84881f4ac3
permissions -rw-r--r--
Revision: 201003 Kit: 201005

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:   XDM Engine node attribute
*
*/




// INCLUDE FILES
#include "XdmEngine.h"
#include "XdmNodeFactory.h"
#include "XdmNodeAttribute.h"

// ----------------------------------------------------------
// CXdmNodeAttribute::CXdmNodeAttribute
// 
// ----------------------------------------------------------
//
EXPORT_C CXdmNodeAttribute::CXdmNodeAttribute( CXdmEngine& aXdmEngine,
                                               MXdmNodeFactory& aNodeFactory ) :
                                               CXdmDocumentNode( aXdmEngine, aNodeFactory )
                                                
    {    
    }
    
// ----------------------------------------------------------
// CXdmNodeAttribute::CXdmNodeAttribute
// 
// ----------------------------------------------------------
//
EXPORT_C CXdmNodeAttribute::CXdmNodeAttribute( CXdmEngine& aXdmEngine,
                                               MXdmNodeFactory& aNodeFactory,
                                               CXdmDocumentNode* aParentNode ) :
                                               CXdmDocumentNode( aXdmEngine, aNodeFactory, aParentNode )                                          
    {  
    }
       
// ----------------------------------------------------------
// CXdmNodeAttribute::ConstructL
// 
// ----------------------------------------------------------
//
EXPORT_C void CXdmNodeAttribute::BaseConstructL( const TDesC& aAttributeName )
    {
    SetNameL( aAttributeName );
    }

// ----------------------------------------------------------
// CXdmNodeAttribute::ElementType
// 
// ----------------------------------------------------------
//
EXPORT_C TXdmElementType CXdmNodeAttribute::ElementType() const
    {
    return EXdmElementAttribute;
    }

// ----------------------------------------------------
// CXdmNodeAttribute::~CXdmNodeAttribute
// 
// ----------------------------------------------------
//
EXPORT_C CXdmNodeAttribute::~CXdmNodeAttribute()
    {
    #ifdef _DEBUG
        iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::~CXdmNodeAttribute()" ) );
    #endif
    delete iAttributeValue;
    }

// ----------------------------------------------------
// CXdmNodeAttribute::AttributeValue
// 
// ----------------------------------------------------
//
EXPORT_C TPtrC CXdmNodeAttribute::AttributeValue() const
    {
    return iAttributeValue != NULL ? iAttributeValue->Des() : TPtrC();
    }

// ----------------------------------------------------
// CXdmNodeAttribute::AttributeValue
// 
// ----------------------------------------------------
//
EXPORT_C HBufC8* CXdmNodeAttribute::EightBitValueLC() const
    {
    HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iAttributeValue->Des() );
    CleanupStack::PushL( eightBit );
    return eightBit;
    }

// ----------------------------------------------------
// CXdmNodeAttribute::EscapedValueLC
// 
// ----------------------------------------------------
//
EXPORT_C HBufC8* CXdmNodeAttribute::EscapedValueLC() const
    {
    HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iAttributeValue->Des() );
    CleanupStack::PushL( eightBit );
    HBufC8* escape = EscapeDescLC( eightBit->Des() );
    CleanupStack::Pop();  //escape
    CleanupStack::PopAndDestroy();  //eightBit
    CleanupStack::PushL( escape );
    return escape;
    }
    
// ----------------------------------------------------
// CXdmNodeAttribute::SetAttributeValue
// 
// ----------------------------------------------------
//
EXPORT_C void CXdmNodeAttribute::SetAttributeValueL( const TDesC& aAttributeValue )
    {
    #ifdef _DEBUG
        iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::SetAttributeValueL() - Value: %S" ),
                                &aAttributeValue );
    #endif
    delete iAttributeValue;
    iAttributeValue = NULL;
    iAttributeValue = HBufC::NewL( aAttributeValue.Length() );
    iAttributeValue->Des().Copy( aAttributeValue );
    }

// ----------------------------------------------------
// CXdmNodeAttribute::SetAttributeValue
// 
// ----------------------------------------------------
//
EXPORT_C void CXdmNodeAttribute::SetAttributeValueL( const TDesC8& aAttributeValue )
    {
    #ifdef _DEBUG
        iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::SetAttributeValueL() - Value: %S" ),
                                &aAttributeValue );
    #endif
    delete iAttributeValue;
    iAttributeValue = NULL;
    iAttributeValue = HBufC::NewL( aAttributeValue.Length() );
    iAttributeValue->Des().Copy( aAttributeValue );
    }