|
1 /* |
|
2 * Copyright (c) 2004 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: Content writer for the XML Serializer. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __TPENGWRITER_H__ |
|
19 #define __TPENGWRITER_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 |
|
24 |
|
25 |
|
26 // CLASS DECLARATION |
|
27 /** |
|
28 * Content writer for the XML Serializer. |
|
29 * |
|
30 * Simple class encapsulating the overflow |
|
31 * safe handling of the write buffer. |
|
32 * |
|
33 * @lib PEngParser.lib |
|
34 * @since 2.1 |
|
35 */ |
|
36 NONSHARABLE_CLASS( TPEngWriter ) |
|
37 { |
|
38 |
|
39 public: // Constructor and destructor |
|
40 |
|
41 /** |
|
42 * C++ constructor. |
|
43 * @param aBuffer Reference to buffer where |
|
44 * to write. |
|
45 */ |
|
46 TPEngWriter( TDes8& aBuffer ); |
|
47 |
|
48 |
|
49 public: //New buffer handling methods |
|
50 |
|
51 |
|
52 /** |
|
53 * Writes text to destination |
|
54 * buffer. Leaves with KErrOverflow |
|
55 * if the passed aText doesn't fit in the |
|
56 * buffer. Returns TPtrC8 pointing to text |
|
57 * just wrote to the buffer. |
|
58 * (Returned pointer descriptor stays valid |
|
59 * untill the text is reversed beoynd the |
|
60 * start position of current write operation.) |
|
61 * |
|
62 * @since 2.1 |
|
63 * @param aText Text to write. |
|
64 * @return Pointer descriptor pointing to |
|
65 * just written text. (Pointer descriptor |
|
66 * stays valid until the buffer is reversed |
|
67 * beyond the text's start position.) |
|
68 */ |
|
69 const TPtrC8 WriteL( const TDesC8& aText ); |
|
70 |
|
71 |
|
72 /** |
|
73 * Writes a character to destination |
|
74 * buffer. Leaves with KErrOverflow |
|
75 * if the character doesn't fit in the |
|
76 * buffer. |
|
77 * |
|
78 * @since 2.1 |
|
79 * @param aCharacter Character to write. |
|
80 */ |
|
81 void WriteL( TUint8 aCharacter ); |
|
82 |
|
83 |
|
84 |
|
85 /** |
|
86 * Gets the write buffers current length. |
|
87 * |
|
88 * @since 2.1 |
|
89 * @return Write buffers current length. |
|
90 */ |
|
91 TInt CurrentLength(); |
|
92 |
|
93 |
|
94 /** |
|
95 * Reverses the write buffer to required |
|
96 * length. |
|
97 * |
|
98 * If required length aLength is greater |
|
99 * than current buffer length, |
|
100 * returns KErrUnderflow. Else returns KErrNone. |
|
101 * |
|
102 * @since 2.1 |
|
103 * @param aLength Length to reverse to. |
|
104 * @return KErrNone or KErrUnderflow. |
|
105 */ |
|
106 TInt ReverseTo( TInt aLength ); |
|
107 |
|
108 |
|
109 |
|
110 protected: // Data |
|
111 |
|
112 ///<Reference to buffer to write to. |
|
113 TDes8& iBuffer; |
|
114 }; |
|
115 |
|
116 #endif // __TPENGWRITER_H__ |
|
117 |
|
118 // End of File |