diff -r 000000000000 -r c6b0df440bee dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasave.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dbgsrv/coredumpserver/plugins/formatters/test/testcrashdatasave.cpp Tue Mar 02 10:33:16 2010 +0530 @@ -0,0 +1,96 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "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: +// + +#include +#include "testcrashdatasave.h" + +CTestDataSave::~CTestDataSave() +{ + iData.Close(); +} + +CTestDataSave* CTestDataSave::NewL() +{ + CTestDataSave* self = new(ELeave) CTestDataSave(); + CleanupStack::PushL(self); + //self->ConstructL(); + self->iData.CreateL(0); + CleanupStack::Pop(self); + return self; +} + +TInt CTestDataSave::Open(const TDesC& aParam ) +{ + iData.Zero(); + return KErrNone; +} + +TInt CTestDataSave::Close() +{ + iData.ZeroTerminate(); + return KErrNone; +} + +TInt CTestDataSave::Write( const TDesC8& aData) +{ + iData.ReAlloc(iData.Length() + aData.Length()); + iData.Append(aData); + //Print(); + return KErrNone; +} + +TInt CTestDataSave::Write( TAny* aData, TUint aSize) +{ + TPtrC8 data(static_cast(aData), aSize); + return ( Write(data) ); +} + +TInt CTestDataSave::Write( TInt aPos, const TDesC8& aData ) +{ + if( 0 == iData.Length() ) + { + iData.CreateMax( aPos + aData.Length() ); + } + else if( aPos >= iData.Length() ) + { + iData.ReAlloc( aPos + aData.Length() ); + iData.SetMax(); + + } + else if( (aPos + aData.Length()) > iData.Length() ) + { + iData.ReAlloc( aPos - iData.Length() + aData.Length() ); + } + + iData.Replace( aPos, aData.Length(), aData ); + + return KErrNone; +} + + +TInt CTestDataSave::Write( TInt aPos, TAny* aData, TUint aSize ) + { + TPtrC8 data(static_cast(aData), aSize); + return ( Write(aPos, data) ); + } + +void CTestDataSave::Print() const + { + RBuf8 printBuf; + printBuf.Create( iData, iData.Length()+1 ); + char* clPrompt = (char*) printBuf.PtrZ(); + RDebug::Printf(" CTestDataSave::Print() length=%d, iData=>>>%s<<<\n", iData.Length(), clPrompt ); + printBuf.Close(); + }