TUrl.h

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TUrl.h 33098 2010-04-19 22:54:51Z rdm $
00002 // Author: Fons Rademakers   17/01/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TUrl
00013 #define ROOT_TUrl
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TUrl                                                                 //
00019 //                                                                      //
00020 // This class represents a WWW compatible URL.                          //
00021 // It provides member functions to return the different parts of        //
00022 // an URL. The supported url format is:                                 //
00023 //  [proto://][user[:passwd]@]host[:port]/file.ext[#anchor][?options]   //
00024 //                                                                      //
00025 //////////////////////////////////////////////////////////////////////////
00026 
00027 #ifndef ROOT_TObject
00028 #include "TObject.h"
00029 #endif
00030 #ifndef ROOT_TString
00031 #include "TString.h"
00032 #endif
00033 #ifndef ROOT_TMap
00034 #include "TMap.h"
00035 #endif
00036 
00037 
00038 class THashList;
00039 class TMap;
00040 
00041 class TUrl : public TObject {
00042 
00043 private:
00044    mutable TString fUrl;    // full URL
00045    TString fProtocol;       // protocol: http, ftp, news, root, proof, ...
00046    TString fUser;           // user name
00047    TString fPasswd;         // password
00048    TString fHost;           // remote host
00049    TString fFile;           // remote object
00050    TString fAnchor;         // anchor in object (after #)
00051    TString fOptions;        // options/search (after ?)
00052    mutable TString fFileOA; //!file with option and anchor
00053    mutable TString fHostFQ; //!fully qualified host name
00054    Int_t   fPort;           // port through which to contact remote server
00055    mutable TMap *fOptionsMap; //!map containing options key/value pairs
00056 
00057    static TObjArray  *fgSpecialProtocols;  // list of special protocols
00058    static THashList  *fgHostFQDNs;         // list of resolved host FQDNs
00059 
00060    void FindFile(char *u, Bool_t stripDoubleSlash = kTRUE);
00061 
00062    enum EStatusBits { kUrlWithDefaultPort = BIT(14), kUrlHasDefaultPort = BIT(15) };
00063 
00064 public:
00065    TUrl() : fUrl(), fProtocol(), fUser(), fPasswd(), fHost(), fFile(),
00066             fAnchor(), fOptions(), fFileOA(), fHostFQ(), fPort(-1), fOptionsMap(0) { }
00067    TUrl(const char *url, Bool_t defaultIsFile = kFALSE);
00068    TUrl(const TUrl &url);
00069    TUrl &operator=(const TUrl &rhs);
00070    virtual ~TUrl();
00071 
00072    const char *GetUrl(Bool_t withDeflt = kFALSE) const;
00073    const char *GetProtocol() const { return fProtocol; }
00074    const char *GetUser() const { return fUser; }
00075    const char *GetPasswd() const { return fPasswd; }
00076    const char *GetHost() const { return fHost; }
00077    const char *GetHostFQDN() const;
00078    const char *GetFile() const { return fFile; }
00079    const char *GetAnchor() const { return fAnchor; }
00080    const char *GetOptions() const { return fOptions; }
00081    const char *GetValueFromOptions(const char *key) const;
00082    Int_t       GetIntValueFromOptions(const char *key) const;
00083    void        ParseOptions() const;
00084    void        CleanRelativePath();
00085    const char *GetFileAndOptions() const;
00086    Int_t       GetPort() const { return fPort; }
00087    Bool_t      IsValid() const { return fPort == -1 ? kFALSE : kTRUE; }
00088 
00089    void        SetProtocol(const char *proto, Bool_t setDefaultPort = kFALSE);
00090    void        SetUser(const char *user) { fUser = user; fUrl = ""; }
00091    void        SetPasswd(const char *pw) { fPasswd = pw; fUrl = ""; }
00092    void        SetHost(const char *host) { fHost = host; fUrl = ""; }
00093    void        SetFile(const char *file) { fFile = file; fUrl = ""; fFileOA = "";}
00094    void        SetAnchor(const char *anchor) { fAnchor = anchor; fUrl = ""; fFileOA = ""; }
00095    void        SetOptions(const char *opt) { fOptions = opt; fUrl = ""; fFileOA = ""; }
00096    void        SetPort(Int_t port) { fPort = port; fUrl = ""; }
00097    void        SetUrl(const char *url, Bool_t defaultIsFile = kFALSE);
00098 
00099    Bool_t      IsSortable() const { return kTRUE; }
00100    Int_t       Compare(const TObject *obj) const;
00101 
00102    void        Print(Option_t *option="") const;
00103 
00104    static TObjArray *GetSpecialProtocols();
00105 
00106    ClassDef(TUrl,1)  //Represents an URL
00107 };
00108 
00109 #endif

Generated on Tue Jul 5 14:10:32 2011 for ROOT_528-00b_version by  doxygen 1.5.1