syncmlfw/common/wbxml/src/WBXMLAttributes.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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 "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:  WBXML attribute classes implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // ------------------------------------------------------------------------------------------------
       
    20 // Includes
       
    21 // ------------------------------------------------------------------------------------------------
       
    22 #include "WBXMLAttributes.h"
       
    23 
       
    24 // ------------------------------------------------------------------------------------------------
       
    25 // CWBXMLAttribute
       
    26 // ------------------------------------------------------------------------------------------------
       
    27 CWBXMLAttribute* CWBXMLAttribute::NewL( TWBXMLTag aName, const TDesC8& aValue )
       
    28 	{
       
    29 	CWBXMLAttribute* self = new (ELeave) CWBXMLAttribute();
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL(aName, aValue);
       
    32 	CleanupStack::Pop(); // self
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 // ------------------------------------------------------------------------------------------------
       
    37 CWBXMLAttribute::~CWBXMLAttribute()
       
    38 	{
       
    39 	delete iValue;
       
    40 	}
       
    41 
       
    42 // ------------------------------------------------------------------------------------------------
       
    43 void CWBXMLAttribute::ConstructL( TWBXMLTag aName, const TDesC8& aValue )
       
    44 	{
       
    45 	iName = aName;
       
    46 	iValue = aValue.AllocL();
       
    47 	}
       
    48 
       
    49 // ------------------------------------------------------------------------------------------------
       
    50 EXPORT_C TWBXMLTag CWBXMLAttribute::Name() const
       
    51 	{
       
    52 	return iName;
       
    53 	}
       
    54 
       
    55 // ------------------------------------------------------------------------------------------------
       
    56 EXPORT_C TPtrC8 CWBXMLAttribute::Value() const
       
    57 	{
       
    58 	return *iValue;
       
    59 	}
       
    60 
       
    61 // ------------------------------------------------------------------------------------------------
       
    62 // CWBXMLAttributes
       
    63 // ------------------------------------------------------------------------------------------------
       
    64 EXPORT_C CWBXMLAttributes* CWBXMLAttributes::NewL()
       
    65 	{
       
    66 	CWBXMLAttributes* self = NewLC();
       
    67 	CleanupStack::Pop();
       
    68 	return self;
       
    69 	}
       
    70 
       
    71 // ------------------------------------------------------------------------------------------------
       
    72 EXPORT_C CWBXMLAttributes* CWBXMLAttributes::NewLC()
       
    73 	{
       
    74 	CWBXMLAttributes* self = new (ELeave) CWBXMLAttributes();
       
    75 	CleanupStack::PushL(self);
       
    76 	self->ConstructL();
       
    77 	return self;
       
    78 	}
       
    79 
       
    80 // ------------------------------------------------------------------------------------------------
       
    81 CWBXMLAttributes::~CWBXMLAttributes()
       
    82 	{
       
    83 	if ( iAttributeList )
       
    84 		{
       
    85 		iAttributeList->ResetAndDestroy();
       
    86 		delete iAttributeList;
       
    87 		}
       
    88 	}
       
    89 
       
    90 // ------------------------------------------------------------------------------------------------
       
    91 void CWBXMLAttributes::ConstructL()
       
    92 	{
       
    93 	iAttributeList = new (ELeave) CArrayPtrFlat<CWBXMLAttribute>(2);
       
    94 	}
       
    95 
       
    96 // ------------------------------------------------------------------------------------------------
       
    97 EXPORT_C TInt CWBXMLAttributes::Count() const
       
    98 	{
       
    99 	return iAttributeList->Count();
       
   100 	}
       
   101 
       
   102 // ------------------------------------------------------------------------------------------------
       
   103 EXPORT_C const CWBXMLAttribute& CWBXMLAttributes::Attribute( TInt aIndex ) const
       
   104 	{
       
   105 	return *(iAttributeList->operator[](aIndex));
       
   106 	}
       
   107 
       
   108 // ------------------------------------------------------------------------------------------------
       
   109 EXPORT_C void CWBXMLAttributes::AddAttributeL( TWBXMLTag aName, const TDesC8& aValue )
       
   110 	{
       
   111 	CWBXMLAttribute* attr = CWBXMLAttribute::NewL(aName, aValue);
       
   112 	iAttributeList->AppendL(attr);
       
   113 	}