00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TUrl
00013 #define ROOT_TUrl
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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;
00045 TString fProtocol;
00046 TString fUser;
00047 TString fPasswd;
00048 TString fHost;
00049 TString fFile;
00050 TString fAnchor;
00051 TString fOptions;
00052 mutable TString fFileOA;
00053 mutable TString fHostFQ;
00054 Int_t fPort;
00055 mutable TMap *fOptionsMap;
00056
00057 static TObjArray *fgSpecialProtocols;
00058 static THashList *fgHostFQDNs;
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)
00107 };
00108
00109 #endif