os/ossrv/genericservices/httputils/UriParser/TEquiv.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericservices/httputils/UriParser/TEquiv.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,116 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// File contains internal classes for comparing two URIs to determine
    1.18 +// if they identify the same resource
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file TEquiv.h
    1.24 + @see Uri8.h
    1.25 +*/
    1.26 +
    1.27 +#ifndef __TEQUIV_H__
    1.28 +#define __TEQUIV_H__
    1.29 +
    1.30 +#include <uri8.h>
    1.31 +#include <delimitedparser8.h>
    1.32 +
    1.33 +/**
    1.34 +	Comments : 
    1.35 +	
    1.36 +	@internalComponent
    1.37 +	@released
    1.38 +*/
    1.39 +class TEquiv
    1.40 +	{
    1.41 +public:
    1.42 +	enum THeaderType
    1.43 +		{
    1.44 +		EHeaderNormal,
    1.45 +		EHeaderId,
    1.46 +		EHeaderContact,
    1.47 +		EHeaderEncoding,
    1.48 +		EHeaderLength,
    1.49 +		EHeaderType,
    1.50 +		EHeaderFrom,
    1.51 +		EHeaderSubject,
    1.52 +		EHeaderTo
    1.53 +		};
    1.54 +
    1.55 +public:
    1.56 +	TEquiv(const TUriC8& aLhs, const TUriC8& aRhs);
    1.57 +	TInt EquivalentL() const;
    1.58 +
    1.59 +protected:
    1.60 +	// Default implementation is for network schemes
    1.61 +	// Overide the following methods where appropriate for other schemes
    1.62 +	virtual TBool IsMatchSchemeL() const;
    1.63 +	virtual TBool IsMatchUserInfoL() const;
    1.64 +	virtual TBool IsMatchHostL() const;
    1.65 +	virtual TBool IsMatchPortL() const;
    1.66 +	virtual TBool IsMatchPathL() const;
    1.67 +	virtual TBool IsMatchQueryL() const;
    1.68 +	virtual TBool IsMatchFragmentL() const;
    1.69 +
    1.70 +	// general utility methods
    1.71 +	HBufC8* DecodedSegmentLC(const TUriC8& aUri, TUriComponent aSegmentType) const;
    1.72 +	inline TBool IsMatchCaseless(const TDesC8& aLhs, const TDesC8& aRhs) const;
    1.73 +	inline TBool IsMatchCaseSensitive(const TDesC8& aLhs, const TDesC8& aRhs) const;
    1.74 +
    1.75 +protected:
    1.76 +	const TUriC8& iLhs;
    1.77 +	const TUriC8& iRhs;
    1.78 +	};
    1.79 +
    1.80 +/**
    1.81 +	Comments : This class provides the functionality for Comparing SIP URIs.
    1.82 +	
    1.83 +	@internalComponent
    1.84 +	@released
    1.85 +*/
    1.86 +class TEquivSip: public TEquiv
    1.87 +	{
    1.88 +public:
    1.89 +	TEquivSip(const TUriC8& aLhs, const TUriC8& aRhs);
    1.90 +	// from TEquiv
    1.91 +private:
    1.92 +	virtual TBool IsMatchHostL() const;
    1.93 +	virtual TBool IsMatchPathL() const;
    1.94 +	virtual TBool IsMatchQueryL() const;
    1.95 +	virtual TBool IsMatchFragmentL() const;
    1.96 +
    1.97 +	// supporting methods
    1.98 +	void RemoveLeadingZeros(TPtr8 aHost) const;
    1.99 +	TBool IsMatchHostL(const TDesC8& aLhs, const TDesC8& aRhs) const;
   1.100 +	TBool IsParamCompatibleL(const TDesC8& aLhsName, const TDesC8& aLhsValue, const TDesC8& aRhsName, const TDesC8& aRhsValue) const;
   1.101 +	TBool IsParamListCompatibleL(const TDelimitedParserBase8& aLhsParser, const TDelimitedParserBase8& aRhsParser) const;
   1.102 +	TInt ListLength(const TDelimitedParserBase8& aParser) const;
   1.103 +	TBool HasMoreParameters(const TDelimitedParserBase8& aLhsParser, const TDelimitedParserBase8& aRhsParser) const;
   1.104 +	THeaderType HeaderType(const TDesC8& aHeaderName) const;
   1.105 +	TBool IsMatchHeader(const TDesC8& aLhs, const TDesC8& aRhs) const;
   1.106 +	TBool IsQueryListCompatible(const TDelimitedParserBase8& aLhsParser, const TDelimitedParserBase8& aRhsParser) const;
   1.107 +};
   1.108 +
   1.109 +inline TBool TEquiv::IsMatchCaseless(const TDesC8& aLhs, const TDesC8& aRhs) const
   1.110 +	{
   1.111 +	return (aLhs.CompareF(aRhs) == 0);
   1.112 +	}
   1.113 +
   1.114 +inline TBool TEquiv::IsMatchCaseSensitive(const TDesC8& aLhs, const TDesC8& aRhs) const
   1.115 +	{
   1.116 +	return (aLhs.Compare(aRhs) == 0);
   1.117 +	}
   1.118 +
   1.119 +#endif	// __TEQUIV_H__