First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <delimitedpathsegment8.h>
17 #include <delimitedpathsegment16.h>
18 #include <escapeutils.h>
22 // Implemetation of CDelimitedPathSegment8
27 Static factory constructor. Uses two phase construction and leaves nothing on
31 @param aPathSegment A descriptor with the initial path segment.
32 @return A pointer to created object.
33 @post Nothing left on the CleanupStack.
35 EXPORT_C CDelimitedPathSegment8* CDelimitedPathSegment8::NewL(const TDesC8& aPathSegment)
37 CDelimitedPathSegment8* self = NewLC(aPathSegment);
38 CleanupStack::Pop(self);
43 Static factory constructor. Uses two phase construction and leaves a pointer to
44 created object on the CleanupStack.
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.
51 EXPORT_C CDelimitedPathSegment8* CDelimitedPathSegment8::NewLC(const TDesC8& aPathSegment)
53 CDelimitedPathSegment8* self = new (ELeave) CDelimitedPathSegment8;
54 CleanupStack::PushL(self);
55 self->ConstructL(aPathSegment);
64 EXPORT_C CDelimitedPathSegment8::~CDelimitedPathSegment8()
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
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.
82 EXPORT_C void CDelimitedPathSegment8::InsertAndEscapeCurrentL(const TDesC8& aParam)
84 // Create escaped version of the parameter
85 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath);
86 CleanupStack::PushL(escaped);
89 InsertCurrentL(*escaped);
92 CleanupStack::PopAndDestroy(escaped);
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
102 @warning A re-parse is required to ensure that the parser is valid.
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.
109 EXPORT_C void CDelimitedPathSegment8::PushAndEscapeBackL(const TDesC8& aParam)
111 // Create escaped version of the parameter
112 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath);
113 CleanupStack::PushL(escaped);
115 // Insert the segment
119 CleanupStack::PopAndDestroy(escaped);
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
129 @warning A re-parse is required to ensure that the parser is valid.
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.
136 EXPORT_C void CDelimitedPathSegment8::PushAndEscapeFrontL(const TDesC8& aParam)
138 // Create escaped version of the parameter
139 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath);
140 CleanupStack::PushL(escaped);
142 // Insert the segment
143 PushFrontL(*escaped);
146 CleanupStack::PopAndDestroy(escaped);
150 Constructor. First phase of two-phase construction method. Does non-allocating
155 CDelimitedPathSegment8::CDelimitedPathSegment8()
156 : CDelimitedDataBase8()
161 Second phase of two-phase construction method. Does any allocations required to
162 fully construct the object.
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.
169 void CDelimitedPathSegment8::ConstructL(const TDesC8& aPathSegment)
171 // Call base class ConstructL()
172 CDelimitedDataBase8::ConstructL(aPathSegment);
174 // Set the delimiter to ';'
175 SetDelimiter(TChar(';'));
180 // Implemetation of CDelimitedPathSegment16
185 Static factory constructor. Uses two phase construction and leaves nothing on the
189 @param aPathSegment A descriptor with the initial path segment.
190 @return A pointer to created object.
191 @post Nothing left on the CleanupStack.
193 EXPORT_C CDelimitedPathSegment16* CDelimitedPathSegment16::NewL(const TDesC16& aPathSegment)
195 CDelimitedPathSegment16* self = NewLC(aPathSegment);
196 CleanupStack::Pop(self);
201 Static factory constructor. Uses two phase construction and leaves a pointer to created
202 object on the CleanupStack.
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.
209 EXPORT_C CDelimitedPathSegment16* CDelimitedPathSegment16::NewLC(const TDesC16& aPathSegment)
211 CDelimitedPathSegment16* self = new (ELeave) CDelimitedPathSegment16;
212 CleanupStack::PushL(self);
213 self->ConstructL(aPathSegment);
222 EXPORT_C CDelimitedPathSegment16::~CDelimitedPathSegment16()
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
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.
239 EXPORT_C void CDelimitedPathSegment16::InsertAndEscapeCurrentL(const TDesC16& aParam)
241 // Need to convert to utf8 first
242 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam);
243 CleanupStack::PushL(utf8);
245 // Create escaped version of component
246 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath);
247 CleanupStack::PushL(escaped);
249 // Convert back to 16-bits
250 HBufC16* converted = HBufC16::NewLC(escaped->Length());
251 converted->Des().Copy(*escaped);
253 // Insert the segment
254 InsertCurrentL(*converted);
257 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted
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.
266 @warning A re-parse is required to ensure that the parser is valid.
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.
273 EXPORT_C void CDelimitedPathSegment16::PushAndEscapeBackL(const TDesC16& aParam)
275 // Need to convert to utf8 first
276 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam);
277 CleanupStack::PushL(utf8);
279 // Create escaped version of component
280 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath);
281 CleanupStack::PushL(escaped);
283 // Convert back to 16-bits
284 HBufC16* converted = HBufC16::NewLC(escaped->Length());
285 converted->Des().Copy(*escaped);
287 // Insert the segment
288 PushBackL(*converted);
291 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted
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
301 @warning A re-parse is required to ensure that the parser is valid.
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.
308 EXPORT_C void CDelimitedPathSegment16::PushAndEscapeFrontL(const TDesC16& aParam)
310 // Need to convert to utf8 first
311 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam);
312 CleanupStack::PushL(utf8);
314 // Create escaped version of component
315 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath);
316 CleanupStack::PushL(escaped);
318 // Convert back to 16-bits
319 HBufC16* converted = HBufC16::NewLC(escaped->Length());
320 converted->Des().Copy(*escaped);
322 // Insert the segment
323 PushFrontL(*converted);
326 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted
330 Constructor. First phase of two-phase construction method. Does non-allocating
335 CDelimitedPathSegment16::CDelimitedPathSegment16()
336 : CDelimitedDataBase16()
341 Second phase of two-phase construction method. Does any allocations required to
342 fully construct the object.
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.
349 void CDelimitedPathSegment16::ConstructL(const TDesC16& aPathSegment)
351 // Call base class ConstructL()
352 CDelimitedDataBase16::ConstructL(aPathSegment);
354 // Set the delimiter to ';'
355 SetDelimiter(TChar(';'));