diff -r f18401adf8e1 -r 641f389e9157 authenticationservices/authenticationserver/source/common/arrayutils.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/authenticationservices/authenticationserver/source/common/arrayutils.inl Tue Aug 31 17:00:08 2010 +0300 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Utility functions for copying and streaming RArrays. +* RPointerArray utilities +* +*/ + +template +void ExternalizePointerArrayL(const RPointerArray& aArray, RWriteStream& aStream) + { + aStream.WriteInt32L(aArray.Count()); + for (TInt i = 0; i < aArray.Count(); ++i) + { + TTraits::WriteToStreamL(*aArray[i], aStream); + } + } + +template +void InternalizePointerArrayL(RPointerArray& aArray, RReadStream& aStream) + { + TInt count = aStream.ReadInt32L(); + for (TInt i = 0; i < count; ++i) + { + T* item = TTraits::ReadFromStreamLC(aStream); + User::LeaveIfError(aArray.Append(item)); + CleanupStack::Pop(); + } + } + +///////////////////////////////////////////////////////////////////// +// RArray utilities +///////////////////////////////////////////////////////////////////// +template +void ExternalizeArrayL(const RArray& aArray, RWriteStream& aStream) + { + aStream.WriteInt32L(aArray.Count()); + for (TInt i = 0; i < aArray.Count(); ++i) + { + aStream.WriteL(TPckgC(aArray[i])); + } + } + +template +void InternalizeArrayL(RArray& aArray, RReadStream& aStream) + { + TInt count = aStream.ReadInt32L(); + for (TInt i = 0; i < count; ++i) + { + T item; + TPckg itemPckg(item); + aStream.ReadL(itemPckg); + User::LeaveIfError(aArray.Append(item)); + } + }