authenticationservices/authenticationserver/source/common/idandstring.cpp
changeset 29 ece3df019add
equal deleted inserted replaced
19:cd501b96611d 29:ece3df019add
       
     1 /*
       
     2 * Copyright (c) 2005-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 * CIdAndString implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22 */
       
    23 
       
    24 #include "authcommon_impl.h"
       
    25 #include "authserver/idandstring.h"
       
    26 
       
    27 using namespace AuthServer;
       
    28 
       
    29 EXPORT_C CIdAndString* CIdAndString::NewLC(TIdentityId aId, const TDesC& aString)
       
    30 	{
       
    31 	CIdAndString* me = new (ELeave) CIdAndString();
       
    32 	CleanupStack::PushL(me);
       
    33 	me->ConstructL(aId, aString);
       
    34 	return me;
       
    35 	}
       
    36 
       
    37 EXPORT_C void CIdAndString::ConstructL(TIdentityId aId, const TDesC& aString)
       
    38     {
       
    39     iId = aId;
       
    40 	iString = aString.AllocL();
       
    41 	}
       
    42 
       
    43 	
       
    44 EXPORT_C CIdAndString::~CIdAndString() { delete iString; }
       
    45 
       
    46 EXPORT_C CIdAndString* CIdAndString::NewLC(RReadStream& aStream)
       
    47 	    {
       
    48 		CIdAndString* me = new (ELeave) CIdAndString();
       
    49 		CleanupStack::PushL(me);
       
    50 		me->InternalizeL(aStream);
       
    51 		return me;
       
    52 		}
       
    53 EXPORT_C void CIdAndString::ExternalizeL(RWriteStream& aStream) const
       
    54 	    {
       
    55 		  aStream << iId;
       
    56 		  aStream << *iString;
       
    57 	    }
       
    58 
       
    59 void CIdAndString::InternalizeL(RReadStream& aStream) 
       
    60 	{
       
    61 	aStream >> iId;
       
    62 	if (iString)
       
    63 		{
       
    64 		delete iString;
       
    65 		iString = 0;
       
    66 		}
       
    67 	iString = HBufC::NewL(aStream,255);
       
    68 	}
       
    69 	
       
    70 EXPORT_C TIdentityId CIdAndString::Id() const
       
    71   {
       
    72   return iId;
       
    73   }
       
    74 EXPORT_C HBufC* CIdAndString::String() const
       
    75   {
       
    76   return iString;
       
    77   }