diff -r 000000000000 -r 62f9d29f7211 webservices/wsutils/src/sensaxutils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webservices/wsutils/src/sensaxutils.cpp Thu Jan 07 16:19:19 2010 +0200 @@ -0,0 +1,551 @@ +/* +* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + + + + +// INCLUDE FILES +#include "sensaxutils.h" +#include + + +EXPORT_C TInt SenSaxUtils::SearchStartTagL(const TDesC8& aDocument, + const TDesC8& aLocalName, + TInt& aStartTagStart, + TInt& aStartTagEnd, + TPtrC8& aPrefix) + { + return SearchStartTagL(aDocument, aLocalName, aStartTagStart, aStartTagEnd, + aPrefix, EFalse); + } + + +EXPORT_C TInt SenSaxUtils::SearchStartTagL(const TDesC8& aDocument, + const TDesC8& aPrefix, + const TDesC8& aLocalName, + TInt& aStartTagStart, + TInt& aStartTagEnd) + { + TPtrC8 tmpPrefix(aPrefix); + return SearchStartTagL(aDocument, aLocalName, aStartTagStart, aStartTagEnd, + tmpPrefix, ETrue); + } + +EXPORT_C TInt SenSaxUtils::SearchEndTagL(const TDesC8& aDocument, + const TDesC8& aLocalName, + TInt& aEndTagStart, + TInt& aEndTagEnd, + TPtrC8& aPrefix) + { + return SearchEndTagL(aDocument, aLocalName, aEndTagStart, aEndTagEnd, + aPrefix, EFalse); + } + +EXPORT_C TInt SenSaxUtils::SearchEndTagL(const TDesC8& aDocument, + const TDesC8& aPrefix, + const TDesC8& aLocalName, + TInt& aEndTagStart, + TInt& aEndTagEnd) + { + TPtrC8 tmpPrefix(aPrefix); + return SearchEndTagL(aDocument, aLocalName, aEndTagStart, aEndTagEnd, + tmpPrefix, ETrue); + } + +TInt SenSaxUtils::SearchStartTagL(const TDesC8& aDocument, + const TDesC8& aLocalName, + TInt& aStartTagStart, + TInt& aStartTagEnd, + TPtrC8& aPrefix, + TBool aSearchPrefix = EFalse) + + { + TPtrC8 localNamePtr(KNullDesC8); + TPtrC8 stPrefixPtr(KNullDesC8); + + TInt i; + TBool tagFound(EFalse); + TInt colon(KErrNotFound); + TInt lessThan(KErrNotFound); + TInt space(KErrNotFound); + + TInt size = aDocument.Size()-(aLocalName.Size()+3); // <=> at least size-4 + TPtrC8 currentCharacter(KNullDesC8); + for (i = 0; i < size; i++) + { + currentCharacter.Set(aDocument.Ptr()+i,1); + + // ************* Handle Quotes <=> ' or " ******** // + if ( currentCharacter == KSenDblQuot ) // Check "\"" + { + i = SearchMarkStartingFromPlus(aDocument, KSenDblQuot, i+1, size); + if ( i == KErrNotFound ) + { + return i; + } + } + else if ( currentCharacter == KSenQuot ) // Check "'" + { + i = SearchMarkStartingFromPlus(aDocument, KSenQuot, i+1, size); + if ( i == KErrNotFound ) + { + return i; + } + } + else + { + // ************* Handle "<" ****************** // + if ( currentCharacter == KSenLessThan ) // Check "<" + { + currentCharacter.Set(aDocument.Ptr()+i,4); + // ************* Handle comments ********* // + if ( currentCharacter == KSenXmlCommentStart ) // Check "" + { + i-=3; + i = SearchStartOfCommentStartingFrom(aDocument, i); + if ( i == KErrNotFound ) + { + return i; + } + } + else + { + greaterThan = i; + colon = KErrNotFound; + } + } + // ************* Handle "<" ****************** // + else if ( currentCharacter == KSenLessThan ) // Check "<" + { + currentCharacter.Set(aDocument.Ptr()+i,2); + if ( currentCharacter == KSenXmlInstructionStart || // Check "= 0; i--) + { + currentCharacter.Set(aDocument.Ptr()+i,1); + if ( currentCharacter == aMark ) + { + return i; + } + } + + return KErrNotFound; + } + +TInt SenSaxUtils::SearchMatchingGreaterThanStartingFrom(const TDesC8& aDocument, + TInt position, + TInt size) + { + TInt lessThanCount = 1; + TPtrC8 currentCharacter; + + for (TInt i = position; i < size; i++) + { + currentCharacter.Set(aDocument.Ptr()+i,1); + + if ( currentCharacter == KSenDblQuot ) // Check "\"" + { + i = SearchMarkStartingFromPlus(aDocument, KSenDblQuot, i+1, size); + if ( i == KErrNotFound ) + { + return i; + } + } + else if ( currentCharacter == KSenQuot ) // Check "'" + { + i = SearchMarkStartingFromPlus(aDocument, KSenQuot, i+1, size); + if ( i == KErrNotFound ) + { + return i; + } + } + else + { + if ( currentCharacter == KSenLessThan ) // Check "<" + { + currentCharacter.Set(aDocument.Ptr()+i,4); + if ( currentCharacter == KSenXmlCommentStart ) // Check "" + { + return i; + } + } + } + + return KErrNotFound; + } + +TInt SenSaxUtils::SearchStartOfCommentStartingFrom(const TDesC8& aDocument, + TInt position) + { + TPtrC8 currentCharacter; + + for (TInt i = position; i >= 0; i--) + { + currentCharacter.Set(aDocument.Ptr()+i,1); + + if ( currentCharacter == KSenLessThan ) // Check "<" + { + currentCharacter.Set(aDocument.Ptr()+i,4); + if ( currentCharacter == KSenXmlCommentStart ) // Check "