|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: A unicode des buffer with automatic memory* |
|
15 */ |
|
16 |
|
17 #ifndef __MDSCLAUSEBUFFER_H__ |
|
18 #define __MDSCLAUSEBUFFER_H__ |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 |
|
23 |
|
24 /** |
|
25 * An automatic clause buffer class. The class provides Descriptor |
|
26 * functionality, plus automatic memory handling so that it reserves |
|
27 * the required space automatically as the size grows. |
|
28 */ |
|
29 class CMdsClauseBuffer: public CBase |
|
30 { |
|
31 public: // public definitions |
|
32 |
|
33 /** |
|
34 * Static constructor |
|
35 * @param aInitialSize size of the buffer |
|
36 * @return buffer instance |
|
37 */ |
|
38 IMPORT_C static CMdsClauseBuffer* NewL( TInt aInitialSize ); |
|
39 |
|
40 /** |
|
41 * Static constructor |
|
42 * @param aInitialSize size of the buffer |
|
43 * @return buffer instance |
|
44 */ |
|
45 IMPORT_C static CMdsClauseBuffer* NewLC( TInt aInitialSize ); |
|
46 |
|
47 virtual ~CMdsClauseBuffer(); |
|
48 |
|
49 private: |
|
50 |
|
51 /** |
|
52 * Default constructor |
|
53 */ |
|
54 CMdsClauseBuffer(); |
|
55 |
|
56 /** |
|
57 * 2nd phase constructor |
|
58 * @param aInitialSize size of the buffer |
|
59 */ |
|
60 void ConstructL( TInt aInitialSize ); |
|
61 |
|
62 public: |
|
63 |
|
64 /** |
|
65 * Appends a descriptor at the end of this descriptor. |
|
66 * Increases the size of the descriptor if needed. |
|
67 * @param aDes descriptor which is appended |
|
68 */ |
|
69 void AppendL( const TDesC16& aDes ); |
|
70 |
|
71 /** |
|
72 * Appends a descriptor at the end of this descriptor. |
|
73 * Increases the size of the descriptor if needed. |
|
74 * @param aDes descriptor which is appended |
|
75 * @param aAdditionl |
|
76 */ |
|
77 void AppendL( const TDesC16& aDes, const TInt aAdditional ); |
|
78 |
|
79 /** |
|
80 * Makes sure the buffer max size is AT LEAST given required bytes. |
|
81 * @param aRequired required buffer total size |
|
82 * @return ETrue if the buffer was re-allocated |
|
83 */ |
|
84 TBool ReserveSpaceL( TInt aRequired ); |
|
85 |
|
86 /** |
|
87 * Return buffer. |
|
88 * |
|
89 * @return buffer |
|
90 * |
|
91 * @leave KErrNotFound Buffer is NULL. |
|
92 */ |
|
93 TPtr BufferL() const; |
|
94 |
|
95 /** |
|
96 * Return const reference to buffer. |
|
97 * |
|
98 * @return const reference to buffer |
|
99 * |
|
100 * @leave KErrNotFound Buffer is NULL. |
|
101 */ |
|
102 const TDesC& ConstBufferL() const; |
|
103 |
|
104 private: |
|
105 |
|
106 /** |
|
107 * The heap buffer |
|
108 */ |
|
109 HBufC* iBuffer; |
|
110 |
|
111 /** |
|
112 * Current size of the buffer |
|
113 */ |
|
114 TInt iCurrentBufSize; |
|
115 }; |
|
116 |
|
117 |
|
118 #endif // __MDSCLAUSEBUFFER_H__ |