authenticationservices/authenticationserver/source/common/idandstring.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 24 Nov 2009 09:06:03 +0200
changeset 19 ece3df019add
permissions -rw-r--r--
Revision: 200948 Kit: 200948

/*
* Copyright (c) 2005-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: 
* CIdAndString implementation
*
*/


/**
 @file 
*/

#include "authcommon_impl.h"
#include "authserver/idandstring.h"

using namespace AuthServer;

EXPORT_C CIdAndString* CIdAndString::NewLC(TIdentityId aId, const TDesC& aString)
	{
	CIdAndString* me = new (ELeave) CIdAndString();
	CleanupStack::PushL(me);
	me->ConstructL(aId, aString);
	return me;
	}

EXPORT_C void CIdAndString::ConstructL(TIdentityId aId, const TDesC& aString)
    {
    iId = aId;
	iString = aString.AllocL();
	}

	
EXPORT_C CIdAndString::~CIdAndString() { delete iString; }

EXPORT_C CIdAndString* CIdAndString::NewLC(RReadStream& aStream)
	    {
		CIdAndString* me = new (ELeave) CIdAndString();
		CleanupStack::PushL(me);
		me->InternalizeL(aStream);
		return me;
		}
EXPORT_C void CIdAndString::ExternalizeL(RWriteStream& aStream) const
	    {
		  aStream << iId;
		  aStream << *iString;
	    }

void CIdAndString::InternalizeL(RReadStream& aStream) 
	{
	aStream >> iId;
	if (iString)
		{
		delete iString;
		iString = 0;
		}
	iString = HBufC::NewL(aStream,255);
	}
	
EXPORT_C TIdentityId CIdAndString::Id() const
  {
  return iId;
  }
EXPORT_C HBufC* CIdAndString::String() const
  {
  return iString;
  }