bluetooth/btsdp/database/SDPAttribute.h
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 
       
    17 #ifndef SDPATTRIBUTE_H
       
    18 #define SDPATTRIBUTE_H
       
    19 
       
    20 #include <btsdp.h>
       
    21 #include "sdputil.h"
       
    22 
       
    23 class MAttributeVisitor;
       
    24 
       
    25 class CSdpAttr;
       
    26 
       
    27 typedef TOrderedQue<CSdpAttr> TServAttrList;
       
    28 typedef TDblQueIter<CSdpAttr> TServAttrIter;
       
    29 
       
    30 /**
       
    31 	SDP Service Attribute.
       
    32 	Contains the Attribute ID and value pair.
       
    33 **/
       
    34 NONSHARABLE_CLASS(CSdpAttr) : public CBase, public MSdpElementBuilder
       
    35 	{
       
    36 public:
       
    37 	IMPORT_C static CSdpAttr* NewL(TUint16 aAttrID,MSdpElementBuilder* aParent);
       
    38 	~CSdpAttr();
       
    39 	inline TSdpAttributeID AttributeID() const;
       
    40 	inline const CSdpAttrValue& Value() const;
       
    41 	inline CSdpAttrValue& Value();
       
    42 	inline CSdpAttrValue* ReleaseValue();
       
    43 	inline TBool operator>(const CSdpAttr& aAttr) const;
       
    44 	inline static TInt LinkOffset();
       
    45 
       
    46 	IMPORT_C void AcceptVisitorL(MAttributeVisitor& aVisitor);
       
    47 
       
    48 	// MSdpElementBuilder interface
       
    49 	virtual MSdpElementBuilder* BuildNilL();
       
    50 	virtual MSdpElementBuilder* BuildUintL(const TDesC8& aUint);
       
    51 	virtual MSdpElementBuilder* BuildIntL(const TDesC8& aInt);
       
    52 	virtual MSdpElementBuilder* BuildUUIDL(const TUUID& aUUID);
       
    53 	virtual MSdpElementBuilder* BuildBooleanL(TBool aBool);
       
    54 	virtual MSdpElementBuilder* BuildStringL(const TDesC8& aString);
       
    55 	virtual MSdpElementBuilder* BuildDESL();
       
    56 	virtual MSdpElementBuilder* BuildDEAL();
       
    57 	virtual MSdpElementBuilder* BuildURLL(const TDesC8& aString);
       
    58 	virtual MSdpElementBuilder* BuildEncodedL(const TDesC8& aString);
       
    59 private:
       
    60 	CSdpAttr(TUint16 aAttrID,MSdpElementBuilder* aParent);
       
    61 	void ConstructL();
       
    62 	void Reset();
       
    63 
       
    64 private:
       
    65 	MSdpElementBuilder* iParent;
       
    66 	CSdpAttrValue* iAttrValue;
       
    67     TSdpAttributeID iAttrID;
       
    68 	TDblQueLink iLink;
       
    69 	};
       
    70 
       
    71 inline TSdpAttributeID CSdpAttr::AttributeID() const
       
    72 	{
       
    73 	return iAttrID;
       
    74 	}
       
    75 
       
    76 inline const CSdpAttrValue& CSdpAttr::Value() const
       
    77 	{
       
    78 	return const_cast<CSdpAttr*>(this)->Value();
       
    79 	}
       
    80 
       
    81 
       
    82 inline CSdpAttrValue& CSdpAttr::Value()
       
    83 	{
       
    84 	__ASSERT_DEBUG(iAttrValue, User::Panic(_L("Sdp Database"), ESdpNoAttrValue));
       
    85 	return *iAttrValue;
       
    86 	}
       
    87 
       
    88 inline CSdpAttrValue* CSdpAttr::ReleaseValue()
       
    89 	{
       
    90 	CSdpAttrValue* p = iAttrValue;
       
    91 	iAttrValue = 0;
       
    92 	return p;
       
    93 	}
       
    94 
       
    95 inline TBool CSdpAttr::operator>(const CSdpAttr& aAttr) const
       
    96 	{
       
    97 	return iAttrID > aAttr.iAttrID;
       
    98 	}
       
    99 
       
   100 inline TInt CSdpAttr::LinkOffset()
       
   101 	{
       
   102 	return _FOFF(CSdpAttr, iLink);
       
   103 	}
       
   104 
       
   105 #endif