Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TUrl.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: Fons Rademakers   17/01/97
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, 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_TUrl
0013 #define ROOT_TUrl
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TUrl                                                                 //
0019 //                                                                      //
0020 // This class represents a WWW compatible URL.                          //
0021 // It provides member functions to return the different parts of        //
0022 // an URL. The supported url format is:                                 //
0023 //  [proto://][user[:passwd]@]host[:port]/file.ext[#anchor][?options]   //
0024 //                                                                      //
0025 //////////////////////////////////////////////////////////////////////////
0026 
0027 #include "TObject.h"
0028 #include "TString.h"
0029 
0030 class THashList;
0031 class TMap;
0032 
0033 class TUrl : public TObject {
0034 
0035 private:
0036    mutable TString fUrl;    // full URL
0037    TString fProtocol;       // protocol: http, ftp, news, root, proof, ...
0038    TString fUser;           // user name
0039    TString fPasswd;         // password
0040    TString fHost;           // remote host
0041    TString fFile;           // remote object
0042    TString fAnchor;         // anchor in object (after #)
0043    TString fOptions;        // options/search (after ?)
0044    mutable TString fFileOA; //!file with option and anchor
0045    mutable TString fHostFQ; //!fully qualified host name
0046    Int_t   fPort{-1};       // port through which to contact remote server
0047    mutable TMap *fOptionsMap{nullptr}; //!map containing options key/value pairs
0048 
0049    static TObjArray  *fgSpecialProtocols;  // list of special protocols
0050    static THashList  *fgHostFQDNs;         // list of resolved host FQDNs
0051 
0052    void FindFile(char *u, Bool_t stripDoubleSlash = kTRUE);
0053 
0054    enum EStatusBits { kUrlWithDefaultPort = BIT(14), kUrlHasDefaultPort = BIT(15) };
0055 
0056 public:
0057    TUrl() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
0058    TUrl(const char *url, Bool_t defaultIsFile = kFALSE);
0059    TUrl(const TUrl &url);
0060    TUrl &operator=(const TUrl &rhs);
0061    virtual ~TUrl();
0062 
0063    const char *GetUrl(Bool_t withDeflt = kFALSE) const;
0064    const char *GetProtocol() const { return fProtocol; }
0065    const char *GetUser() const { return fUser; }
0066    const char *GetPasswd() const { return fPasswd; }
0067    const char *GetHost() const { return fHost; }
0068    const char *GetHostFQDN() const;
0069    const char *GetFile() const { return fFile; }
0070    const char *GetAnchor() const { return fAnchor; }
0071    const char *GetOptions() const { return fOptions; }
0072    const char *GetValueFromOptions(const char *key) const;
0073    Int_t       GetIntValueFromOptions(const char *key) const;
0074    Bool_t      HasOption(const char *key) const;
0075    void        ParseOptions() const;
0076    void        CleanRelativePath();
0077    const char *GetFileAndOptions() const;
0078    Int_t       GetPort() const { return fPort; }
0079    Bool_t      IsValid() const { return fPort == -1 ? kFALSE : kTRUE; }
0080 
0081    void        SetProtocol(const char *proto, Bool_t setDefaultPort = kFALSE);
0082    void        SetUser(const char *user) { fUser = user; fUrl = ""; }
0083    void        SetPasswd(const char *pw) { fPasswd = pw; fUrl = ""; }
0084    void        SetHost(const char *host) { fHost = host; fUrl = ""; }
0085    void        SetFile(const char *file) { fFile = file; fUrl = ""; fFileOA = "";}
0086    void        SetAnchor(const char *anchor) { fAnchor = anchor; fUrl = ""; fFileOA = ""; }
0087    void        SetOptions(const char *opt) { fOptions = opt; fUrl = ""; fFileOA = ""; }
0088    void        SetPort(Int_t port) { fPort = port; fUrl = ""; }
0089    void        SetUrl(const char *url, Bool_t defaultIsFile = kFALSE);
0090 
0091    Bool_t      IsSortable() const override { return kTRUE; }
0092    Int_t       Compare(const TObject *obj) const override;
0093 
0094    void        Print(Option_t *option="") const override;
0095 
0096    static TObjArray *GetSpecialProtocols();
0097 
0098    ClassDefOverride(TUrl,1)  //Represents an URL
0099 };
0100 
0101 #endif