bluetooth/btsdp/database/SDPAttribute.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "SDPAttribute.h"
       
    17 #include "MAttributeVisitor.h"
       
    18 #include "attrvalueencoded.h"
       
    19 
       
    20 // Class CServArrr
       
    21 
       
    22 
       
    23 // ******************* CSdpAttrValue ********************************
       
    24 
       
    25 EXPORT_C CSdpAttr *CSdpAttr::NewL(TUint16 aAttrID,MSdpElementBuilder *aParent)
       
    26 	{
       
    27 	CSdpAttr *attr=new (ELeave) CSdpAttr(aAttrID,aParent);
       
    28 	CleanupStack::PushL(attr);
       
    29 	attr->ConstructL();
       
    30 	CleanupStack::Pop();
       
    31 	return attr;
       
    32 	}
       
    33 
       
    34 void CSdpAttr::ConstructL()
       
    35 	{
       
    36 	}
       
    37 
       
    38 CSdpAttr::CSdpAttr(TUint16 aAttrID,MSdpElementBuilder *aParent)
       
    39 	: iParent(aParent),
       
    40 	iAttrID(aAttrID)
       
    41 	{
       
    42 	}
       
    43 
       
    44 CSdpAttr::~CSdpAttr()
       
    45 	{
       
    46 	delete iAttrValue;
       
    47 	iLink.Deque();
       
    48 	}
       
    49 
       
    50 EXPORT_C void CSdpAttr::AcceptVisitorL(MAttributeVisitor& aVisitor)
       
    51 	{
       
    52 	aVisitor.VisitAttributeL(*this);
       
    53 	if (iAttrValue)
       
    54 		{
       
    55 		iAttrValue->AcceptVisitorL(aVisitor);		
       
    56 		}
       
    57 	//else //do nothing
       
    58 	}
       
    59 
       
    60 
       
    61 void CSdpAttr::Reset()
       
    62 	{
       
    63 	delete iAttrValue;
       
    64 	iAttrValue = 0;
       
    65 	}
       
    66 
       
    67 /*
       
    68 EXPORT_C CSdpAttrValue& CSdpAttr::Value()
       
    69 	{
       
    70 	__ASSERT_DEBUG(iAttrValue, DbPanic(ESdpNoAttrValue));
       
    71 	return *iAttrValue;
       
    72 	}
       
    73 */
       
    74 
       
    75 // FIXME: Need to delete and reset iAttrValue on all the following....
       
    76 
       
    77 MSdpElementBuilder *CSdpAttr::BuildNilL()
       
    78 	{
       
    79 	Reset();
       
    80 	iAttrValue=CSdpAttrValueNil::NewNilL();
       
    81 	return iParent;
       
    82 	}
       
    83 
       
    84 MSdpElementBuilder *CSdpAttr::BuildUintL(const TDesC8& aUint)
       
    85 	{
       
    86 	Reset();
       
    87 	iAttrValue=CSdpAttrValueUint::NewUintL(aUint);
       
    88 	return iParent;
       
    89 	}
       
    90 
       
    91 MSdpElementBuilder *CSdpAttr::BuildIntL(const TDesC8& aInt)
       
    92 	{
       
    93 	Reset();
       
    94 	iAttrValue=CSdpAttrValueInt::NewIntL(aInt);
       
    95 	return iParent;
       
    96 	}
       
    97 
       
    98 MSdpElementBuilder *CSdpAttr::BuildUUIDL(const TUUID& aUUID)
       
    99 	{
       
   100 	Reset();
       
   101 	iAttrValue=CSdpAttrValueUUID::NewUUIDL(aUUID);
       
   102 	return iParent;
       
   103 	}
       
   104 
       
   105 MSdpElementBuilder *CSdpAttr::BuildStringL(const TDesC8& aString)
       
   106 	{
       
   107 	Reset();
       
   108 	iAttrValue=CSdpAttrValueString::NewStringL(aString);
       
   109 	return iParent;
       
   110 	}
       
   111 
       
   112 MSdpElementBuilder *CSdpAttr::BuildBooleanL(TBool aBool)
       
   113 	{
       
   114 	Reset();
       
   115 	iAttrValue=CSdpAttrValueBoolean::NewBoolL(aBool);
       
   116 	return iParent;
       
   117 	}
       
   118 
       
   119 MSdpElementBuilder* CSdpAttr::BuildDESL()
       
   120 /**
       
   121 	CSdpAttr Build DES.
       
   122 	This function creates a new CSdpAttrValue of type DES and returns 
       
   123 	a pointer to it as the new parent MSdpElementBuilder
       
   124 **/
       
   125 	{
       
   126 	Reset();
       
   127 	CSdpAttrValueList *list=CSdpAttrValueDES::NewDESL(iParent);
       
   128 	iAttrValue=list;
       
   129 	return list;
       
   130 	}
       
   131 
       
   132 MSdpElementBuilder* CSdpAttr::BuildDEAL()
       
   133 /**
       
   134 	CSdpAttr Build DEA.
       
   135 	This function creates a new CSdpAttrValue of type DEA and returns 
       
   136 	a pointer to it as the new parent MSdpElementBuilder
       
   137 **/
       
   138 	{
       
   139 	Reset(); //FIXME .. added because I do not understand why it was not here!
       
   140 	CSdpAttrValueList *list=CSdpAttrValueDEA::NewDEAL(iParent);
       
   141 	iAttrValue=list;
       
   142 	return list;
       
   143 	}
       
   144 
       
   145 MSdpElementBuilder *CSdpAttr::BuildURLL(const TDesC8& aURL)
       
   146 	{
       
   147 	Reset(); //FIXME .. added because I do not understand why it was not here!
       
   148 	iAttrValue=CSdpAttrValueURL::NewURLL(aURL);
       
   149 	return iParent;
       
   150 	}
       
   151 
       
   152 MSdpElementBuilder *CSdpAttr::BuildEncodedL(const TDesC8& aString)
       
   153 	{
       
   154 	Reset();
       
   155 	iAttrValue=CSdpAttrValueEncoded::NewEncodedL(aString);
       
   156 	return iParent;
       
   157 	}