|
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 #include <delimitedpathsegment8.h> |
|
17 #include <delimitedpathsegment16.h> |
|
18 #include <escapeutils.h> |
|
19 |
|
20 // |
|
21 // |
|
22 // Implemetation of CDelimitedPathSegment8 |
|
23 // |
|
24 // |
|
25 |
|
26 /** |
|
27 Static factory constructor. Uses two phase construction and leaves nothing on |
|
28 the CleanupStack. |
|
29 |
|
30 @since 6.0 |
|
31 @param aPathSegment A descriptor with the initial path segment. |
|
32 @return A pointer to created object. |
|
33 @post Nothing left on the CleanupStack. |
|
34 */ |
|
35 EXPORT_C CDelimitedPathSegment8* CDelimitedPathSegment8::NewL(const TDesC8& aPathSegment) |
|
36 { |
|
37 CDelimitedPathSegment8* self = NewLC(aPathSegment); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 /** |
|
43 Static factory constructor. Uses two phase construction and leaves a pointer to |
|
44 created object on the CleanupStack. |
|
45 |
|
46 @since 6.0 |
|
47 @param aPathSegment A descriptor with the initial path segment. |
|
48 @return A pointer to created object. |
|
49 @post Pointer to created object left of CleanupStack. |
|
50 */ |
|
51 EXPORT_C CDelimitedPathSegment8* CDelimitedPathSegment8::NewLC(const TDesC8& aPathSegment) |
|
52 { |
|
53 CDelimitedPathSegment8* self = new (ELeave) CDelimitedPathSegment8; |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(aPathSegment); |
|
56 return self; |
|
57 } |
|
58 |
|
59 /** |
|
60 Destructor. |
|
61 |
|
62 @since 6.0 |
|
63 */ |
|
64 EXPORT_C CDelimitedPathSegment8::~CDelimitedPathSegment8() |
|
65 { |
|
66 } |
|
67 |
|
68 /** |
|
69 |
|
70 Escape encodes the parameter then inserts the escaped version in a position before the |
|
71 current parsed parameter. The new parameter should only contain a single path segment |
|
72 parameter, as any parameter delimiters in the parameter will be converted to an escape |
|
73 triple. The parser is left in a state where its current parameter is the same one as before |
|
74 the insertion. |
|
75 |
|
76 @since 6.0 |
|
77 @param aParam A descriptor with the unescaped path segment parameter |
|
78 @pre The path segment must have been initially parsed. |
|
79 @post The path segment will have been extended to include the new |
|
80 parameter. The current segment will remain as the one before the insertion. |
|
81 */ |
|
82 EXPORT_C void CDelimitedPathSegment8::InsertAndEscapeCurrentL(const TDesC8& aParam) |
|
83 { |
|
84 // Create escaped version of the parameter |
|
85 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath); |
|
86 CleanupStack::PushL(escaped); |
|
87 |
|
88 // Insert the segment |
|
89 InsertCurrentL(*escaped); |
|
90 |
|
91 // Cleanup |
|
92 CleanupStack::PopAndDestroy(escaped); |
|
93 } |
|
94 |
|
95 /** |
|
96 Escape encodes the parameter then inserts the escaped version at the front of the |
|
97 path segment. The new parameter should only contain a single path segment parameter, |
|
98 as any parameter delimiters in the parameter will be converted to an escape triple. |
|
99 The parser is left in a state where its current parameter is the same one as before |
|
100 the insertion. |
|
101 |
|
102 @warning A re-parse is required to ensure that the parser is valid. |
|
103 @since 6.0 |
|
104 @param aParam A descriptor with the unescaped path segment parameter |
|
105 @pre The path segment must have been initially parsed. |
|
106 @post The path segment will have been extended to include the new |
|
107 parameter. The current segment will remain as the one before the insertion. |
|
108 */ |
|
109 EXPORT_C void CDelimitedPathSegment8::PushAndEscapeBackL(const TDesC8& aParam) |
|
110 { |
|
111 // Create escaped version of the parameter |
|
112 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath); |
|
113 CleanupStack::PushL(escaped); |
|
114 |
|
115 // Insert the segment |
|
116 PushBackL(*escaped); |
|
117 |
|
118 // Cleanup |
|
119 CleanupStack::PopAndDestroy(escaped); |
|
120 } |
|
121 |
|
122 /** |
|
123 Escape encodes the parameter then inserts the escaped version at the back of the |
|
124 path segment. The new parameter should only contain a single path segment parameter, |
|
125 as any parameter delimiters in the parameter will be converted to an escape triple. |
|
126 The parser is left in a state where its current parameter is the same one as before |
|
127 the insertion. |
|
128 |
|
129 @warning A re-parse is required to ensure that the parser is valid. |
|
130 @since 6.0 |
|
131 @param aParam A descriptor with the unescaped path segment parameter. |
|
132 @pre The path segment must have been initially parsed. |
|
133 @post The path segment will have been extended to include the new |
|
134 parameter. The current segment will remain as the one before the insertion. |
|
135 */ |
|
136 EXPORT_C void CDelimitedPathSegment8::PushAndEscapeFrontL(const TDesC8& aParam) |
|
137 { |
|
138 // Create escaped version of the parameter |
|
139 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath); |
|
140 CleanupStack::PushL(escaped); |
|
141 |
|
142 // Insert the segment |
|
143 PushFrontL(*escaped); |
|
144 |
|
145 // Cleanup |
|
146 CleanupStack::PopAndDestroy(escaped); |
|
147 } |
|
148 |
|
149 /** |
|
150 Constructor. First phase of two-phase construction method. Does non-allocating |
|
151 construction. |
|
152 |
|
153 @since 6.0 |
|
154 */ |
|
155 CDelimitedPathSegment8::CDelimitedPathSegment8() |
|
156 : CDelimitedDataBase8() |
|
157 { |
|
158 } |
|
159 |
|
160 /** |
|
161 Second phase of two-phase construction method. Does any allocations required to |
|
162 fully construct the object. |
|
163 |
|
164 @since 6.0 |
|
165 @param aPathSegment A descriptor with the initial path segment. |
|
166 @pre First phase of construction is complete. |
|
167 @post The object is fully constructed. |
|
168 */ |
|
169 void CDelimitedPathSegment8::ConstructL(const TDesC8& aPathSegment) |
|
170 { |
|
171 // Call base class ConstructL() |
|
172 CDelimitedDataBase8::ConstructL(aPathSegment); |
|
173 |
|
174 // Set the delimiter to ';' |
|
175 SetDelimiter(TChar(';')); |
|
176 } |
|
177 |
|
178 // |
|
179 // |
|
180 // Implemetation of CDelimitedPathSegment16 |
|
181 // |
|
182 // |
|
183 |
|
184 /** |
|
185 Static factory constructor. Uses two phase construction and leaves nothing on the |
|
186 CleanupStack. |
|
187 |
|
188 @since 6.0 |
|
189 @param aPathSegment A descriptor with the initial path segment. |
|
190 @return A pointer to created object. |
|
191 @post Nothing left on the CleanupStack. |
|
192 */ |
|
193 EXPORT_C CDelimitedPathSegment16* CDelimitedPathSegment16::NewL(const TDesC16& aPathSegment) |
|
194 { |
|
195 CDelimitedPathSegment16* self = NewLC(aPathSegment); |
|
196 CleanupStack::Pop(self); |
|
197 return self; |
|
198 } |
|
199 |
|
200 /** |
|
201 Static factory constructor. Uses two phase construction and leaves a pointer to created |
|
202 object on the CleanupStack. |
|
203 |
|
204 @since 6.0 |
|
205 @param aPathSegment A descriptor with the initial path segment. |
|
206 @return A pointer to created object. |
|
207 @post Pointer to created object left of CleanupStack. |
|
208 */ |
|
209 EXPORT_C CDelimitedPathSegment16* CDelimitedPathSegment16::NewLC(const TDesC16& aPathSegment) |
|
210 { |
|
211 CDelimitedPathSegment16* self = new (ELeave) CDelimitedPathSegment16; |
|
212 CleanupStack::PushL(self); |
|
213 self->ConstructL(aPathSegment); |
|
214 return self; |
|
215 } |
|
216 |
|
217 /** |
|
218 Destructor. |
|
219 |
|
220 @since 6.0 |
|
221 */ |
|
222 EXPORT_C CDelimitedPathSegment16::~CDelimitedPathSegment16() |
|
223 { |
|
224 } |
|
225 |
|
226 /** |
|
227 Escape encodes the parameter then inserts the escaped version in a position before the |
|
228 current parsed parameter. The new parameter should only contain a single path segment |
|
229 parameter, as any parameter delimiters in the parameter will be converted to an escape |
|
230 triple. The parser is left in a state where its current parameter is the same one as before |
|
231 the insertion. |
|
232 |
|
233 @since 6.0 |
|
234 @param aParam A descriptor with the unescaped path segment parameter |
|
235 @pre The path segment must have been initially parsed. |
|
236 @post The path segment will have been extended to include the new |
|
237 parameter. The current segment will remain as the one before the insertion. |
|
238 */ |
|
239 EXPORT_C void CDelimitedPathSegment16::InsertAndEscapeCurrentL(const TDesC16& aParam) |
|
240 { |
|
241 // Need to convert to utf8 first |
|
242 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam); |
|
243 CleanupStack::PushL(utf8); |
|
244 |
|
245 // Create escaped version of component |
|
246 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath); |
|
247 CleanupStack::PushL(escaped); |
|
248 |
|
249 // Convert back to 16-bits |
|
250 HBufC16* converted = HBufC16::NewLC(escaped->Length()); |
|
251 converted->Des().Copy(*escaped); |
|
252 |
|
253 // Insert the segment |
|
254 InsertCurrentL(*converted); |
|
255 |
|
256 // Cleanup |
|
257 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted |
|
258 } |
|
259 |
|
260 /** |
|
261 Escape encodes the parameter then inserts the escaped version at the back of the path |
|
262 segment. The new parameter should only contain a single path segment parameter, as any |
|
263 parameter delimiters in the parameter will be converted to an escape triple. The parser |
|
264 is left in a state where its current parameter is the same one as before the insertion. |
|
265 |
|
266 @warning A re-parse is required to ensure that the parser is valid. |
|
267 @since 6.0 |
|
268 @param aParam A descriptor with the unescaped path segment parameter. |
|
269 @pre The path segment must have been initially parsed. |
|
270 @post The path segment will have been extended to include the new |
|
271 parameter. The current segment will remain as the one before the insertion. |
|
272 */ |
|
273 EXPORT_C void CDelimitedPathSegment16::PushAndEscapeBackL(const TDesC16& aParam) |
|
274 { |
|
275 // Need to convert to utf8 first |
|
276 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam); |
|
277 CleanupStack::PushL(utf8); |
|
278 |
|
279 // Create escaped version of component |
|
280 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath); |
|
281 CleanupStack::PushL(escaped); |
|
282 |
|
283 // Convert back to 16-bits |
|
284 HBufC16* converted = HBufC16::NewLC(escaped->Length()); |
|
285 converted->Des().Copy(*escaped); |
|
286 |
|
287 // Insert the segment |
|
288 PushBackL(*converted); |
|
289 |
|
290 // Cleanup |
|
291 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted |
|
292 } |
|
293 |
|
294 /** |
|
295 Escape encodes the parameter then inserts the escaped version at the front of the |
|
296 path segment. The new parameter should only contain a single path segment parameter, |
|
297 as any parameter delimiters in the parameter will be converted to an escape triple. |
|
298 The parser is left in a state where its current parameter is the same one as before |
|
299 the insertion. |
|
300 |
|
301 @warning A re-parse is required to ensure that the parser is valid. |
|
302 @since 6.0 |
|
303 @param aParam A descriptor with the unescaped path segment parameter |
|
304 @pre The path segment must have been initially parsed. |
|
305 @post The path segment will have been extended to include the new |
|
306 parameter. The current segment will remain as the one before the insertion. |
|
307 */ |
|
308 EXPORT_C void CDelimitedPathSegment16::PushAndEscapeFrontL(const TDesC16& aParam) |
|
309 { |
|
310 // Need to convert to utf8 first |
|
311 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam); |
|
312 CleanupStack::PushL(utf8); |
|
313 |
|
314 // Create escaped version of component |
|
315 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath); |
|
316 CleanupStack::PushL(escaped); |
|
317 |
|
318 // Convert back to 16-bits |
|
319 HBufC16* converted = HBufC16::NewLC(escaped->Length()); |
|
320 converted->Des().Copy(*escaped); |
|
321 |
|
322 // Insert the segment |
|
323 PushFrontL(*converted); |
|
324 |
|
325 // Cleanup |
|
326 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted |
|
327 } |
|
328 |
|
329 /** |
|
330 Constructor. First phase of two-phase construction method. Does non-allocating |
|
331 construction. |
|
332 |
|
333 @since 6.0 |
|
334 */ |
|
335 CDelimitedPathSegment16::CDelimitedPathSegment16() |
|
336 : CDelimitedDataBase16() |
|
337 { |
|
338 } |
|
339 |
|
340 /** |
|
341 Second phase of two-phase construction method. Does any allocations required to |
|
342 fully construct the object. |
|
343 |
|
344 @since 6.0 |
|
345 @param aPathSegment A descriptor with the initial path segment. |
|
346 @pre First phase of construction is complete. |
|
347 @post The object is fully constructed. |
|
348 */ |
|
349 void CDelimitedPathSegment16::ConstructL(const TDesC16& aPathSegment) |
|
350 { |
|
351 // Call base class ConstructL() |
|
352 CDelimitedDataBase16::ConstructL(aPathSegment); |
|
353 |
|
354 // Set the delimiter to ';' |
|
355 SetDelimiter(TChar(';')); |
|
356 } |
|
357 |