realtimenetprots/sipfw/SDP/inc/SdpCodecTemplate.inl
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003-2009 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:
       
    15 * Name          : SdpCodecTemplate.inl
       
    16 * Part of       : SDP Codec
       
    17 * Interface     : -
       
    18 * Version       : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #ifndef SDPCODECTEMPLATE_INL
       
    25 #define SDPCODECTEMPLATE_INL
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <stringpool.h>
       
    30 
       
    31 #include "_sdpdefs.h"
       
    32 #include "e32std.h"
       
    33 
       
    34 class RReadStream;
       
    35 class RWriteStream;
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // SdpCodecTemplate<T>::ExternalizeL 
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 template<class T> void SdpCodecTemplate<T>::ExternalizeL(const T* aElement,
       
    42 										RWriteStream& aWriteStream)
       
    43 	{
       
    44 	if(aElement)
       
    45 		{
       
    46 		aWriteStream.WriteUint8L (1);
       
    47 		aElement->ExternalizeL(aWriteStream);
       
    48 		}
       
    49 	else
       
    50 		{
       
    51 		aWriteStream.WriteUint8L (0);
       
    52 		}
       
    53 	}
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // SdpCodecTemplate<T>::ExternalizeArrayL
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 template<class T> void 
       
    60 SdpCodecTemplate<T>::ExternalizeArrayL(RPointerArray<T> aArray,
       
    61 						   RWriteStream& aStream)
       
    62 	{
       
    63 	aStream.WriteUint32L (aArray.Count());
       
    64 	for (TInt i = 0;i < aArray.Count();i++)
       
    65 		{
       
    66 		aArray[i]->ExternalizeL(aStream);
       
    67 		}
       
    68 	}
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // SdpCodecTemplate<T>::EncodeArrayL
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 template<class T> void 
       
    75 SdpCodecTemplate<T>::EncodeArrayL(RPointerArray<T> aArray, RWriteStream& aStream)
       
    76 	{
       
    77 	for (TInt i = 0;i < aArray.Count();i++)
       
    78 		{
       
    79 		aArray[i]->EncodeL(aStream);
       
    80 		}
       
    81 	}
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // SdpCodecTemplate<T>::EncodeL
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 template<class T> void SdpCodecTemplate<T>::EncodeL(const T* aElement,
       
    88 										RWriteStream& aWriteStream)
       
    89 	{
       
    90 	if(aElement)
       
    91 		{
       
    92 		aElement->EncodeL(aWriteStream);
       
    93 		}
       
    94 	}
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // SdpCodecTemplate<T>::InternalizeArrayL
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 template<class T> void 
       
   101 SdpCodecTemplate<T>::InternalizeArrayL(RPointerArray<T>& aArray, 
       
   102 								RReadStream& aStream)
       
   103 	{
       
   104 	TInt count = aStream.ReadUint32L();
       
   105 	for (TInt i = 0;i < count;i++)
       
   106 		{
       
   107 		T* obj = T::InternalizeL(aStream);
       
   108 		CleanupStack::PushL(obj);
       
   109 		User::LeaveIfError(aArray.Append(obj));
       
   110 		CleanupStack::Pop();//obj
       
   111 		}
       
   112 	}
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // SdpCodecTemplate<T>::CloneArrayL
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 template<class T> void 
       
   119 SdpCodecTemplate<T>::CloneArrayL(RPointerArray<T>& aArray,
       
   120 						  RPointerArray<T> aSourceArray)
       
   121 	{
       
   122 	for (TInt i=0; i < (aSourceArray).Count(); i++)
       
   123 		{
       
   124 		T* obj = aSourceArray[i]->CloneL();
       
   125 		CleanupStack::PushL(obj);
       
   126 		User::LeaveIfError(aArray.Append(obj));
       
   127 		CleanupStack::Pop();//obj
       
   128 		}
       
   129 	}
       
   130 
       
   131 
       
   132 #endif