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:16613

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
 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.
 
Bool_t IsSortable () const
 
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
 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)
 
- 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 for instance with: gROOT->SetSelectedPad(gPad).
 
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=0)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 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.
 
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 [].
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator 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.
 
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=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Static Public Member Functions

static TObjArrayGetSpecialProtocols ()
 Read the list of special protocols from the rootrc files.
 
- Static Public Member Functions inherited from TObject
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 = BIT(14) , kUrlHasDefaultPort = BIT(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 = BIT(0) , kOverwrite = BIT(1) , kWriteDelete = BIT(2) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = BIT(3) }
 
enum  EStatusBits {
  kCanDelete = BIT(0) , kMustCleanup = BIT(3) , kIsReferenced = BIT(4) , kHasUUID = BIT(5) ,
  kCannotPick = BIT(6) , kNoContextMenu = BIT(8) , kInvalidObject = BIT(13)
}
 
- Protected Types inherited from TObject
enum  { kOnlyPrepStep = BIT(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 345 of file TUrl.cxx.

◆ ~TUrl()

TUrl::~TUrl ( )
virtual

Cleanup.

Definition at line 88 of file TUrl.cxx.

Member Function Documentation

◆ CleanRelativePath()

void TUrl::CleanRelativePath ( )

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

Definition at line 693 of file TUrl.cxx.

◆ Compare()

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

Compare two urls as strings.

Reimplemented from TObject.

Definition at line 549 of file TUrl.cxx.

◆ FindFile()

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

Find file and optionally anchor and options.

Definition at line 287 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 503 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 471 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 671 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 573 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 389 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 659 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 682 of file TUrl.cxx.

◆ IsSortable()

Bool_t TUrl::IsSortable ( ) const
inlinevirtual

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 364 of file TUrl.cxx.

◆ ParseOptions()

void TUrl::ParseOptions ( ) const

Parse URL options into a key/value map.

Definition at line 625 of file TUrl.cxx.

◆ Print()

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

Print URL on stdout.

Reimplemented from TObject.

Definition at line 559 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 522 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.

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