metadataengine/client/src/mderange.cpp
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Serialization for mderange template class
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mderange.h"
       
    19 #include "mdcserializationbuffer.h"
       
    20 
       
    21 
       
    22 void TMdESerializeRange::SerializeL( CMdCSerializationBuffer& aBuffer, TMdERangeType aType,
       
    23 		void* aMin, void* aMax, TInt aValueSize )
       
    24 	{
       
    25 #ifdef _DEBUG
       
    26 	if ( aValueSize > sizeof(TMdCValueUnion) )
       
    27 		{
       
    28 		__ASSERT_DEBUG( EFalse, User::Panic( _L("Incorrect type"), KErrMdEIncorrectType ) );
       
    29 		User::Leave( KErrMdEIncorrectType );
       
    30 		}
       
    31 #endif
       
    32 
       
    33 	aBuffer.InsertL( (TInt32)aType );
       
    34 
       
    35 	TMdCValueUnion min;
       
    36 	Mem::Copy( &min, aMin, aValueSize );
       
    37 	TMdCValueUnion max;
       
    38 	Mem::Copy( &max, aMax, aValueSize );
       
    39 
       
    40 	aBuffer.InsertL( min );
       
    41 	aBuffer.InsertL( max );
       
    42 	}
       
    43 
       
    44 TUint32 TMdESerializeRange::RequiredBufferSize( TInt 
       
    45 #ifdef _DEBUG		
       
    46 		aValueSize
       
    47 #endif
       
    48 		)
       
    49 	{
       
    50 #ifdef _DEBUG
       
    51 	if ( aValueSize > sizeof(TMdCValueUnion) )
       
    52 		{
       
    53 		User::Panic( _L("Incorrect type"), KErrMdEIncorrectType );
       
    54 		}
       
    55 #endif
       
    56 	
       
    57 	// Required size for type (TInt32), iMin and iMax (fixed size)
       
    58 	TUint32 bufferSize = CMdCSerializationBuffer::KRequiredSizeForTInt32
       
    59 			+ 2 * CMdCSerializationBuffer::KRequiredSizeForTMdCValueUnion;
       
    60 
       
    61 	return bufferSize;
       
    62 	}