Logo ROOT  
Reference Guide
TUri.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Gerhard E. Bruckner 15/07/07
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TUri
13 #define ROOT_TUri
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TUri //
19 // //
20 // This class represents a RFC3986 compatible URI. //
21 // See http://rfc.net/rfc3986.html. //
22 // It provides member functions to return the different parts of //
23 // an URI. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #include "TObject.h"
28 #include "TString.h"
29 
30 
31 class TUri;
32 Bool_t operator==(const TUri &u1, const TUri &u2);
33 
34 
35 class TUri : public TObject {
36 
37 friend Bool_t operator==(const TUri &u1, const TUri &u2); // comparison operator
38 
39 private:
40 
41  // In order to represent the five basic components of an URI,
42  // we use 7 member variables (authority gets split in 3 parts)
43  //
44  // foo://user:pass@example.com:8042/over/there?name=ferret#nose
45  // \_/ \________________________/\_________/ \_________/ \__/
46  // | | | | |
47  // scheme authority path query fragment
48  //
49  // In many cases we have to distinguish between empty
50  // TString and undefined value (i.e. delimiter not found).
51  // Therefore, we use a TString to hold the string value
52  // and a corresponding Bool_t to store if it is defined or not.
53  // The Bool_t has precedence.
54 
56  TString fUserinfo; // authority/userinfo: user@password, ...
57  TString fHost; // authority/host: hostname or ip-address
58  TString fPort; // authority/port: port number, normally 1-65535
62 
70 
71 public:
72  TUri(const TUri &uri);
73  TUri() { Reset(); }
74  TUri(const TString &uri);
75  TUri(const char *uri);
76  TUri &operator=(const TUri &rhs); //copy ctor
77  virtual ~TUri() { }
78 
79  const TString GetUri() const;
80  const TString GetScheme() const { return fScheme; }
81  const TString GetHierPart() const;
82  const TString GetRelativePart() const;
83  const TString GetAuthority() const;
84  const TString GetUserInfo() const { return fUserinfo; }
85  const TString GetHost() const { return fHost; }
86  const TString GetPort() const { return fPort; }
87  const TString GetPath() const { return fPath; }
88  const TString GetQuery() const { return fQuery; }
89  const TString GetFragment() const { return fFragment; }
90 
91  Bool_t HasScheme() const { return fHasScheme; }
92  Bool_t HasHierPart() const { return IsHierPart(GetHierPart()); }
93  Bool_t HasAuthority() const { return fHasHost; }
94  Bool_t HasUserInfo() const { return fHasUserinfo; }
95  Bool_t HasHost() const { return fHasHost; }
96  Bool_t HasPort() const { return fHasPort; }
97  Bool_t HasPath() const { return fHasPath; }
98  Bool_t HasQuery() const { return fHasQuery; }
99  Bool_t HasFragment() const { return fHasFragment; }
101 
102  Bool_t SetUri(const TString &uri);
103  Bool_t SetScheme(const TString &scheme);
104  Bool_t SetHierPart(const TString &hier);
105  Bool_t SetAuthority(const TString &authority);
106  Bool_t SetUserInfo(const TString &userinfo);
107  Bool_t SetHost(const TString &host);
108  Bool_t SetPort(const TString &port);
109  Bool_t SetPath(const TString &path);
110  Bool_t SetQuery(const TString &path);
111  Bool_t SetFragment(const TString &fragment);
112 
114 
115  void Print(Option_t *option = "") const;
116  Bool_t IsSortable() const { return kTRUE; }
117 
118  void Normalise();
119  void Reset();
120 
121  Bool_t IsAbsolute() const;
122  Bool_t IsRelative() const;
123  Bool_t IsUri() const;
124  Bool_t IsReference() const;
125 
126  static Bool_t IsUnreserved(const TString &string);
127 
128  static const TString PctEncode(const TString &source);
129  static const TString PctDecode(const TString &source);
130  static const TString PctDecodeUnreserved(const TString &source);
131  static const TString PctNormalise(const TString &source);
132 
133  static Bool_t IsScheme(const TString&);
134  static Bool_t IsHierPart(const TString&);
135  static Bool_t IsAuthority(const TString&);
136  static Bool_t IsUserInfo(const TString&);
137  static Bool_t IsHost(const TString&);
138  static Bool_t IsIpv4(const TString&);
139  static Bool_t IsRegName(const TString&);
140  static Bool_t IsPort(const TString&);
141  static Bool_t IsPath(const TString&);
142  static Bool_t IsPathAbsolute(const TString&);
143  static Bool_t IsPathAbempty(const TString&);
144  static Bool_t IsPathNoscheme(const TString&);
145  static Bool_t IsPathRootless(const TString&);
146  static Bool_t IsPathEmpty(const TString&);
147  static Bool_t IsQuery(const TString&);
148  static Bool_t IsFragment(const TString&);
149 
150  static Bool_t IsRelativePart(const TString&);
151 
152  static const TString RemoveDotSegments(const TString&);
153 
154  static TUri Transform(const TUri &reference, const TUri &base);
155  static const TString MergePaths(const TUri &reference, const TUri &base);
156 
157  ClassDef(TUri, 1) //Represents an URI
158 };
159 
160 #endif
TUri::IsFragment
static Bool_t IsFragment(const TString &)
TUri::fHasHost
Bool_t fHasHost
Definition: TUri.h:65
TUri::HasQuery
Bool_t HasQuery() const
Definition: TUri.h:98
TUri::TUri
TUri()
Definition: TUri.h:73
TUri::GetUserInfo
const TString GetUserInfo() const
Definition: TUri.h:84
TUri::PctNormalise
static const TString PctNormalise(const TString &source)
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TUri::fHost
TString fHost
Definition: TUri.h:57
TUri::fHasFragment
Bool_t fHasFragment
Definition: TUri.h:69
TUri::SetScheme
Bool_t SetScheme(const TString &scheme)
Set scheme component of URI:
Definition: TUri.cxx:248
Option_t
const char Option_t
Definition: RtypesCore.h:66
TUri::GetRelativePart
const TString GetRelativePart() const
operator==
Bool_t operator==(const TUri &u1, const TUri &u2)
Implementation of a TUri Equivalence operator that uses syntax-based normalisation see chapter 6....
Definition: TUri.cxx:116
TUri::IsHierPart
static Bool_t IsHierPart(const TString &)
TUri::fHasPath
Bool_t fHasPath
Definition: TUri.h:67
TUri::GetHost
const TString GetHost() const
Definition: TUri.h:85
TUri::Transform
static TUri Transform(const TUri &reference, const TUri &base)
TUri::GetHierPart
const TString GetHierPart() const
TUri::IsQuery
static Bool_t IsQuery(const TString &)
TUri::PctDecode
static const TString PctDecode(const TString &source)
TUri::HasPort
Bool_t HasPort() const
Definition: TUri.h:96
TUri::HasHost
Bool_t HasHost() const
Definition: TUri.h:95
TUri::PctDecodeUnreserved
static const TString PctDecodeUnreserved(const TString &source)
TUri::SetFragment
Bool_t SetFragment(const TString &fragment)
TUri::IsUnreserved
static Bool_t IsUnreserved(const TString &string)
TUri::IsReference
Bool_t IsReference() const
Returns kTRUE if instance qualifies as URI-reference URI-reference = URI / relative-ref cf.
Definition: TUri.cxx:237
TUri::GetAuthority
const TString GetAuthority() const
TString
Basic string class.
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TUri::SetHost
Bool_t SetHost(const TString &host)
TUri::IsScheme
static Bool_t IsScheme(const TString &)
Returns kTRUE if string qualifies as URI scheme:
Definition: TUri.cxx:270
TString.h
TUri::operator==
friend Bool_t operator==(const TUri &u1, const TUri &u2)
Implementation of a TUri Equivalence operator that uses syntax-based normalisation see chapter 6....
Definition: TUri.cxx:116
bool
TUri::Print
void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
TUri::~TUri
virtual ~TUri()
Definition: TUri.h:77
TUri::fFragment
TString fFragment
Definition: TUri.h:61
TUri::IsPathNoscheme
static Bool_t IsPathNoscheme(const TString &)
TUri::MergePaths
static const TString MergePaths(const TUri &reference, const TUri &base)
TUri::HasScheme
Bool_t HasScheme() const
Definition: TUri.h:91
TUri::HasHierPart
Bool_t HasHierPart() const
Definition: TUri.h:92
TUri::IsAbsolute
Bool_t IsAbsolute() const
Returns kTRUE if instance qualifies as absolute-URI absolute-URI = scheme ":" hier-part [ "?...
Definition: TUri.cxx:207
TUri::IsSortable
Bool_t IsSortable() const
Definition: TUri.h:116
TUri::IsIpv4
static Bool_t IsIpv4(const TString &)
TUri::GetQuery
const TString GetQuery() const
Definition: TUri.h:88
TUri::fHasUserinfo
Bool_t fHasUserinfo
Definition: TUri.h:64
TUri::Normalise
void Normalise()
TUri::fPort
TString fPort
Definition: TUri.h:58
TUri::HasRelativePart
Bool_t HasRelativePart() const
Definition: TUri.h:100
TUri::IsUserInfo
static Bool_t IsUserInfo(const TString &)
TUri::HasUserInfo
Bool_t HasUserInfo() const
Definition: TUri.h:94
TUri::IsPathAbempty
static Bool_t IsPathAbempty(const TString &)
TUri::fHasQuery
Bool_t fHasQuery
Definition: TUri.h:68
TUri::RemoveDotSegments
static const TString RemoveDotSegments(const TString &)
This functions implements the "remove_dot_segments" routine of chapter 5.2.4 "for interpreting and re...
Definition: TUri.cxx:159
TUri::fUserinfo
TString fUserinfo
Definition: TUri.h:56
TUri::GetScheme
const TString GetScheme() const
Definition: TUri.h:80
TUri::SetPath
Bool_t SetPath(const TString &path)
TUri::IsUri
Bool_t IsUri() const
Returns kTRUE if instance qualifies as URI URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] ...
Definition: TUri.cxx:227
TUri::SetRelativePart
Bool_t SetRelativePart(const TString &)
TUri::IsAuthority
static Bool_t IsAuthority(const TString &)
TUri::fHasPort
Bool_t fHasPort
Definition: TUri.h:66
TUri::HasPath
Bool_t HasPath() const
Definition: TUri.h:97
TUri::IsHost
static Bool_t IsHost(const TString &)
TUri::fPath
TString fPath
Definition: TUri.h:59
TUri::fHasScheme
Bool_t fHasScheme
Definition: TUri.h:63
TUri::IsRelative
Bool_t IsRelative() const
Returns kTRUE if instance qualifies as relative-ref relative-ref = relative-part [ "?...
Definition: TUri.cxx:217
TUri::HasAuthority
Bool_t HasAuthority() const
Definition: TUri.h:93
TObject.h
TUri
This class represents a RFC 3986 compatible URI.
Definition: TUri.h:35
TUri::SetPort
Bool_t SetPort(const TString &port)
TUri::IsPathRootless
static Bool_t IsPathRootless(const TString &)
TUri::IsPort
static Bool_t IsPort(const TString &)
TUri::PctEncode
static const TString PctEncode(const TString &source)
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TUri::SetHierPart
Bool_t SetHierPart(const TString &hier)
TUri::GetPort
const TString GetPort() const
Definition: TUri.h:86
TUri::SetAuthority
Bool_t SetAuthority(const TString &authority)
TUri::HasFragment
Bool_t HasFragment() const
Definition: TUri.h:99
TUri::SetUserInfo
Bool_t SetUserInfo(const TString &userinfo)
TUri::IsPathEmpty
static Bool_t IsPathEmpty(const TString &)
TUri::Reset
void Reset()
TUri::IsRelativePart
static Bool_t IsRelativePart(const TString &)
TUri::SetQuery
Bool_t SetQuery(const TString &path)
TUri::operator=
TUri & operator=(const TUri &rhs)
TUri assignment operator.
Definition: TUri.cxx:89
TUri::IsPathAbsolute
static Bool_t IsPathAbsolute(const TString &)
TUri::GetFragment
const TString GetFragment() const
Definition: TUri.h:89
TUri::fQuery
TString fQuery
Definition: TUri.h:60
TUri::IsPath
static Bool_t IsPath(const TString &)
TUri::GetPath
const TString GetPath() const
Definition: TUri.h:87
TUri::IsRegName
static Bool_t IsRegName(const TString &)
TUri::GetUri
const TString GetUri() const
Returns the whole URI - an implementation of chapter 5.3 component recomposition.
Definition: TUri.cxx:140
TUri::SetUri
Bool_t SetUri(const TString &uri)
TUri::fScheme
TString fScheme
Definition: TUri.h:55