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