javacommons/gcfbase/inc.s60/turi.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TURI_H
       
    20 #define TURI_H
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 
       
    25 
       
    26 /**
       
    27  * A generic class for parsing the parts of URI's.
       
    28  *
       
    29  * NOTE: This uses the folding version of some descriptor methods, which has the
       
    30  * undesired affect of removing the distinctions between characters with and without
       
    31  * accents, etc. This is not good, but we do not want to implement our own
       
    32  * comparison ignoring case.
       
    33  */
       
    34 class TUri : public TPtrC16
       
    35 {
       
    36 public:
       
    37     static TBool IsUri(const TDesC16& aName);
       
    38 
       
    39 public:
       
    40     TInt Parse(const TDesC16& aDes, TBool aCheckForSlashes = EFalse);
       
    41     inline const TDesC16& Scheme() const;
       
    42     inline const TDesC16& Host() const;
       
    43     inline const TDesC16& Port() const;
       
    44     inline const TDesC16& Path() const;
       
    45     inline const TDesC16& Query() const;
       
    46     inline const TDesC16& Parameters() const;
       
    47     TInt PortAsUint(TUint& aPortNum) const;
       
    48     TInt GetParameterValue(const TDesC16& aParamName, TBool& aValue) const;
       
    49     TInt GetParameterValueInt(const TDesC16& aParamName, TInt& aValue) const;
       
    50     TInt GetParameterValue(const TDesC16& aParamName, TPtrC16& aValue) const;
       
    51     TInt CheckParameterValidity(const RPointerArray<TDesC16>& aParamNames) const;
       
    52     TInt CheckNoDuplicateParameters() const;
       
    53 
       
    54 private:
       
    55     TInt FindParamNameIndex(const TDesC16& aParamName,
       
    56                             const TDesC16& aParametersSegment) const;
       
    57     TInt CheckParameter(const RPointerArray<TDesC>& aParamNames,
       
    58                         const TDesC16& aRemainder) const;
       
    59     static TBool MatchParamName(const TDesC16& aName1, const TDesC16& aName2);
       
    60     static TBool MatchParamNamePtr(const TPtrC16& aName1, const TPtrC16& aName2);
       
    61 
       
    62 private:
       
    63     TPtrC16 iScheme;
       
    64     TPtrC16 iSchemeData;
       
    65     TPtrC16 iHost;
       
    66     TPtrC16 iPort;
       
    67     TPtrC16 iPath;
       
    68     TPtrC16 iParameters;
       
    69     TPtrC16 iQuery;
       
    70 };
       
    71 
       
    72 
       
    73 
       
    74 inline const TDesC16& TUri::Scheme() const
       
    75 {
       
    76     return iScheme;
       
    77 }
       
    78 inline const TDesC16& TUri::Host() const
       
    79 {
       
    80     return iHost;
       
    81 }
       
    82 inline const TDesC16& TUri::Port() const
       
    83 {
       
    84     return iPort;
       
    85 }
       
    86 inline const TDesC16& TUri::Path() const
       
    87 {
       
    88     return iPath;
       
    89 }
       
    90 inline const TDesC16& TUri::Query() const
       
    91 {
       
    92     return iQuery;
       
    93 }
       
    94 inline const TDesC16& TUri::Parameters() const
       
    95 {
       
    96     return iParameters;
       
    97 }
       
    98 
       
    99 
       
   100 
       
   101 #endif // TURI_H
       
   102 
       
   103