Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TUrl Class Reference

This class represents a WWW compatible URL.

It provides member functions to return the different parts of an URL. The supported url format is:

[proto://][user[:passwd]@]host[:port]/file.ext[#anchor][?options]
const char * proto
Definition civetweb.c:17536

Definition at line 33 of file TUrl.h.

Public Member Functions

 TUrl ()
 
 TUrl (const char *url, Bool_t defaultIsFile=kFALSE)
 Parse url character string and split in its different subcomponents.
 
 TUrl (const TUrl &url)
 TUrl copy ctor.
 
virtual ~TUrl ()
 Cleanup.
 
void CleanRelativePath ()
 Recompute the path removing all relative directory jumps via '..'.
 
Int_t Compare (const TObject *obj) const override
 Compare two urls as strings.
 
const char * GetAnchor () const
 
const char * GetFile () const
 
const char * GetFileAndOptions () const
 Return the file and its options (the string specified behind the ?).
 
const char * GetHost () const
 
const char * GetHostFQDN () const
 Return fully qualified domain name of url host.
 
Int_t GetIntValueFromOptions (const char *key) const
 Return a value for a given key from the URL options as an Int_t, a missing key returns -1.
 
const char * GetOptions () const
 
const char * GetPasswd () const
 
Int_t GetPort () const
 
const char * GetProtocol () const
 
const char * GetUrl (Bool_t withDeflt=kFALSE) const
 Return full URL.
 
const char * GetUser () const
 
const char * GetValueFromOptions (const char *key) const
 Return a value for a given key from the URL options.
 
Bool_t HasOption (const char *key) const
 Returns true if the given key appears in the URL options list.
 
TClassIsA () const override
 
Bool_t IsSortable () const override
 
Bool_t IsValid () const
 
TUrloperator= (const TUrl &rhs)
 TUrl assignment operator.
 
void ParseOptions () const
 Parse URL options into a key/value map.
 
void Print (Option_t *option="") const override
 Print URL on stdout.
 
void SetAnchor (const char *anchor)
 
void SetFile (const char *file)
 
void SetHost (const char *host)
 
void SetOptions (const char *opt)
 
void SetPasswd (const char *pw)
 
void SetPort (Int_t port)
 
void SetProtocol (const char *proto, Bool_t setDefaultPort=kFALSE)
 Set protocol and, optionally, change the port accordingly.
 
void SetUrl (const char *url, Bool_t defaultIsFile=kFALSE)
 Parse url character string and split in its different subcomponents.
 
void SetUser (const char *user)
 
void Streamer (TBuffer &) override
 Stream an object of class TObject.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility.
 
virtual void Copy (TObject &object) const
 Copy this to obj.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object.
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py).
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual const char * GetName () const
 Returns name of object.
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py).
 
virtual Option_tGetOption () const
 
virtual const char * GetTitle () const
 Returns title of object.
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
virtual ULong_t Hash () const
 Return hash value for this object.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 IsDestructed.
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 The ls function lists the contents of a class on stdout.
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification (the base implementation is no-op).
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *vp)
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out".
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static TObjArrayGetSpecialProtocols ()
 Read the list of special protocols from the rootrc files.
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 

Private Types

enum  EStatusBits { kUrlWithDefaultPort = (1ULL << ( 14 )) , kUrlHasDefaultPort = (1ULL << ( 15 )) }
 

Private Member Functions

void FindFile (char *u, Bool_t stripDoubleSlash=kTRUE)
 Find file and optionally anchor and options.
 

Private Attributes

TString fAnchor
 
TString fFile
 
TString fFileOA
 
TString fHost
 
TString fHostFQ
 file with option and anchor
 
TString fOptions
 
TMapfOptionsMap {nullptr}
 
TString fPasswd
 
Int_t fPort {-1}
 fully qualified host name
 
TString fProtocol
 
TString fUrl
 
TString fUser
 

Static Private Attributes

static THashListfgHostFQDNs = nullptr
 
static TObjArrayfgSpecialProtocols = nullptr
 map containing options key/value pairs
 

Additional Inherited Members

- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = (1ULL << ( 0 )) , kOverwrite = (1ULL << ( 1 )) , kWriteDelete = (1ULL << ( 2 )) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = (1ULL << ( 3 )) }
 
enum  EStatusBits {
  kCanDelete = (1ULL << ( 0 )) , kMustCleanup = (1ULL << ( 3 )) , kIsReferenced = (1ULL << ( 4 )) , kHasUUID = (1ULL << ( 5 )) ,
  kCannotPick = (1ULL << ( 6 )) , kNoContextMenu = (1ULL << ( 8 )) , kInvalidObject = (1ULL << ( 13 ))
}
 
- Protected Types inherited from TObject
enum  { kOnlyPrepStep = (1ULL << ( 3 )) }
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

#include <TUrl.h>

Inheritance diagram for TUrl:
[legend]

Member Enumeration Documentation

◆ EStatusBits

enum TUrl::EStatusBits
private
Enumerator
kUrlWithDefaultPort 
kUrlHasDefaultPort 

