os/persistentdata/persistentstorage/store/USTOR/UT_UTL.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/store/USTOR/UT_UTL.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,126 @@
     1.4 +// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "UT_STD.H"
    1.20 +
    1.21 +#pragma BullseyeCoverage off
    1.22 +
    1.23 +//
    1.24 +// Panic the process with STORE-Store as the category.
    1.25 +//
    1.26 +GLDEF_C void Panic(TStorePanic aPanic)
    1.27 +	{
    1.28 +	_LIT(KCategory,"STORE-Store");
    1.29 +	User::Panic(KCategory,aPanic);
    1.30 +	}
    1.31 +
    1.32 +#pragma BullseyeCoverage on
    1.33 +
    1.34 +EXPORT_C void TStreamId::InternalizeL(RReadStream& aStream)
    1.35 +/** Internalises an object of this class from a read stream.
    1.36 +
    1.37 +The presence of this function means that the standard templated operator>>() 
    1.38 +can be used to internalise objects of this class.
    1.39 +
    1.40 +Note that the function has assignment semantics. It replaces the old value 
    1.41 +of the object with a new value read from the read stream.
    1.42 +
    1.43 +@param aStream Stream from which the object should be internalised. */
    1.44 +	{
    1.45 +	aStream>>iVal;
    1.46 +	if (iVal>KMaxStreamIdValue)
    1.47 +		__LEAVE(KErrCorrupt);
    1.48 +	}
    1.49 +
    1.50 +EXPORT_C void MIncrementalCollector::DoRelease()
    1.51 +/** Implementation of the public Release() function. This signals that client has 
    1.52 +no further need of the object and all necessary clean-up should be done. e.g. 
    1.53 +if the implementation object is allocated on the heap, it could be deleted. */
    1.54 +	{}
    1.55 +
    1.56 +EXPORT_C void MIncrementalCollector::DoNextL(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus,TPckgBuf<TInt>& aTotal)
    1.57 +/** Implementation of the public asynchronous NextL() function. The default implementation 
    1.58 +invokes the synchronous form of DoNextL() and then reports the result by signalling 
    1.59 +the request status.
    1.60 +
    1.61 +@param aStep The progress value from either the last NextL() increment of 
    1.62 +from ResetL() if the reclamation/compaction was restarted. On return, 
    1.63 +should contain the new progress value, which can be used in subsequent calls 
    1.64 +to NextL(). This must be equal to, or less than, the previous value a 
    1.65 +zero value must be used to indicate that the operation is complete.
    1.66 +@param aStatus A status variable. KErrNone on successful completion, otherwise 
    1.67 +another of the system-wide error codes.
    1.68 +@param aTotal On return, should contain the total amount of free space in the 
    1.69 +store. */
    1.70 +	{
    1.71 +	DoNextL(aStep(),aTotal());
    1.72 +	TRequestStatus* stat=&aStatus;
    1.73 +	User::RequestComplete(stat,KErrNone);
    1.74 +	}
    1.75 +
    1.76 +HDirectStoreBuf* HDirectStoreBuf::CreateL(TStreamExchange& aHost,TStreamId& anId,TInt aMode)
    1.77 +//
    1.78 +// Create a stream buffer for a new 'direct' stream.
    1.79 +//
    1.80 +	{
    1.81 +	TInt size=aHost.SizeL();
    1.82 +	HDirectStoreBuf* buf=NewL(aHost,size,aMode);
    1.83 +	anId=TStreamId(size);
    1.84 +	return buf;
    1.85 +	}
    1.86 +
    1.87 +HDirectStoreBuf* HDirectStoreBuf::OpenL(TStreamExchange& aHost,TStreamId anId,TInt aMode)
    1.88 +//
    1.89 +// Create a stream buffer for an existing 'direct' stream.
    1.90 +//
    1.91 +	{
    1.92 +	HDirectStoreBuf* buf=NewL(aHost,anId.Value(),aMode);
    1.93 +	return buf;
    1.94 +	}
    1.95 +
    1.96 +HDirectStoreBuf* HDirectStoreBuf::NewL(TStreamExchange& aHost,TInt anOffset,TInt aMode)
    1.97 +	{
    1.98 +	HDirectStoreBuf* buf=new(ELeave) HDirectStoreBuf(anOffset);
    1.99 +	buf->Open(aHost,TStreamPos(anOffset),aMode);
   1.100 +	return buf;
   1.101 +	}
   1.102 +
   1.103 +void HDirectStoreBuf::DoRelease()
   1.104 +//
   1.105 +// Finished with this stream buffer.
   1.106 +//
   1.107 +	{
   1.108 +	delete this;
   1.109 +	}
   1.110 +
   1.111 +TStreamPos HDirectStoreBuf::DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset)
   1.112 +//
   1.113 +// Position the mark(s) indicated by aMark at anOffset from aLocation.
   1.114 +//
   1.115 +	{
   1.116 +	TInt off=iOff;
   1.117 +	if (aLocation==EStreamBeginning)
   1.118 +		anOffset+=off;
   1.119 +	return RShareBuf::DoSeekL(aMark,aLocation,anOffset)-off;
   1.120 +	}
   1.121 +
   1.122 +EXPORT_C void TStreamId::__DbgChkRange(TUint32 aValue)
   1.123 +//
   1.124 +// Check for values out of range.
   1.125 +//
   1.126 +	{
   1.127 +	__ASSERT_ALWAYS(aValue<=KMaxStreamIdValue,Panic(EStoreIdOutOfRange));
   1.128 +	}
   1.129 +