persistentstorage/store/INC/U32FRAME.H
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined(__U32FRAME_H__)
       
    17 #define __U32FRAME_H__
       
    18 #if !defined(__S32SHARE_H__)
       
    19 #include <s32share.h>
       
    20 #endif
       
    21 
       
    22 #if defined(_DEBUG)&&!defined(__SMALL_FRAME)
       
    23 //#define __SMALL_FRAME
       
    24 #endif
       
    25 //
       
    26 enum TFrameType16
       
    27 	{
       
    28 	EFrameFree16=0x0000,
       
    29 	EFrameData16=0x4000,
       
    30 	EFrameDescriptive16=0x8000,
       
    31 	EFrameContinuation16=0xc000
       
    32 	};
       
    33 typedef TUint16 TFrameDes16;
       
    34 const TInt KSizeFrameDes16=sizeof(TFrameDes16);
       
    35 const TInt KShiftFrameDes16=1;
       
    36 //
       
    37 const TInt KMaskFrame16=0xffff;
       
    38 const TInt KMaskFrameType16=0xc000;
       
    39 #if defined(__SMALL_FRAME)
       
    40 const TInt KMaskFrameLength16=0xf;
       
    41 const TInt KShiftFrameLength16=4;
       
    42 #else
       
    43 const TInt KMaskFrameLength16=0x3fff;
       
    44 const TInt KShiftFrameLength16=14;
       
    45 #endif
       
    46 //
       
    47 const TInt KFrameOpen16=0;
       
    48 const TInt KFrameMinLength16=1;
       
    49 const TInt KFrameMaxLength16=KMaskFrameLength16;
       
    50 const TInt KFrameFullLength16=KMaskFrameLength16+1;
       
    51 //
       
    52 const TInt KFrameNonexistent16=-1;
       
    53 //
       
    54 NONSHARABLE_CLASS(RFrame16Buf) : public MStreamBuf
       
    55 	{
       
    56 public:
       
    57 	static TInt Offset(TStreamPos aBase,TStreamPos aPos);
       
    58 	static TStreamPos Position(TStreamPos aBase,TInt anOffset);
       
    59 //
       
    60 	RFrame16Buf(TStreamPos aBase);
       
    61 	inline TStreamPos Base() const;
       
    62 	inline TInt Offset(TStreamPos aPos) const;
       
    63 	inline TStreamPos Position(TInt anOffset) const;
       
    64 //
       
    65 	TInt ExtendL(TStreamExchange& aHost,TInt anExtent,TInt aMode=ERead|EWrite);
       
    66 	void OpenL(TStreamExchange& aHost,TInt anOffset,TInt aMode=ERead|EWrite);
       
    67 	void Set(TStreamExchange& aHost,TInt anOffset,TInt anExtent,TInt aMode=ERead|EWrite);
       
    68 //
       
    69 	inline TInt Offset() const;
       
    70 	inline TInt Extent() const;
       
    71 protected:
       
    72 	inline TBool IsCommitted() const;
       
    73 	void CommitL();
       
    74 //
       
    75 	void DoRelease();
       
    76 	void DoSynchL();
       
    77 private:
       
    78 	TInt DoReadL(TAny* aPtr,TInt aMaxLength);
       
    79 	TInt DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
       
    80 	TStreamTransfer DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer);
       
    81 	void DoWriteL(const TAny* aPtr,TInt aLength);
       
    82 	TInt DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
       
    83 	TStreamTransfer DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer);
       
    84 	TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
       
    85 //
       
    86 	inline TStreamExchange& Host() const;
       
    87 	TInt UnderflowL();
       
    88 	void OverflowL();
       
    89 	TBool ReachL(TInt anOffset);
       
    90 	TInt EndL();
       
    91 private:
       
    92 	TStreamPos iBase;
       
    93 	TStreamExchange* iHost;
       
    94 	TInt iOff;
       
    95 	TInt iExt;
       
    96 	TStreamMark iRMark,iWMark;
       
    97 	TInt iRAvail,iWAvail;
       
    98 	TInt iRLim,iWLim;
       
    99 	TInt iMode;
       
   100 	};
       
   101 
       
   102 #include "U32FRAME.INL"
       
   103 #endif