Definition at line 54 of file TUrl.h.

Constructor & Destructor Documentation

◆ TUrl() [1/3]

TUrl::TUrl ( )
inline

Definition at line 57 of file TUrl.h.

◆ TUrl() [2/3]

TUrl::TUrl ( const char *  url,
Bool_t  defaultIsFile = kFALSE 
)

Parse url character string and split in its different subcomponents.

Use IsValid() to check if URL is legal.

url: [proto://][user[:passwd]@]host[:port]/file.ext[?options][#anchor]

Known protocols: http, root, proof, ftp, news and any special protocols defined in the rootrc Url.Special key. The default protocol is "http", unless defaultIsFile is true in which case the url is assumed to be of type "file". If a passwd contains a @ it must be escaped by a \, e.g. "pip@" becomes "pip\\@".

Default ports: http=80, root=1094, proof=1093, ftp=20, news=119. Port #1093 has been assigned by IANA (www.iana.org) to proofd. Port #1094 has been assigned by IANA (www.iana.org) to rootd.

Definition at line 76 of file TUrl.cxx.

◆ TUrl() [3/3]

TUrl::TUrl ( const TUrl url)

TUrl copy ctor.

Definition at line 346 of file TUrl.cxx.

◆ ~TUrl()

TUrl::~TUrl ( )
virtual

Cleanup.

Definition at line 88 of file TUrl.cxx.

Member Function Documentation

◆ Class()

static TClass * TUrl::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TUrl::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TUrl::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 98 of file TUrl.h.

◆ CleanRelativePath()

void TUrl::CleanRelativePath ( )

Recompute the path removing all relative directory jumps via '..'.

Definition at line 694 of file TUrl.cxx.

◆ Compare()

Int_t TUrl::Compare ( const TObject obj) const
overridevirtual

Compare two urls as strings.

Reimplemented from TObject.

Definition at line 550 of file TUrl.cxx.

◆ DeclFileName()

static const char * TUrl::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 98 of file TUrl.h.

◆ FindFile()

void TUrl::FindFile ( char *  u,
Bool_t  stripDoubleSlash = kTRUE 
)
private

Find file and optionally anchor and options.

Definition at line 288 of file TUrl.cxx.

◆ GetAnchor()

const char * TUrl::GetAnchor ( ) const
inline

Definition at line 70 of file TUrl.h.

◆ GetFile()

const char * TUrl::GetFile ( ) const
inline

Definition at line 69 of file TUrl.h.

◆ GetFileAndOptions()

const char * TUrl::GetFileAndOptions ( ) const

Return the file and its options (the string specified behind the ?).

Convenience function useful when the option is used to pass authentication/access information for the specified file.

Definition at line 504 of file TUrl.cxx.

◆ GetHost()

const char * TUrl::GetHost ( ) const
inline

Definition at line 67 of file TUrl.h.

◆ GetHostFQDN()

const char * TUrl::GetHostFQDN ( ) const

Return fully qualified domain name of url host.

If host cannot be resolved or not valid return the host name as originally specified.

Definition at line 472 of file TUrl.cxx.

◆ GetIntValueFromOptions()

Int_t TUrl::GetIntValueFromOptions ( const char *  key) const

Return a value for a given key from the URL options as an Int_t, a missing key returns -1.

Definition at line 672 of file TUrl.cxx.

◆ GetOptions()

const char * TUrl::GetOptions ( ) const
inline

Definition at line 71 of file TUrl.h.

◆ GetPasswd()

const char * TUrl::GetPasswd ( ) const
inline

Definition at line 66 of file TUrl.h.

◆ GetPort()

Int_t TUrl::GetPort ( ) const
inline

Definition at line 78 of file TUrl.h.

◆ GetProtocol()

const char * TUrl::GetProtocol ( ) const
inline

Definition at line 64 of file TUrl.h.

◆ GetSpecialProtocols()

TObjArray * TUrl::GetSpecialProtocols ( )
static

Read the list of special protocols from the rootrc files.

These protocols will be parsed in a protocol and a file part, no host or other info will be determined. This is typically used for legacy file descriptions like: file:/path/file.root.

Definition at line 574 of file TUrl.cxx.

◆ GetUrl()

const char * TUrl::GetUrl ( Bool_t  withDeflt = kFALSE) const

Return full URL.

If withDflt is kTRUE, explicitly add the port even if it matches the default value for the URL protocol.

Definition at line 390 of file TUrl.cxx.

◆ GetUser()

const char * TUrl::GetUser ( ) const
inline

Definition at line 65 of file TUrl.h.

◆ GetValueFromOptions()

const char * TUrl::GetValueFromOptions ( const char *  key) const

Return a value for a given key from the URL options.

Returns 0 in case key is not found.

Definition at line 660 of file TUrl.cxx.

◆ HasOption()

Bool_t TUrl::HasOption ( const char *  key) const

Returns true if the given key appears in the URL options list.

Definition at line 683 of file TUrl.cxx.

◆ IsA()

TClass * TUrl::IsA ( ) const
inlineoverridevirtual
Returns
TClass describing current object

Reimplemented from TObject.

Definition at line 98 of file TUrl.h.

◆ IsSortable()

Bool_t TUrl::IsSortable ( ) const
inlineoverridevirtual

Reimplemented from TObject.

Definition at line 91 of file TUrl.h.

◆ IsValid()

Bool_t TUrl::IsValid ( ) const
inline

Definition at line 79 of file TUrl.h.

◆ operator=()

TUrl & TUrl::operator= ( const TUrl rhs)

TUrl assignment operator.

Definition at line 365 of file TUrl.cxx.

◆ ParseOptions()

void TUrl::ParseOptions ( ) const

Parse URL options into a key/value map.

Definition at line 626 of file TUrl.cxx.

◆ Print()

void TUrl::Print ( Option_t option = "") const
overridevirtual

Print URL on stdout.

Reimplemented from TObject.

Definition at line 560 of file TUrl.cxx.

◆ SetAnchor()

void TUrl::SetAnchor ( const char *  anchor)
inline

Definition at line 86 of file TUrl.h.

◆ SetFile()

void TUrl::SetFile ( const char *  file)
inline

Definition at line 85 of file TUrl.h.

◆ SetHost()

void TUrl::SetHost ( const char *  host)
inline

Definition at line 84 of file TUrl.h.

◆ SetOptions()

void TUrl::SetOptions ( const char *  opt)
inline

Definition at line 87 of file TUrl.h.

◆ SetPasswd()

void TUrl::SetPasswd ( const char *  pw)
inline

Definition at line 83 of file TUrl.h.

◆ SetPort()

void TUrl::SetPort ( Int_t  port)
inline

Definition at line 88 of file TUrl.h.

◆ SetProtocol()

void TUrl::SetProtocol ( const char *  proto,
Bool_t  setDefaultPort = kFALSE 
)

Set protocol and, optionally, change the port accordingly.

Definition at line 523 of file TUrl.cxx.

◆ SetUrl()

void TUrl::SetUrl ( const char *  url,
Bool_t  defaultIsFile = kFALSE 
)

Parse url character string and split in its different subcomponents.

Use IsValid() to check if URL is legal.

url: [proto://][user[:passwd]@]host[:port]/file.ext[?options][#anchor]

Known protocols: http, root, proof, ftp, news and any special protocols defined in the rootrc Url.Special key. The default protocol is "http", unless defaultIsFile is true in which case the url is assumed to be of type "file". If a passwd contains a @ it must be escaped by a \, e.g. "pip@" becomes "pip\\@".

Default ports: http=80, root=1094, proof=1093, ftp=20, news=119. Port #1093 has been assigned by IANA (www.iana.org) to proofd. Port #1094 has been assigned by IANA (www.iana.org) to rootd.

Definition at line 110 of file TUrl.cxx.

◆ SetUser()

void TUrl::SetUser ( const char *  user)
inline

Definition at line 82 of file TUrl.h.

◆ Streamer()

void TUrl::Streamer ( TBuffer R__b)
overridevirtual

Stream an object of class TObject.

Reimplemented from TObject.

◆ StreamerNVirtual()

void TUrl::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 98 of file TUrl.h.

Member Data Documentation

◆ fAnchor

TString TUrl::fAnchor
private

Definition at line 42 of file TUrl.h.

◆ fFile

TString TUrl::fFile
private

Definition at line 41 of file TUrl.h.

◆ fFileOA

TString TUrl::fFileOA
mutableprivate

Definition at line 44 of file TUrl.h.

◆ fgHostFQDNs

THashList * TUrl::fgHostFQDNs = nullptr
staticprivate

Definition at line 50 of file TUrl.h.

◆ fgSpecialProtocols

TObjArray * TUrl::fgSpecialProtocols = nullptr
staticprivate

map containing options key/value pairs

Definition at line 49 of file TUrl.h.

◆ fHost

TString TUrl::fHost
private

Definition at line 40 of file TUrl.h.

◆ fHostFQ

TString TUrl::fHostFQ
mutableprivate

file with option and anchor

Definition at line 45 of file TUrl.h.

◆ fOptions

TString TUrl::fOptions
private

Definition at line 43 of file TUrl.h.

◆ fOptionsMap

TMap* TUrl::fOptionsMap {nullptr}
mutableprivate

Definition at line 47 of file TUrl.h.

◆ fPasswd

TString TUrl::fPasswd
private

Definition at line 39 of file TUrl.h.

◆ fPort

Int_t TUrl::fPort {-1}
private

fully qualified host name

Definition at line 46 of file TUrl.h.

◆ fProtocol

TString TUrl::fProtocol
private

Definition at line 37 of file TUrl.h.

◆ fUrl

TString TUrl::fUrl
mutableprivate

Definition at line 36 of file TUrl.h.

◆ fUser

TString TUrl::fUser
private

Definition at line 38 of file TUrl.h.

  • core/base/inc/TUrl.h
  • core/base/src/TUrl.cxx