sl@0: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: // sl@0: // sl@0: // Implemetation of CDelimitedPathSegment8 sl@0: // sl@0: // sl@0: sl@0: /** sl@0: Static factory constructor. Uses two phase construction and leaves nothing on sl@0: the CleanupStack. sl@0: sl@0: @since 6.0 sl@0: @param aPathSegment A descriptor with the initial path segment. sl@0: @return A pointer to created object. sl@0: @post Nothing left on the CleanupStack. sl@0: */ sl@0: EXPORT_C CDelimitedPathSegment8* CDelimitedPathSegment8::NewL(const TDesC8& aPathSegment) sl@0: { sl@0: CDelimitedPathSegment8* self = NewLC(aPathSegment); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: Static factory constructor. Uses two phase construction and leaves a pointer to sl@0: created object on the CleanupStack. sl@0: sl@0: @since 6.0 sl@0: @param aPathSegment A descriptor with the initial path segment. sl@0: @return A pointer to created object. sl@0: @post Pointer to created object left of CleanupStack. sl@0: */ sl@0: EXPORT_C CDelimitedPathSegment8* CDelimitedPathSegment8::NewLC(const TDesC8& aPathSegment) sl@0: { sl@0: CDelimitedPathSegment8* self = new (ELeave) CDelimitedPathSegment8; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aPathSegment); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: Destructor. sl@0: sl@0: @since 6.0 sl@0: */ sl@0: EXPORT_C CDelimitedPathSegment8::~CDelimitedPathSegment8() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: sl@0: Escape encodes the parameter then inserts the escaped version in a position before the sl@0: current parsed parameter. The new parameter should only contain a single path segment sl@0: parameter, as any parameter delimiters in the parameter will be converted to an escape sl@0: triple. The parser is left in a state where its current parameter is the same one as before sl@0: the insertion. sl@0: sl@0: @since 6.0 sl@0: @param aParam A descriptor with the unescaped path segment parameter sl@0: @pre The path segment must have been initially parsed. sl@0: @post The path segment will have been extended to include the new sl@0: parameter. The current segment will remain as the one before the insertion. sl@0: */ sl@0: EXPORT_C void CDelimitedPathSegment8::InsertAndEscapeCurrentL(const TDesC8& aParam) sl@0: { sl@0: // Create escaped version of the parameter sl@0: HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath); sl@0: CleanupStack::PushL(escaped); sl@0: sl@0: // Insert the segment sl@0: InsertCurrentL(*escaped); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy(escaped); sl@0: } sl@0: sl@0: /** sl@0: Escape encodes the parameter then inserts the escaped version at the front of the sl@0: path segment. The new parameter should only contain a single path segment parameter, sl@0: as any parameter delimiters in the parameter will be converted to an escape triple. sl@0: The parser is left in a state where its current parameter is the same one as before sl@0: the insertion. sl@0: sl@0: @warning A re-parse is required to ensure that the parser is valid. sl@0: @since 6.0 sl@0: @param aParam A descriptor with the unescaped path segment parameter sl@0: @pre The path segment must have been initially parsed. sl@0: @post The path segment will have been extended to include the new sl@0: parameter. The current segment will remain as the one before the insertion. sl@0: */ sl@0: EXPORT_C void CDelimitedPathSegment8::PushAndEscapeBackL(const TDesC8& aParam) sl@0: { sl@0: // Create escaped version of the parameter sl@0: HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath); sl@0: CleanupStack::PushL(escaped); sl@0: sl@0: // Insert the segment sl@0: PushBackL(*escaped); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy(escaped); sl@0: } sl@0: sl@0: /** sl@0: Escape encodes the parameter then inserts the escaped version at the back of the sl@0: path segment. The new parameter should only contain a single path segment parameter, sl@0: as any parameter delimiters in the parameter will be converted to an escape triple. sl@0: The parser is left in a state where its current parameter is the same one as before sl@0: the insertion. sl@0: sl@0: @warning A re-parse is required to ensure that the parser is valid. sl@0: @since 6.0 sl@0: @param aParam A descriptor with the unescaped path segment parameter. sl@0: @pre The path segment must have been initially parsed. sl@0: @post The path segment will have been extended to include the new sl@0: parameter. The current segment will remain as the one before the insertion. sl@0: */ sl@0: EXPORT_C void CDelimitedPathSegment8::PushAndEscapeFrontL(const TDesC8& aParam) sl@0: { sl@0: // Create escaped version of the parameter sl@0: HBufC8* escaped = EscapeUtils::EscapeEncodeL(aParam, EscapeUtils::EEscapePath); sl@0: CleanupStack::PushL(escaped); sl@0: sl@0: // Insert the segment sl@0: PushFrontL(*escaped); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy(escaped); sl@0: } sl@0: sl@0: /** sl@0: Constructor. First phase of two-phase construction method. Does non-allocating sl@0: construction. sl@0: sl@0: @since 6.0 sl@0: */ sl@0: CDelimitedPathSegment8::CDelimitedPathSegment8() sl@0: : CDelimitedDataBase8() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Second phase of two-phase construction method. Does any allocations required to sl@0: fully construct the object. sl@0: sl@0: @since 6.0 sl@0: @param aPathSegment A descriptor with the initial path segment. sl@0: @pre First phase of construction is complete. sl@0: @post The object is fully constructed. sl@0: */ sl@0: void CDelimitedPathSegment8::ConstructL(const TDesC8& aPathSegment) sl@0: { sl@0: // Call base class ConstructL() sl@0: CDelimitedDataBase8::ConstructL(aPathSegment); sl@0: sl@0: // Set the delimiter to ';' sl@0: SetDelimiter(TChar(';')); sl@0: } sl@0: sl@0: // sl@0: // sl@0: // Implemetation of CDelimitedPathSegment16 sl@0: // sl@0: // sl@0: sl@0: /** sl@0: Static factory constructor. Uses two phase construction and leaves nothing on the sl@0: CleanupStack. sl@0: sl@0: @since 6.0 sl@0: @param aPathSegment A descriptor with the initial path segment. sl@0: @return A pointer to created object. sl@0: @post Nothing left on the CleanupStack. sl@0: */ sl@0: EXPORT_C CDelimitedPathSegment16* CDelimitedPathSegment16::NewL(const TDesC16& aPathSegment) sl@0: { sl@0: CDelimitedPathSegment16* self = NewLC(aPathSegment); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: Static factory constructor. Uses two phase construction and leaves a pointer to created sl@0: object on the CleanupStack. sl@0: sl@0: @since 6.0 sl@0: @param aPathSegment A descriptor with the initial path segment. sl@0: @return A pointer to created object. sl@0: @post Pointer to created object left of CleanupStack. sl@0: */ sl@0: EXPORT_C CDelimitedPathSegment16* CDelimitedPathSegment16::NewLC(const TDesC16& aPathSegment) sl@0: { sl@0: CDelimitedPathSegment16* self = new (ELeave) CDelimitedPathSegment16; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aPathSegment); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: Destructor. sl@0: sl@0: @since 6.0 sl@0: */ sl@0: EXPORT_C CDelimitedPathSegment16::~CDelimitedPathSegment16() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Escape encodes the parameter then inserts the escaped version in a position before the sl@0: current parsed parameter. The new parameter should only contain a single path segment sl@0: parameter, as any parameter delimiters in the parameter will be converted to an escape sl@0: triple. The parser is left in a state where its current parameter is the same one as before sl@0: the insertion. sl@0: sl@0: @since 6.0 sl@0: @param aParam A descriptor with the unescaped path segment parameter sl@0: @pre The path segment must have been initially parsed. sl@0: @post The path segment will have been extended to include the new sl@0: parameter. The current segment will remain as the one before the insertion. sl@0: */ sl@0: EXPORT_C void CDelimitedPathSegment16::InsertAndEscapeCurrentL(const TDesC16& aParam) sl@0: { sl@0: // Need to convert to utf8 first sl@0: HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam); sl@0: CleanupStack::PushL(utf8); sl@0: sl@0: // Create escaped version of component sl@0: HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath); sl@0: CleanupStack::PushL(escaped); sl@0: sl@0: // Convert back to 16-bits sl@0: HBufC16* converted = HBufC16::NewLC(escaped->Length()); sl@0: converted->Des().Copy(*escaped); sl@0: sl@0: // Insert the segment sl@0: InsertCurrentL(*converted); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted sl@0: } sl@0: sl@0: /** sl@0: Escape encodes the parameter then inserts the escaped version at the back of the path sl@0: segment. The new parameter should only contain a single path segment parameter, as any sl@0: parameter delimiters in the parameter will be converted to an escape triple. The parser sl@0: is left in a state where its current parameter is the same one as before the insertion. sl@0: sl@0: @warning A re-parse is required to ensure that the parser is valid. sl@0: @since 6.0 sl@0: @param aParam A descriptor with the unescaped path segment parameter. sl@0: @pre The path segment must have been initially parsed. sl@0: @post The path segment will have been extended to include the new sl@0: parameter. The current segment will remain as the one before the insertion. sl@0: */ sl@0: EXPORT_C void CDelimitedPathSegment16::PushAndEscapeBackL(const TDesC16& aParam) sl@0: { sl@0: // Need to convert to utf8 first sl@0: HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam); sl@0: CleanupStack::PushL(utf8); sl@0: sl@0: // Create escaped version of component sl@0: HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath); sl@0: CleanupStack::PushL(escaped); sl@0: sl@0: // Convert back to 16-bits sl@0: HBufC16* converted = HBufC16::NewLC(escaped->Length()); sl@0: converted->Des().Copy(*escaped); sl@0: sl@0: // Insert the segment sl@0: PushBackL(*converted); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted sl@0: } sl@0: sl@0: /** sl@0: Escape encodes the parameter then inserts the escaped version at the front of the sl@0: path segment. The new parameter should only contain a single path segment parameter, sl@0: as any parameter delimiters in the parameter will be converted to an escape triple. sl@0: The parser is left in a state where its current parameter is the same one as before sl@0: the insertion. sl@0: sl@0: @warning A re-parse is required to ensure that the parser is valid. sl@0: @since 6.0 sl@0: @param aParam A descriptor with the unescaped path segment parameter sl@0: @pre The path segment must have been initially parsed. sl@0: @post The path segment will have been extended to include the new sl@0: parameter. The current segment will remain as the one before the insertion. sl@0: */ sl@0: EXPORT_C void CDelimitedPathSegment16::PushAndEscapeFrontL(const TDesC16& aParam) sl@0: { sl@0: // Need to convert to utf8 first sl@0: HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aParam); sl@0: CleanupStack::PushL(utf8); sl@0: sl@0: // Create escaped version of component sl@0: HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapePath); sl@0: CleanupStack::PushL(escaped); sl@0: sl@0: // Convert back to 16-bits sl@0: HBufC16* converted = HBufC16::NewLC(escaped->Length()); sl@0: converted->Des().Copy(*escaped); sl@0: sl@0: // Insert the segment sl@0: PushFrontL(*converted); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy(3, utf8); // utf8, escaped, converted sl@0: } sl@0: sl@0: /** sl@0: Constructor. First phase of two-phase construction method. Does non-allocating sl@0: construction. sl@0: sl@0: @since 6.0 sl@0: */ sl@0: CDelimitedPathSegment16::CDelimitedPathSegment16() sl@0: : CDelimitedDataBase16() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Second phase of two-phase construction method. Does any allocations required to sl@0: fully construct the object. sl@0: sl@0: @since 6.0 sl@0: @param aPathSegment A descriptor with the initial path segment. sl@0: @pre First phase of construction is complete. sl@0: @post The object is fully constructed. sl@0: */ sl@0: void CDelimitedPathSegment16::ConstructL(const TDesC16& aPathSegment) sl@0: { sl@0: // Call base class ConstructL() sl@0: CDelimitedDataBase16::ConstructL(aPathSegment); sl@0: sl@0: // Set the delimiter to ';' sl@0: SetDelimiter(TChar(';')); sl@0: } sl@0: