Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TUri.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/base:$Id$
0002 // Author: Gerhard E. Bruckner 15/07/07
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TUri
0013 #define ROOT_TUri
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TUri                                                                 //
0019 //                                                                      //
0020 // This class represents a RFC3986 compatible URI.                      //
0021 // See http://rfc.net/rfc3986.html.                                     //
0022 // It provides member functions to return the different parts of        //
0023 // an URI.                                                              //
0024 //                                                                      //
0025 //////////////////////////////////////////////////////////////////////////
0026 
0027 #include "TObject.h"
0028 #include "TString.h"
0029 
0030 
0031 class TUri;
0032 Bool_t  operator==(const TUri &u1, const TUri &u2);
0033 
0034 
0035 class TUri : public TObject {
0036 
0037 friend Bool_t operator==(const TUri &u1, const TUri &u2); // comparison operator
0038 
0039 private:
0040 
0041    // In order to represent the five basic components of an URI,
0042    // we use 7 member variables (authority gets split in 3 parts)
0043    //
0044    //   foo://user:pass@example.com:8042/over/there?name=ferret#nose
0045    //   \_/   \________________________/\_________/ \_________/ \__/
0046    //    |                 |                |            |        |
0047    //  scheme          authority           path        query   fragment
0048    //
0049    // In many cases we have to distinguish between empty
0050    // TString and undefined value (i.e. delimiter not found).
0051    // Therefore, we use a TString to hold the string value
0052    // and a corresponding Bool_t to store if it is defined or not.
0053    // The Bool_t has precedence.
0054 
0055    TString fScheme;
0056    TString fUserinfo;     // authority/userinfo: user@password, ...
0057    TString fHost;         // authority/host: hostname or ip-address
0058    TString fPort;         // authority/port: port number, normally 1-65535
0059    TString fPath;
0060    TString fQuery;
0061    TString fFragment;
0062 
0063    Bool_t fHasScheme;
0064    Bool_t fHasUserinfo;
0065    Bool_t fHasHost;
0066    Bool_t fHasPort;
0067    Bool_t fHasPath;
0068    Bool_t fHasQuery;
0069    Bool_t fHasFragment;
0070 
0071 public:
0072    TUri(const TUri &uri);
0073    TUri() { Reset(); }
0074    TUri(const TString &uri);
0075    TUri(const char *uri);
0076    TUri &operator=(const TUri &rhs); //copy ctor
0077    virtual ~TUri() { }
0078 
0079    const TString GetUri() const;
0080    const TString GetScheme() const { return fScheme; }
0081    const TString GetHierPart() const;
0082    const TString GetRelativePart() const;
0083    const TString GetAuthority() const;
0084    const TString GetUserInfo() const { return fUserinfo; }
0085    const TString GetHost() const { return fHost; }
0086    const TString GetPort() const { return fPort; }
0087    const TString GetPath() const { return fPath; }
0088    const TString GetQuery() const { return fQuery; }
0089    const TString GetFragment() const { return fFragment; }
0090 
0091    Bool_t HasScheme() const { return fHasScheme; }
0092    Bool_t HasHierPart() const { return IsHierPart(GetHierPart()); }
0093    Bool_t HasAuthority() const { return fHasHost; }
0094    Bool_t HasUserInfo() const { return fHasUserinfo; }
0095    Bool_t HasHost() const { return fHasHost; }
0096    Bool_t HasPort() const { return fHasPort; }
0097    Bool_t HasPath() const { return fHasPath; }
0098    Bool_t HasQuery() const { return fHasQuery; }
0099    Bool_t HasFragment() const { return fHasFragment; }
0100    Bool_t HasRelativePart() const { return IsRelativePart(GetRelativePart()); }
0101 
0102    Bool_t SetUri(const TString &uri);
0103    Bool_t SetScheme(const TString &scheme);
0104    Bool_t SetHierPart(const TString &hier);
0105    Bool_t SetAuthority(const TString &authority);
0106    Bool_t SetUserInfo(const TString &userinfo);
0107    Bool_t SetHost(const TString &host);
0108    Bool_t SetPort(const TString &port);
0109    Bool_t SetPath(const TString &path);
0110    Bool_t SetQuery(const TString &path);
0111    Bool_t SetFragment(const TString &fragment);
0112 
0113    Bool_t SetRelativePart(const TString&);
0114 
0115    void   Print(Option_t *option = "") const override;
0116    Bool_t IsSortable() const override { return kTRUE; }
0117 
0118    void Normalise();
0119    void Reset();
0120 
0121    Bool_t IsAbsolute() const;
0122    Bool_t IsRelative() const;
0123    Bool_t IsUri() const;
0124    Bool_t IsReference() const;
0125 
0126    static Bool_t IsUnreserved(const TString &string);
0127 
0128    static const TString PctEncode(const TString &source);
0129    static const TString PctDecode(const TString &source);
0130    static const TString PctDecodeUnreserved(const TString &source);
0131    static const TString PctNormalise(const TString &source);
0132 
0133    static Bool_t IsScheme(const TString&);
0134    static Bool_t IsHierPart(const TString&);
0135    static Bool_t IsAuthority(const TString&);
0136    static Bool_t IsUserInfo(const TString&);
0137    static Bool_t IsHost(const TString&);
0138    static Bool_t IsIpv4(const TString&);
0139    static Bool_t IsRegName(const TString&);
0140    static Bool_t IsPort(const TString&);
0141    static Bool_t IsPath(const TString&);
0142    static Bool_t IsPathAbsolute(const TString&);
0143    static Bool_t IsPathAbempty(const TString&);
0144    static Bool_t IsPathNoscheme(const TString&);
0145    static Bool_t IsPathRootless(const TString&);
0146    static Bool_t IsPathEmpty(const TString&);
0147    static Bool_t IsQuery(const TString&);
0148    static Bool_t IsFragment(const TString&);
0149 
0150    static Bool_t IsRelativePart(const TString&);
0151 
0152    static const TString RemoveDotSegments(const TString&);
0153 
0154    static TUri Transform(const TUri &reference, const TUri &base);
0155    static const TString MergePaths(const TUri &reference, const TUri &base);
0156 
0157    ClassDefOverride(TUri, 1)  //Represents an URI
0158 };
0159 
0160 #endif