Update contrib.
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 <delimitedquery8.h>
17 #include <delimitedquery16.h>
18 #include <escapeutils.h>
22 // Implemetation of CDelimitedQuery8
27 Static factory constructor. Uses two phase construction and leaves nothing on
31 @param aQuery A descriptor with the initial query.
32 @return A pointer to created object.
33 @post Nothing left on the CleanupStack.
35 EXPORT_C CDelimitedQuery8* CDelimitedQuery8::NewL(const TDesC8& aQuery)
37 CDelimitedQuery8* self = NewLC(aQuery);
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 aQuery A descriptor with the initial query.
48 @return A pointer to created object.
49 @post Pointer to created object left of CleanupStack.
51 EXPORT_C CDelimitedQuery8* CDelimitedQuery8::NewLC(const TDesC8& aQuery)
53 CDelimitedQuery8* self = new (ELeave) CDelimitedQuery8;
54 CleanupStack::PushL(self);
55 self->ConstructL(aQuery);
64 EXPORT_C CDelimitedQuery8::~CDelimitedQuery8()
69 Escape encodes segment then inserts the escaped version in a position before the
70 current parsed segment. The new segment should only contain a single query segment,
71 as any query delimiters in the segment will be converted to an escape triple. The
72 parser is left in a state where its current segment is the same one as before the
76 @param aSegment A descriptor with the unescaped query segment.
77 @pre The query must have been initially parsed.
78 @post The query will have been extended to include the new segment. The
79 current segment will remain as the one before the insertion.
81 EXPORT_C void CDelimitedQuery8::InsertAndEscapeCurrentL(const TDesC8& aSegment)
83 // Create escaped version of the segment
84 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aSegment, EscapeUtils::EEscapeQuery);
85 CleanupStack::PushL(escaped);
88 InsertCurrentL(*escaped);
91 CleanupStack::PopAndDestroy(escaped);
95 Escape encodes segment then inserts the escaped version at the back of the query.
96 The new segment should only contain a single query segment, as any query delimiters
97 in the segment will be converted to an escape triple. The parser is left in a state
98 where its current segment is the same one as before the insertion.
100 @warning A re-parse is required to ensure that the parser is valid.
102 @param aSegment A descriptor with the unescaped query segment.
103 @pre The delimiter must have been set.
104 @post The query will have been extended to include the new segment.
106 EXPORT_C void CDelimitedQuery8::PushAndEscapeBackL(const TDesC8& aSegment)
108 // Create escaped version of the segment
109 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aSegment, EscapeUtils::EEscapeQuery);
110 CleanupStack::PushL(escaped);
112 // Insert the segment
116 CleanupStack::PopAndDestroy(escaped);
120 Escape encodes segment then inserts the escaped version at the front of the query.
121 The new segment should only contain a single query segment, as any query delimiters
122 in the segment will be converted to an escape triple. The parser is left in a state
123 where its current segment is the same one as before the insertion.
125 @warning A re-parse is required to ensure that the parser is valid.
127 @param aSegment A descriptor with the unescaped query segment.
128 @pre The delimiter must have been set.
129 @post The query will have been extended to include the new segment.
131 EXPORT_C void CDelimitedQuery8::PushAndEscapeFrontL(const TDesC8& aSegment)
133 // Create escaped version of the segment
134 HBufC8* escaped = EscapeUtils::EscapeEncodeL(aSegment, EscapeUtils::EEscapeQuery);
135 CleanupStack::PushL(escaped);
137 // Insert the segment
138 PushFrontL(*escaped);
141 CleanupStack::PopAndDestroy(escaped);
145 Constructor. First phase of two-phase construction method. Does non-allocating
150 CDelimitedQuery8::CDelimitedQuery8()
151 : CDelimitedDataBase8()
156 Second phase of two-phase construction method. Does any allocations required to fully
157 construct the object.
160 @param aQuery A descriptor with the initial query.
161 @pre First phase of construction is complete.
162 @post The object is fully constructed.
164 void CDelimitedQuery8::ConstructL(const TDesC8& aQuery)
166 // Call base class ConstructL()
167 CDelimitedDataBase8::ConstructL(aQuery);
169 // Set the delimiter to '&'
170 SetDelimiter(TChar('&'));
175 // Implemetation of CDelimitedQuery16
180 Static factory constructor. Uses two phase construction and leaves nothing on the
184 @param aQuery A descriptor with the initial query.
185 @return A pointer to created object.
186 @post Nothing left on the CleanupStack.
188 EXPORT_C CDelimitedQuery16* CDelimitedQuery16::NewL(const TDesC16& aQuery)
190 CDelimitedQuery16* self = NewLC(aQuery);
191 CleanupStack::Pop(self);
197 Static factory constructor. Uses two phase construction and leaves a pointer to created object on the CleanupStack.
200 @param aQuery A descriptor with the initial query.
201 @return A pointer to created object.
202 @post Pointer to created object left of CleanupStack.
204 EXPORT_C CDelimitedQuery16* CDelimitedQuery16::NewLC(const TDesC16& aQuery)
206 CDelimitedQuery16* self = new (ELeave) CDelimitedQuery16;
207 CleanupStack::PushL(self);
208 self->ConstructL(aQuery);
217 EXPORT_C CDelimitedQuery16::~CDelimitedQuery16()
222 Escape encodes segment then inserts the escaped version in a position before the
223 current parsed segment. The new segment should only contain a single query segment,
224 as any query delimiters in the segment will be converted to an escape triple. The
225 parser is left in a state where its current segment is the same one as before the
229 @param aSegment A descriptor with the unescaped query segment.
230 @pre The query must have been initially parsed.
231 @post The query will have been extended to include the new segment. The
232 current segment will remain as the one before the insertion.
234 EXPORT_C void CDelimitedQuery16::InsertAndEscapeCurrentL(const TDesC16& aSegment)
236 // Need to convert to utf8 first
237 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aSegment);
238 CleanupStack::PushL(utf8);
240 // Create escaped version of component
241 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath);
242 CleanupStack::PushL(escaped);
244 // Convert back to 16-bits
245 HBufC16* converted = HBufC16::NewLC(escaped->Length());
246 converted->Des().Copy(*escaped);
248 // Insert the segment
249 InsertCurrentL(*converted);
252 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted
256 Escape encodes segment then inserts the escaped version at the back of the query.
257 The new segment should only contain a single query segment, as any query delimiters
258 in the segment will be converted to an escape triple. The parser is left in a state
259 where its current segment is the same one as before the insertion.
261 @warning A re-parse is required to ensure that the parser is valid.
263 @param aSegment A descriptor with the unescaped query segment.
264 @pre The delimiter must have been set.
265 @post The query will have been extended to include the new segment.
267 EXPORT_C void CDelimitedQuery16::PushAndEscapeBackL(const TDesC16& aSegment)
269 // Need to convert to utf8 first
270 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aSegment);
271 CleanupStack::PushL(utf8);
273 // Create escaped version of component
274 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath);
275 CleanupStack::PushL(escaped);
277 // Convert back to 16-bits
278 HBufC16* converted = HBufC16::NewLC(escaped->Length());
279 converted->Des().Copy(*escaped);
281 // Insert the segment
282 PushBackL(*converted);
285 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted
289 Escape encodes segment then inserts the escaped version at the front of the query.
290 The new segment should only contain a single query segment, as any query delimiters
291 in the segment will be converted to an escape triple. The parser is left in a state
292 where its current segment is the same one as before the insertion.
294 @warning A re-parse is required to ensure that the parser is valid.
296 @param aSegment A descriptor with the unescaped query segment.
297 @pre The delimiter must have been set.
298 @post The query will have been extended to include the new segment.
300 EXPORT_C void CDelimitedQuery16::PushAndEscapeFrontL(const TDesC16& aSegment)
302 // Need to convert to utf8 first
303 HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aSegment);
304 CleanupStack::PushL(utf8);
306 // Create escaped version of component
307 HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath);
308 CleanupStack::PushL(escaped);
310 // Convert back to 16-bits
311 HBufC16* converted = HBufC16::NewLC(escaped->Length());
312 converted->Des().Copy(*escaped);
314 // Insert the segment
315 PushFrontL(*converted);
318 CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted
322 Constructor. First phase of two-phase construction method. Does non-allocating construction.
326 CDelimitedQuery16::CDelimitedQuery16()
327 : CDelimitedDataBase16()
332 Second phase of two-phase construction method. Does any allocations required to fully
333 construct the object.
336 @param aQuery A descriptor with the initial query.
337 @pre First phase of construction is complete.
338 @post The object is fully constructed.
340 void CDelimitedQuery16::ConstructL(const TDesC16& aQuery)
342 // Call base class ConstructL()
343 CDelimitedDataBase16::ConstructL(aQuery);
345 // Set the delimiter to '&'
346 SetDelimiter(TChar('&'));