commsfwutils/commsbufs/version1/mbufmgr/INC/MBufChain.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #if !defined(__MBufChain_h__)
       
    21 #define __MBufChain_h__
       
    22 
       
    23 #include <comms-infras/mbufallocator.h>
       
    24 
       
    25 class RMBuf;
       
    26 
       
    27 /**
       
    28 MBUF CHAIN
       
    29 
       
    30 @internalComponent
       
    31 */
       
    32 #define MBUF_TODATA(chain, type) \
       
    33 	(chain.Align(sizeof(type)), (type *)chain.First()->Ptr())
       
    34 
       
    35 /**
       
    36 Constant to indicate as much as possible, or whole chain
       
    37 @internalComponent
       
    38 */
       
    39 const TInt KMBufAll = KMaxTInt;
       
    40 
       
    41 class RMBufChain
       
    42 /**
       
    43 @publishedPartner
       
    44 @released
       
    45 */
       
    46 	{
       
    47 	__DECLARE_CLEANUP
       
    48 public:
       
    49 	inline RMBufChain();
       
    50 	inline RMBufChain(RMBuf* aChain);
       
    51 	//
       
    52 	inline void Init();
       
    53 	inline TBool IsEmpty() const;
       
    54 	inline RMBufChain& Next();
       
    55 	inline const RMBufChain& Next() const;
       
    56 	inline void Link(RMBufChain& aChain);
       
    57 	inline void Unlink();
       
    58 	inline RMBuf* First();
       
    59 	inline const RMBuf* First() const;
       
    60 	IMPORT_C RMBuf* Last() const;
       
    61 	inline RMBufChain &operator =(RMBuf* aChain);
       
    62 	//
       
    63 	IMPORT_C RMBuf* Remove();
       
    64 	IMPORT_C void Assign(RMBufQ& aQueue);
       
    65 	IMPORT_C void Assign(RMBufChain& aChain);
       
    66 	IMPORT_C void Append(RMBufChain& aChain);
       
    67 	IMPORT_C void AppendL(TInt aLen);
       
    68 	IMPORT_C TInt Append(TInt aLen);
       
    69 	IMPORT_C TInt Append(TInt aLen, RMBufAllocator &aRMBufAllocator);
       
    70 
       
    71 	IMPORT_C void PrependL(TInt aLen);
       
    72 	IMPORT_C TInt Prepend(TInt aLen);
       
    73 	IMPORT_C TInt Prepend(TInt aLen, RMBufAllocator& aRMBufAllocator);
       
    74 
       
    75 	IMPORT_C void Prepend(RMBuf* aBuf);
       
    76 	IMPORT_C void Prepend(RMBufChain& aChain);
       
    77 	IMPORT_C void AllocL(TInt aLen = 0);
       
    78 	IMPORT_C TInt Alloc(TInt aLen = 0);
       
    79 	IMPORT_C TInt Alloc(TInt aLen, TInt aMinMBufSize);
       
    80 	IMPORT_C TInt Alloc(TInt aLen, TInt aMinMBufSize, TInt aMaxMBufSize);
       
    81 	IMPORT_C void AllocL(TInt aLen, RMBufAllocator& aRMBufAllocator);
       
    82 	IMPORT_C TInt Alloc(TInt aLen, RMBufAllocator& aRMBufAllocator);
       
    83 	IMPORT_C TInt Alloc(TInt aLen, TInt aMinMBufSize, RMBufAllocator& aRMBufAllocator);
       
    84 	IMPORT_C TInt Alloc(TInt aLen, TInt aMinMBufSize, TInt aMaxMBufSize, RMBufAllocator& aRMBufAllocator);
       
    85 
       
    86 	IMPORT_C void ReAllocL(TInt aLen);
       
    87 	IMPORT_C TInt ReAlloc(TInt aLen);
       
    88 	IMPORT_C void CreateL(const TDesC8& aDes, TInt aHdrLen=0);
       
    89 	IMPORT_C TInt Create(const TDesC8& aDes, TInt aHdrLen=0);
       
    90  	IMPORT_C void SplitL(TInt anOffset, RMBufChain& newChain);
       
    91  	IMPORT_C TInt Split(TInt anOffset, RMBufChain& newChain);
       
    92  	IMPORT_C TInt Split(TInt anOffset, RMBufChain& newChain, RMBufAllocator& aRMBufAllocator);
       
    93 
       
    94 	IMPORT_C TInt Align(TInt aSize);
       
    95 	IMPORT_C void Free();
       
    96 	IMPORT_C void FillZ(TInt aLen=KMBufAll);
       
    97 	IMPORT_C void CopyL(RMBufChain& newChain, TInt aOffset=0, TInt aLen=KMBufAll) const;
       
    98 	IMPORT_C TInt Copy(RMBufChain& newChain, TInt aOffset=0, TInt aLen=KMBufAll) const;
       
    99  	IMPORT_C void CopyIn(const TDesC8& aDes, TInt aOffset=0);
       
   100 	IMPORT_C void CopyOut(TDes8 &aDes, TInt aOffset=0) const;
       
   101 	IMPORT_C void TrimStart(TInt nBytes);
       
   102 	IMPORT_C void TrimEnd(TInt anOffset);
       
   103 	IMPORT_C TBool Goto(TInt anOffset, RMBuf* &resBuf, TInt& resOffset, TInt& resLength, RMBuf* &resPrevBuf) const;
       
   104 	inline TBool Goto(TInt anOffset, RMBuf* &resBuf, TInt& resOffset, TInt& resLength) const;
       
   105 	IMPORT_C TInt NumBufs() const;
       
   106 	IMPORT_C TInt Length() const;
       
   107 private:
       
   108 	TInt Alloc(TInt aLen, const RMBufChain& aMBufChain);
       
   109 	TInt Alloc(TInt aLen, const RMBufChain& aMBufChain, RMBufAllocator& aRMBufAllocator);
       
   110 protected:
       
   111 	RMBuf* iNext;
       
   112 	};
       
   113 
       
   114 #endif
       
   115 
       
   116 #if !defined(__MBufChain_Ignore_Inlines__)
       
   117 #define __MBuf_Ignore_Inlines__
       
   118 #include <comms-infras/mbuf.h>
       
   119 #undef __MBuf_Ignore_Inlines__
       
   120 #include <comms-infras/mbufchain.inl>
       
   121 #endif // __MBufchain_Ignore_Inlines__
       
   122