|
1 // Copyright (c) 2001-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 WSPDecoder.h |
|
18 @publishedAll |
|
19 @deprecated |
|
20 */ |
|
21 |
|
22 #ifndef __WSPDECODER_H__ |
|
23 #define __WSPDECODER_H__ |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <stringpool.h> |
|
27 |
|
28 |
|
29 /** |
|
30 * This file contains the following classes: |
|
31 * TWspField |
|
32 * TWspHeaderSegmenter |
|
33 * TWspPrimitiveDecoder |
|
34 * |
|
35 */ |
|
36 |
|
37 |
|
38 /** |
|
39 enum DecoderPanic |
|
40 @publishedAll |
|
41 @deprecated |
|
42 */ |
|
43 enum TWspDecoderPanic |
|
44 { |
|
45 /** |
|
46 LongIntOverflow |
|
47 */ |
|
48 EWspDecoderLongIntOverflow, |
|
49 /** |
|
50 DateOverflow |
|
51 */ |
|
52 EWspDecoderDateOverflow |
|
53 }; |
|
54 |
|
55 /** |
|
56 TWspField class holds the pair <HeaderName, ValueBuffer> |
|
57 This is a simple class that associates these values. |
|
58 No ownership is handed to this class. It is up to user of this class to |
|
59 open and close all resources used. |
|
60 @publishedAll |
|
61 @deprecated |
|
62 */ |
|
63 class TWspField |
|
64 { |
|
65 public: |
|
66 |
|
67 inline TWspField(); |
|
68 |
|
69 inline TWspField(RStringF aHdrName, TPtrC8 aValBuf); |
|
70 |
|
71 /** |
|
72 The header name of a opened RStringF - *Not Owned* |
|
73 This is externally opened. It must be externally |
|
74 closed. |
|
75 */ |
|
76 RStringF iHdrName; |
|
77 |
|
78 /** The raw value buffer - Note: Not owned by this */ |
|
79 TPtrC8 iValBuffer; |
|
80 }; |
|
81 |
|
82 /** |
|
83 TWspHeaderSegmenter segments a WSP buffer into WSP header/value pairs. |
|
84 It detects boundaries between header/values based on the WAP-WSP spec. |
|
85 - To construct, buffer and string pool is passed in |
|
86 - Call to NextL() to iterate through the buffer - this returns a TWspField |
|
87 - NextL() returns KErrNotFound when done |
|
88 |
|
89 @publishedAll |
|
90 @deprecated |
|
91 */ |
|
92 class TWspHeaderSegmenter |
|
93 { |
|
94 public: |
|
95 |
|
96 inline TWspHeaderSegmenter(RStringPool aPool, const TStringTable& aStringTable, TPtrC8 aBuffer); |
|
97 |
|
98 IMPORT_C TInt NextL(TWspField& aWspHeader); |
|
99 |
|
100 inline TInt Offset() const; |
|
101 |
|
102 private: |
|
103 /** Raw buffer that will be segmented - Not Owned */ |
|
104 TPtrC8 iBuffer; |
|
105 |
|
106 /** Segment offset into the buffer. */ |
|
107 TInt iOffset; |
|
108 |
|
109 /** Opened string pool to use with the string table already loaded - Not Owned */ |
|
110 RStringPool iPool; |
|
111 |
|
112 /** The string table to use in the string pool - Not Owned */ |
|
113 const TStringTable& iStringTable; |
|
114 }; |
|
115 |
|
116 /** |
|
117 Decoder for WSP Primitves - WAP-WSP Section 8.4.1 |
|
118 @publishedAll |
|
119 @deprecated |
|
120 */ |
|
121 class TWspPrimitiveDecoder |
|
122 { |
|
123 public: |
|
124 |
|
125 /** |
|
126 * TWspHeaderType describe the types from WAP-WSP Section 8.4.1.2 |
|
127 */ |
|
128 enum TWspHeaderType |
|
129 { |
|
130 /** |
|
131 The type has not been set |
|
132 */ |
|
133 ENotSet, |
|
134 /** |
|
135 0-31 - octet is a value length |
|
136 */ |
|
137 ELengthVal, |
|
138 /** |
|
139 34 - value is a quoted text string, terminated by a Null |
|
140 */ |
|
141 EQuotedString, |
|
142 /** |
|
143 32-127 - value is a text string, terminated by a Null |
|
144 */ |
|
145 EString, |
|
146 /** |
|
147 128-255 - encoded 7 bit value, this header has no more data |
|
148 */ |
|
149 E7BitVal |
|
150 }; |
|
151 |
|
152 |
|
153 inline TWspPrimitiveDecoder(TPtrC8 aBuffer); |
|
154 |
|
155 IMPORT_C TWspHeaderType VarType() const; |
|
156 |
|
157 IMPORT_C TInt LengthVal(TInt& aVal); |
|
158 |
|
159 IMPORT_C TInt String(TPtrC8& aString); |
|
160 |
|
161 |
|
162 IMPORT_C TInt Val7Bit(TUint8& aVal); |
|
163 |
|
164 IMPORT_C TInt Integer(TUint32& aVal); |
|
165 |
|
166 IMPORT_C TInt LongInt(TUint32& aVal); |
|
167 |
|
168 IMPORT_C TInt UintVar(TUint32& aVal); |
|
169 |
|
170 IMPORT_C TInt VersionL(RStringPool aPool, RStringF& aVer); |
|
171 |
|
172 IMPORT_C TInt Date(TDateTime& aDateTime); |
|
173 |
|
174 private: |
|
175 /** The raw buffer */ |
|
176 TPtrC8 iBuffer; |
|
177 |
|
178 /** The current offset */ |
|
179 TInt iOffset; |
|
180 }; |
|
181 |
|
182 /** |
|
183 Constructor |
|
184 |
|
185 */ |
|
186 inline TWspField::TWspField() |
|
187 { |
|
188 } |
|
189 |
|
190 /** |
|
191 Constructor |
|
192 |
|
193 @param aHdrName In - The Header Name. This must be an opened RStringF |
|
194 @param aValBuf In - the Buffer containing the header value in its raw format |
|
195 */ |
|
196 inline TWspField::TWspField(RStringF aHdrName, TPtrC8 aValBuf) : |
|
197 iHdrName(aHdrName), |
|
198 iValBuffer(aValBuf) |
|
199 { |
|
200 } |
|
201 |
|
202 /** |
|
203 Constructor |
|
204 |
|
205 @param aPool In - an opened RStringPool - owned by the caller |
|
206 @param aStringTable In - the string table in the string pool to use |
|
207 @param aBuffer In - the buffer containing the WSP header data - owned by the caller |
|
208 @pre The string table must be opened with the WSP Sting constants table |
|
209 */ |
|
210 inline TWspHeaderSegmenter::TWspHeaderSegmenter(RStringPool aPool, const TStringTable& aStringTable, TPtrC8 aBuffer) : |
|
211 iBuffer(aBuffer), |
|
212 iOffset(0), |
|
213 iPool(aPool), |
|
214 iStringTable(aStringTable) |
|
215 { |
|
216 } |
|
217 |
|
218 /** |
|
219 Offset returns the current offset into the buffer being parsed. |
|
220 |
|
221 @return TInt offset value. It will point to beginning of next segmented field. |
|
222 If NextL has not been called it will be set to 0. The beginning of the buffer. |
|
223 If buffer has been completely parsed, will return KErrNotFound. |
|
224 */ |
|
225 inline TInt TWspHeaderSegmenter::Offset() const |
|
226 { |
|
227 return (iOffset < iBuffer.Length()) ? iOffset : KErrNotFound; |
|
228 } |
|
229 |
|
230 /** |
|
231 Constructor |
|
232 |
|
233 @param aBuffer In - the buffer containing the value in its raw format |
|
234 */ |
|
235 inline TWspPrimitiveDecoder::TWspPrimitiveDecoder(TPtrC8 aBuffer) : |
|
236 iBuffer(aBuffer), |
|
237 iOffset(0) |
|
238 { |
|
239 } |
|
240 |
|
241 |
|
242 #endif // __WSPDECODER_H__ |
|
243 |
|
244 |