genericservices/httputils/UriParser/GenericUriParser.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2007-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 // This file contains the Parsing functionality for Generic URIs as 
       
    15 // specified in RFC 2396.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file GenericUriParser.h
       
    21 */
       
    22 #ifndef __GENERICURIPARSER_H__
       
    23 #define __GENERICURIPARSER_H__
       
    24 
       
    25 // System includes
       
    26 #include <e32base.h>
       
    27 #include <uriutilscommon.h>
       
    28 
       
    29 // Local includes
       
    30 #include "TUriParserInternal.h"
       
    31 #include "UriUtilsInternal.h"
       
    32 
       
    33 /**
       
    34 	Dependencies : CUriParserBase.
       
    35 	Comments : Provides Parsing functionality for the Uri objects.
       
    36 	This is implemented as per RFC2396 for Parsing the Generic Uris. 
       
    37 	It uses 8-bit descriptors.
       
    38 
       
    39 	@internalComponent
       
    40 	@released
       
    41 */
       
    42 class CGenericUriParser: public CBase
       
    43 	{
       
    44 public:	
       
    45 
       
    46 	static CGenericUriParser* NewL();
       
    47 	virtual ~CGenericUriParser();
       
    48     inline void DoParseUri(const TPtrC8& aUri, TPtrC8 aComponent[]);
       
    49 
       
    50 protected:	
       
    51 
       
    52 	CGenericUriParser();
       
    53 	void ConstructL();
       
    54 
       
    55 	virtual TInt ParseScheme(const TPtrC8& aUri, TPtrC8& aScheme);
       
    56 	virtual TInt ParseAuthority(const TPtrC8& aUri, TPtrC8& aUserinfo, TPtrC8& aHost, TPtrC8& aPort, TBool aUseNetworkDelimiter);
       
    57 	virtual TInt ParsePath(const TPtrC8& aUri, TPtrC8& aPath);
       
    58 	virtual TInt ParseQuery(const TPtrC8& aUri, TPtrC8& aQuery);
       
    59 	virtual TInt ParseFragment(const TPtrC8& aUri, TPtrC8& aFragment);
       
    60 
       
    61 	//Internal Supporting method for Parsing
       
    62 	virtual TInt FindFirstUriDelimiter(const TPtrC8& aString, TDelimiterSearchFlag aSearchFlag);
       
    63 	};
       
    64 
       
    65 inline void CGenericUriParser::DoParseUri(const TPtrC8& aUri, TPtrC8 aComponent[])
       
    66 	{
       
    67 	// Parse the components
       
    68 	TPtrC8 uri(aUri);
       
    69 	TInt consumed = 0;
       
    70 	TPtrC8& scheme = aComponent[EUriScheme];
       
    71 	if( (consumed = ParseScheme(uri, scheme)) > 0 )
       
    72 		{
       
    73 		uri.Set(uri.Mid(consumed));
       
    74 		}
       
    75 	if( (consumed = ParseAuthority(uri, aComponent[EUriUserinfo], 
       
    76 		 aComponent[EUriHost], aComponent[EUriPort], IsNetworkScheme(scheme) )) > 0 )
       
    77 		{
       
    78 		uri.Set(uri.Mid(consumed));
       
    79 		}
       
    80 	if( (consumed = ParsePath(uri, aComponent[EUriPath])) > 0 )
       
    81 		{
       
    82 		uri.Set(uri.Mid(consumed));
       
    83 		}
       
    84 	if( (consumed = ParseQuery(uri, aComponent[EUriQuery])) > 0 )
       
    85 		{
       
    86 		uri.Set(uri.Mid(consumed));
       
    87 		}
       
    88 	if( (consumed = ParseFragment(uri, aComponent[EUriFragment])) > 0 )
       
    89 		{
       
    90 		uri.Set(uri.Mid(consumed));
       
    91 		}
       
    92 	}
       
    93 
       
    94 #endif	// __GENERICURIPARSER_H__
       
    95