File indexing completed on 2025-11-04 10:28:17
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 #ifndef ROOT_TUrl
0013 #define ROOT_TUrl
0014 
0015 
0016 
0017 
0018 
0019 
0020 
0021 
0022 
0023 
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;    
0037    TString fProtocol;       
0038    TString fUser;           
0039    TString fPasswd;         
0040    TString fHost;           
0041    TString fFile;           
0042    TString fAnchor;         
0043    TString fOptions;        
0044    mutable TString fFileOA; 
0045    mutable TString fHostFQ; 
0046    Int_t   fPort{-1};       
0047    mutable TMap *fOptionsMap{nullptr}; 
0048 
0049    static TObjArray  *fgSpecialProtocols;  
0050    static THashList  *fgHostFQDNs;         
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() {} 
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)  
0099 };
0100 
0101 #endif