os/ossrv/genericservices/httputils/UriParser/TEquiv.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2004-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 // File contains internal classes for comparing two URIs to determine
    15 // if they identify the same resource
    16 // 
    17 //
    18 
    19 /**
    20  @file TEquiv.h
    21  @see Uri8.h
    22 */
    23 
    24 #ifndef __TEQUIV_H__
    25 #define __TEQUIV_H__
    26 
    27 #include <uri8.h>
    28 #include <delimitedparser8.h>
    29 
    30 /**
    31 	Comments : 
    32 	
    33 	@internalComponent
    34 	@released
    35 */
    36 class TEquiv
    37 	{
    38 public:
    39 	enum THeaderType
    40 		{
    41 		EHeaderNormal,
    42 		EHeaderId,
    43 		EHeaderContact,
    44 		EHeaderEncoding,
    45 		EHeaderLength,
    46 		EHeaderType,
    47 		EHeaderFrom,
    48 		EHeaderSubject,
    49 		EHeaderTo
    50 		};
    51 
    52 public:
    53 	TEquiv(const TUriC8& aLhs, const TUriC8& aRhs);
    54 	TInt EquivalentL() const;
    55 
    56 protected:
    57 	// Default implementation is for network schemes
    58 	// Overide the following methods where appropriate for other schemes
    59 	virtual TBool IsMatchSchemeL() const;
    60 	virtual TBool IsMatchUserInfoL() const;
    61 	virtual TBool IsMatchHostL() const;
    62 	virtual TBool IsMatchPortL() const;
    63 	virtual TBool IsMatchPathL() const;
    64 	virtual TBool IsMatchQueryL() const;
    65 	virtual TBool IsMatchFragmentL() const;
    66 
    67 	// general utility methods
    68 	HBufC8* DecodedSegmentLC(const TUriC8& aUri, TUriComponent aSegmentType) const;
    69 	inline TBool IsMatchCaseless(const TDesC8& aLhs, const TDesC8& aRhs) const;
    70 	inline TBool IsMatchCaseSensitive(const TDesC8& aLhs, const TDesC8& aRhs) const;
    71 
    72 protected:
    73 	const TUriC8& iLhs;
    74 	const TUriC8& iRhs;
    75 	};
    76 
    77 /**
    78 	Comments : This class provides the functionality for Comparing SIP URIs.
    79 	
    80 	@internalComponent
    81 	@released
    82 */
    83 class TEquivSip: public TEquiv
    84 	{
    85 public:
    86 	TEquivSip(const TUriC8& aLhs, const TUriC8& aRhs);
    87 	// from TEquiv
    88 private:
    89 	virtual TBool IsMatchHostL() const;
    90 	virtual TBool IsMatchPathL() const;
    91 	virtual TBool IsMatchQueryL() const;
    92 	virtual TBool IsMatchFragmentL() const;
    93 
    94 	// supporting methods
    95 	void RemoveLeadingZeros(TPtr8 aHost) const;
    96 	TBool IsMatchHostL(const TDesC8& aLhs, const TDesC8& aRhs) const;
    97 	TBool IsParamCompatibleL(const TDesC8& aLhsName, const TDesC8& aLhsValue, const TDesC8& aRhsName, const TDesC8& aRhsValue) const;
    98 	TBool IsParamListCompatibleL(const TDelimitedParserBase8& aLhsParser, const TDelimitedParserBase8& aRhsParser) const;
    99 	TInt ListLength(const TDelimitedParserBase8& aParser) const;
   100 	TBool HasMoreParameters(const TDelimitedParserBase8& aLhsParser, const TDelimitedParserBase8& aRhsParser) const;
   101 	THeaderType HeaderType(const TDesC8& aHeaderName) const;
   102 	TBool IsMatchHeader(const TDesC8& aLhs, const TDesC8& aRhs) const;
   103 	TBool IsQueryListCompatible(const TDelimitedParserBase8& aLhsParser, const TDelimitedParserBase8& aRhsParser) const;
   104 };
   105 
   106 inline TBool TEquiv::IsMatchCaseless(const TDesC8& aLhs, const TDesC8& aRhs) const
   107 	{
   108 	return (aLhs.CompareF(aRhs) == 0);
   109 	}
   110 
   111 inline TBool TEquiv::IsMatchCaseSensitive(const TDesC8& aLhs, const TDesC8& aRhs) const
   112 	{
   113 	return (aLhs.Compare(aRhs) == 0);
   114 	}
   115 
   116 #endif	// __TEQUIV_H__