authenticationservices/authenticationserver/source/common/arrayutils.h
changeset 29 ece3df019add
equal deleted inserted replaced
19:cd501b96611d 29:ece3df019add
       
     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 the License "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 * Utility functions for streaming arrays.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @released
       
    23  @internalComponent 
       
    24 */
       
    25 
       
    26 #ifndef __ARRAYUTILS_H_
       
    27 #define __ARRAYUTILS_H_
       
    28 
       
    29 #include <s32strm.h>
       
    30 
       
    31 namespace AuthServer
       
    32 {
       
    33 	
       
    34 /////////////////////////////////////////////////////////////////////
       
    35 // RPointerArray utilities
       
    36 /////////////////////////////////////////////////////////////////////
       
    37 
       
    38 template <class T>
       
    39 void ExternalizePointerArrayL(const RPointerArray<T>& aArray, RWriteStream& aStream);
       
    40 
       
    41 template <class T>
       
    42 void InternalizePointerArrayL(RPointerArray<T>& aArray, RReadStream& aStream);
       
    43 
       
    44 /////////////////////////////////////////////////////////////////////
       
    45 // RArray utilities
       
    46 /////////////////////////////////////////////////////////////////////
       
    47 
       
    48 template <class T>
       
    49 void ExternalizeArrayL(const RArray<T>& aArray, RWriteStream& aStream);
       
    50 
       
    51 template <class T>
       
    52 void InternalizeArrayL(RArray<T>& aArray, RReadStream& aStream);
       
    53 
       
    54 /////////////////////////////////////////////////////////////////////
       
    55 // Traits classes - internally required by RPointerArray functions
       
    56 /////////////////////////////////////////////////////////////////////
       
    57 
       
    58 template <class T>
       
    59 class TTraits
       
    60 	{
       
    61 public:
       
    62 	static T* ReadFromStreamLC(RReadStream& aStream) { return T::NewLC(aStream); }
       
    63 	static void WriteToStreamL(const T& aItem, RWriteStream& aStream) { aStream << aItem; }
       
    64 	};
       
    65 
       
    66 // Specialisation for HBufs
       
    67 template <>
       
    68 class TTraits<HBufC16>
       
    69 	{
       
    70 public:
       
    71 	static HBufC16* ReadFromStreamLC(RReadStream& aStream) { return HBufC16::NewLC(aStream, KMaxTInt); }
       
    72 	static void WriteToStreamL(const HBufC16& aItem, RWriteStream& aStream) { aStream << aItem; }
       
    73 	};
       
    74 
       
    75 #include "arrayutils.inl"
       
    76 } // namespace AuthServer
       
    77 
       
    78 #endif  // __ARRAYUTILS_H_