Go to the documentation of this file.
17 #ifndef IGNITION_COMMON_URI_HH_
18 #define IGNITION_COMMON_URI_HH_
24 #include <gz/common/config.hh>
25 #include <gz/common/Export.hh>
33 class URIAuthorityPrivate;
35 class URIQueryPrivate;
36 class URIFragmentPrivate;
89 public:
void SetUserInfo(
const std::string &_userInfo)
const;
97 public:
void SetHost(
const std::string &_host)
const;
101 public:
bool EmptyHostValid()
const;
107 public:
void SetEmptyHostValid(
bool _valid)
const;
111 public: std::optional<int> Port()
const;
114 public:
void SetPort(
int _port)
const;
119 public:
bool operator==(
const URIAuthority &_auth)
const;
137 bool _emptyHostValid =
false);
141 public:
bool Valid()
const;
150 bool _emptyHostValid =
false);
185 public:
void Clear();
189 public:
bool IsAbsolute()
const;
196 public:
void SetAbsolute(
bool _absolute =
true);
201 public:
void SetRelative();
246 public:
bool operator==(
const URIPath &_path)
const;
261 public:
static bool Valid(
const std::string &_str);
265 public:
bool Valid()
const;
297 public:
void Clear();
313 public:
bool operator==(
const URIQuery &_query)
const;
324 public:
static bool Valid(
const std::string &_str);
328 public:
bool Valid()
const;
360 public:
void Clear();
375 public:
bool operator==(
const URIFragment &_fragment)
const;
384 public:
static bool Valid(
const std::string &_str);
388 public:
bool Valid()
const;
407 class IGNITION_COMMON_VISIBLE
URI
417 bool _hasAuthority =
false);
421 public:
URI(
const URI &_uri);
434 public:
void Clear();
442 public:
void SetScheme(
const std::string &_scheme);
446 public:
void SetAuthority(
const URIAuthority &_authority);
453 public: std::optional<URIAuthority> Authority()
const;
461 public:
const URIPath &Path()
const;
469 public:
const URIQuery &Query()
const;
482 public:
URI &operator=(
const URI &_uri);
487 public:
bool operator==(
const URI &_uri)
const;
491 public:
bool Valid()
const;
496 public:
static bool Valid(
const std::string &_str);
bool IsAbsolute() const
Returns whether the path is absolute or not.
void SetEmptyHostValid(bool _valid) const
Set whether an empty host is considered valid. This should only be set to true if the corresponding U...
void Clear()
Remove all parts of the authority.
const URIPath operator/(const std::string &_part) const
Get the current path with the _part added to the end.
bool operator==(const URIPath &_path) const
Return true if the two paths match.
Forward declarations for the common classes.
std::string Str(const std::string &_delim="&") const
Get the query as a string.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
void SetRelative()
Set the path to be relative.
void SetPort(int _port) const
Set the port number.
URIAuthority & operator=(const URIAuthority &_auth)
Assignment operator.
void SetAuthority(const URIAuthority &_authority)
Set the URI's authority.
URIFragment()
Constructor.
URIQuery & operator=(const URIQuery &_query)
Assignment operator.
std::string Scheme() const
Get the URI's scheme.
void Clear()
Remove all components of the URI.
void Clear()
Remove all values of the query.
bool Parse(const std::string &_string)
Parse a string as URIQuery.
std::string Str() const
Get the complete authoriy as a string.
std::string PopFront()
Remove the part that's in the front of this path and return it.
bool Valid() const
Validate this URI.
virtual ~URIFragment()
Destructor.
bool Valid() const
Check if this is a valid URI query.
std::string PopBack()
Remove the part that's in the back of this path and return it.
void SetAbsolute(bool _absolute=true)
Set whether the path is to be treated absolute or not.
bool operator==(const URI &_uri) const
Return true if the two URIs match.
A URI path contains a sequence of segments separated by /. The path may be empty in a valid URI....
Definition: gz/common/URI.hh:168
std::string Host() const
Get the host.
void PushBack(const std::string &_part)
Push a new part onto the back of this path.
A complete URI which has the following components:
Definition: gz/common/URI.hh:407
The fragment component of a URI.
Definition: gz/common/URI.hh:343
bool operator==(const URIQuery &_query) const
Return true if the two queries contain the same values.
URIAuthority()
Constructor.
std::optional< int > Port() const
Get the port.
bool Parse(const std::string &_str)
Parse a string as URIPath.
void SetScheme(const std::string &_scheme)
Set the URI's scheme.
std::string UserInfo() const
Get the user information.
bool Valid() const
Check if this is a valid URI fragment.
const URIPath & operator/=(const std::string &_part)
Compound assignment operator.
URIFragment & operator=(const URIFragment &_fragment)
Assignment operator.
void Insert(const std::string &_key, const std::string &_value)
Get this query with a new _key=_value pair added.
The query component of a URI.
Definition: gz/common/URI.hh:280
std::optional< URIAuthority > Authority() const
Get a copy of the URI's authority. If the authority has no value (as opposed to being empty),...
bool Parse(const std::string &_string)
Parse a string as URIFragment.
virtual ~URIAuthority()
Destructor.
URI & operator=(const URI &_uri)
Assignment operator.
void Clear()
Remove all parts of the path.
std::string Str() const
Get the fragment as a string.
Definition: gz/common/URI.hh:63
void SetHost(const std::string &_host) const
Set the host.
URIFragment & Fragment()
Get a mutable version of the fragment component.
URIPath & Path()
Get a mutable version of the path component.
URIQuery & Query()
Get a mutable version of the query component.
bool operator==(const URIAuthority &_auth) const
Return true if the two authorities match.
std::string Str() const
Get the URI as a string, which has the form:
virtual ~URIQuery()
Destructor.
virtual ~URIPath()
Destructor.
URIPath & operator=(const URIPath &_path)
Assignment operator.
void PushFront(const std::string &_part)
Push a new part onto the front of this path.
bool Valid() const
Return true if this is a valid path.
bool Parse(const std::string &_str, bool _emptyHostValid=false)
Parse a string as URIAuthority.
bool Valid() const
Return true if this is a valid authority.
void Clear()
Remove all values of the fragment.
void SetUserInfo(const std::string &_userInfo) const
Set the user information.
URI()
Default constructor.
bool Parse(const std::string &_str)
Parse a string as URI. If there's no authority (i.e. Authority().has_value() == false),...
std::string Str(const std::string &_delim="/") const
Get the path as a string.
bool operator==(const URIFragment &_fragment) const
Return true if the two fragments contain the same values.
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68
bool EmptyHostValid() const
True if an empty host is considered valid.