libzypp: zypp::url::UrlBase Class Reference

libzypp 17.38.7

zypp::url::UrlBase Class Reference

Generic Url base class. More...

`#include <zypp-core/url/UrlBase.h>`

## Public Member Functions
virtual | ~UrlBase ()
| UrlBase ()
| UrlBase (const UrlBase &url)
| Create a new Url object as copy of the given one.
| UrlBase (const std::string &scheme, const std::string &authority, const std::string &pathdata, const std::string &querystr, const std::string &fragment)
| Construct new object and initializes it with specified URL components.
virtual void | clear ()
| Clears all data in the object.
virtual UrlBase * | clone () const
| Returns pointer to a copy of the current object.
virtual void | init (const std::string &scheme, const std::string &authority, const std::string &pathdata, const std::string &querystr, const std::string &fragment)
| Initializes current object with new URL components.
virtual UrlSchemes | getKnownSchemes () const
| Returns scheme names known by this object.
virtual bool | isKnownScheme (const std::string &scheme) const
| Returns if scheme name is known to this object.
virtual bool | isValidScheme (const std::string &scheme) const
| Verifies specified scheme name.
virtual bool | isValid () const
| Verifies the Url.
virtual std::string | asString () const
| Returns a default string representation of the Url object.
virtual std::string | asString (const zypp::url::ViewOptions &opts) const
| Returns a string representation of the Url object.
virtual std::string | getScheme () const
| Returns the scheme name of the URL.
virtual std::string | getAuthority () const
| Returns the encoded authority component of the URL.
virtual std::string | getUsername (EEncoding eflag) const
| Returns the username from the URL authority.
virtual std::string | getPassword (EEncoding eflag) const
| Returns the password from the URL authority.
virtual std::string | getHost (EEncoding eflag) const
| Returns the hostname or IP from the URL authority.
virtual std::string | getPort () const
| Returns the port number from the URL authority.
virtual std::string | getPathData () const
| Returns the encoded path component of the URL.
virtual std::string | getPathName (EEncoding eflag) const
| Returns the path name from the URL.
virtual std::string | getPathParams () const
| Returns the encoded path parameters from the URL.
virtual zypp::url::ParamVec | getPathParamsVec () const
| Returns a vector with encoded path parameter substrings.
virtual zypp::url::ParamMap | getPathParamsMap (EEncoding eflag) const
| Returns a string map with path parameter keys and values.
virtual std::string | getPathParam (const std::string &param, EEncoding eflag) const
| Return the value for the specified path parameter.
virtual std::string | getQueryString () const
| Returns the encoded query string component of the URL.
virtual std::string | getQueryString (const ViewOptions &viewopts_r) const
virtual zypp::url::ParamVec | getQueryStringVec () const
| Returns a vector with query string parameter substrings.
virtual zypp::url::ParamMap | getQueryStringMap (EEncoding eflag) const
| Returns a string map with query parameter and their values.
virtual std::string | getQueryParam (const std::string &param, EEncoding eflag) const
| Return the value for the specified query parameter.
virtual std::string | getFragment (EEncoding eflag) const
| Returns the encoded fragment component of the URL.
virtual void | setScheme (const std::string &scheme)
| Set the scheme name in the URL.
virtual void | setAuthority (const std::string &authority)
| Set the authority component in the URL.
virtual void | setUsername (const std::string &user, EEncoding eflag)
| Set the username in the URL authority.
virtual void | setPassword (const std::string &pass, EEncoding eflag)
| Set the password in the URL authority.
virtual void | setHost (const std::string &host)
| Set the hostname or IP in the URL authority.
virtual void | setPort (const std::string &port)
| Set the port number in the URL authority.
virtual void | setPathData (const std::string &pathdata)
| Set the path data component in the URL.
virtual void | setPathName (const std::string &path, EEncoding eflag)
| Set the path name.
virtual void | setPathParams (const std::string &params)
| Set the path parameters.
virtual void | setPathParamsVec (const zypp::url::ParamVec &pvec)
| Set the path parameters.
virtual void | setPathParamsMap (const zypp::url::ParamMap &pmap)
| Set the path parameters.
virtual void | setPathParam (const std::string &param, const std::string &value)
| Set or add value for the specified path parameter.
virtual void | setQueryString (const std::string &querystr)
| Set the query string in the URL.
virtual void | setQueryStringVec (const zypp::url::ParamVec &qvec)
| Set the query parameters.
virtual void | setQueryStringMap (const zypp::url::ParamMap &qmap, EEncoding eflag)
| Set the query parameters.
virtual void | setQueryParam (const std::string &param, const std::string &value)
| Set or add value for the specified query parameter.
virtual void | delQueryParam (const std::string &param)
| remove the specified query parameter.
void | delQueryParams (const std::set< std::string > &params)
virtual void | setFragment (const std::string &fragment, EEncoding eflag)
| Set the fragment string in the URL.
virtual void | configure ()
| Configures behaviour of the instance.
std::string | config (const std::string &opt) const
| Get the value of a UrlBase configuration variable.
void | config (const std::string &opt, const std::string &val)
| Set the value of a UrlBase configuration variable.
ViewOptions | getViewOptions () const
| Return the view options of the current object.
void | setViewOptions (const ViewOptions &vopts)
| Change the view options of the current object.
std::string | asString1050625 () const

## Protected Member Functions
virtual std::string | cleanupPathName (const std::string &path, bool authority) const
| Utility method to cleanup an encoded path name.
virtual std::string | cleanupPathName (const std::string &path) const
| Utility method to cleanup an encoded path name.
virtual bool | isValidHost (const std::string &host) const
| Verifies specified host or IP.
virtual bool | isValidPort (const std::string &port) const
| Verifies specified port number.

## Private Attributes
UrlBaseData * | m_data

## Detailed Description

Generic Url base class.

The UrlBase class implements default behaviour for URL manipulations and a base for implementation of scheme- specialized URLs for the Url class.

Definition at line 271 of file UrlBase.h.

## Constructor & Destructor Documentation

## ◆ ~UrlBase()

zypp::url::UrlBase::~UrlBase | ( |  | ) |
| virtual

Definition at line 258 of file UrlBase.cc.

## ◆ UrlBase() [1/3]

zypp::url::UrlBase::UrlBase | ( |  | ) |

Definition at line 266 of file UrlBase.cc.

## ◆ UrlBase() [2/3]

zypp::url::UrlBase::UrlBase | ( | const UrlBase & | url | ) |

Create a new Url object as copy of the given one.

Parameters

  url | The Url object to make a copy of.

Definition at line 274 of file UrlBase.cc.

## ◆ UrlBase() [3/3]

zypp::url::UrlBase::UrlBase | ( | const std::string & | scheme,
|  | const std::string & | authority,
|  | const std::string & | pathdata,
|  | const std::string & | querystr,
|  | const std::string & | fragment )

Construct new object and initializes it with specified URL components.

Parameters

  scheme | The scheme name.
  authority | The encoded authority component data.
  pathdata | The encoded path component data.
  querystr | The encoded query string component.
  fragment | The encoded fragment string component.

Exceptions

  UrlNotAllowedException | if one of the components is not allowed for the scheme.
  UrlBadComponentException | if one of the components contains an invalid character.

Definition at line 281 of file UrlBase.cc.

## Member Function Documentation

## ◆ clear()

void zypp::url::UrlBase::clear | ( |  | ) |
| virtual

Clears all data in the object.

Definition at line 396 of file UrlBase.cc.

## ◆ clone()

UrlBase * zypp::url::UrlBase::clone | ( |  | ) | const
| virtual

Returns pointer to a copy of the current object.

Should be reimplemented by all derived object using the copy constructor of the derived class, e.g.:

return new MyUrlDerivedFromUrlBase(*this);

Returns
  A pointer to a copy of the current object.

Definition at line 408 of file UrlBase.cc.

## ◆ init()

void zypp::url::UrlBase::init | ( | const std::string & | scheme,
|  | const std::string & | authority,
|  | const std::string & | pathdata,
|  | const std::string & | querystr,
|  | const std::string & | fragment )
| virtual

Initializes current object with new URL components.

Parameters

  scheme | The scheme name.
  authority | The encoded authority component data.
  pathdata | The encoded path component data.
  querystr | The encoded query string component.
  fragment | The encoded fragment string component.

Exceptions

  UrlNotAllowedException | if one of the components is not allowed in the scheme.
  UrlBadComponentException | if one of the components contains an invalid character.

Definition at line 295 of file UrlBase.cc.

## ◆ getKnownSchemes()

zypp::url::UrlSchemes zypp::url::UrlBase::getKnownSchemes | ( |  | ) | const
| virtual

Returns scheme names known by this object.

This method is used in the isValidScheme() method and is intended to be reimplemented by derived classes to return the scheme names it implements (is restricted or compatible to).

For example, if your derived class implements special features of LDAP URLs, this method may return "ldap" and "ldaps" scheme names.

The UrlBase class returns an empty vector, that signals that it is useable with all URLs.

Returns
  A vector with scheme names known by this object.

Definition at line 416 of file UrlBase.cc.

## ◆ isKnownScheme()

bool zypp::url::UrlBase::isKnownScheme | ( | const std::string & | scheme | ) | const
| virtual

Returns if scheme name is known to this object.

Returns
  True, if scheme name is known to this object.

Definition at line 424 of file UrlBase.cc.

## ◆ isValidScheme()

bool zypp::url::UrlBase::isValidScheme | ( | const std::string & | scheme | ) | const
| virtual

Verifies specified scheme name.

Verifies the generic syntax of the specified `scheme` name and if it is contained in the current object's list of known schemes (see getKnownSchemes()) if the list is not empty (as in the UrlBase class).

Parameters

  scheme | The scheme name to verify.

Returns
  True, if generic scheme name syntax is valid and the scheme name is known to the current object.

Definition at line 441 of file UrlBase.cc.

## ◆ isValid()

bool zypp::url::UrlBase::isValid | ( |  | ) | const
| virtual

Verifies the Url.

Verifies if the current object contains a non-empty scheme name. Additional semantical URL checks may be performed by derived UrlBase-objects.

Returns
  True, if the Url seems to be valid.

Definition at line 473 of file UrlBase.cc.

## ◆ asString() [1/2]

std::string zypp::url::UrlBase::asString | ( |  | ) | const
| virtual

Returns a default string representation of the Url object.

By default, a password in the URL will be hidden.

Returns
  A default string representation of the Url object.

Definition at line 505 of file UrlBase.cc.

## ◆ asString() [2/2]

std::string zypp::url::UrlBase::asString | ( | const zypp::url::ViewOptions & | opts | ) | const
| virtual

Returns a string representation of the Url object.

To include a password in the resulting Url string, use:

url.asString(url.getViewOptions() +
url::ViewOptions::WITH_PASSWORD);
zypp::url
Url details namespace.
Definition UrlBase.cc:58

Parameters

  opts | A combination of view options.

Returns
  A string representation of the Url object.

Definition at line 519 of file UrlBase.cc.

## ◆ getScheme()

std::string zypp::url::UrlBase::getScheme | ( |  | ) | const
| virtual

Returns the scheme name of the URL.

Returns
  Scheme name of the current Url object.

Definition at line 653 of file UrlBase.cc.

## ◆ getAuthority()

std::string zypp::url::UrlBase::getAuthority | ( |  | ) | const
| virtual

Returns the encoded authority component of the URL.

The returned authority string does not contain the leading "//" separator characters, but just its "user:pass@host:port" content only.

Returns
  The encoded authority component string.

Definition at line 661 of file UrlBase.cc.

## ◆ getUsername()

std::string zypp::url::UrlBase::getUsername | ( | EEncoding | eflag | ) | const
| virtual

Returns the username from the URL authority.

Parameters

  eflag | Flag if the usename should be percent-decoded or not.

Returns
  The username sub-component from the URL authority.

Exceptions

  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 722 of file UrlBase.cc.

## ◆ getPassword()

std::string zypp::url::UrlBase::getPassword | ( | EEncoding | eflag | ) | const
| virtual

Returns the password from the URL authority.

Parameters

  eflag | Flag if the password should be percent-decoded or not.

Returns
  The password sub-component from the URL authority.

Exceptions

  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 733 of file UrlBase.cc.

## ◆ getHost()

std::string zypp::url::UrlBase::getHost | ( | EEncoding | eflag | ) | const
| virtual

Returns the hostname or IP from the URL authority.

In case the Url contains an IPv6 number, it is be surrounded by "[" and "]" characters, for example "[::1]" for an IPv6 localhost address.

Parameters

  eflag | Flag if the host should be percent-decoded or not.

Returns
  The host sub-component from the URL authority.

Exceptions

  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 744 of file UrlBase.cc.

## ◆ getPort()

std::string zypp::url::UrlBase::getPort | ( |  | ) | const
| virtual

Returns the port number from the URL authority.

Returns
  The port sub-component from the URL authority.

Definition at line 755 of file UrlBase.cc.

## ◆ getPathData()

std::string zypp::url::UrlBase::getPathData | ( |  | ) | const
| virtual

Returns the encoded path component of the URL.

The path data contains the path name, optionally followed by path parameters separated with a ";" character, for example "/foo/bar;version=1.1".

Returns
  The encoded path component of the URL.

Definition at line 688 of file UrlBase.cc.

## ◆ getPathName()

std::string zypp::url::UrlBase::getPathName | ( | EEncoding | eflag | ) | const
| virtual

Returns the path name from the URL.

Parameters

  eflag | Flag if the path should be decoded or not.

Returns
  The path name sub-component without path parameters from path data component of the URL.

Exceptions

  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 763 of file UrlBase.cc.

## ◆ getPathParams()

std::string zypp::url::UrlBase::getPathParams | ( |  | ) | const
| virtual

Returns the encoded path parameters from the URL.

Returns
  The encoded path parameters from the URL.

Definition at line 774 of file UrlBase.cc.

## ◆ getPathParamsVec()

zypp::url::ParamVec zypp::url::UrlBase::getPathParamsVec | ( |  | ) | const
| virtual

Returns a vector with encoded path parameter substrings.

The default path parameter separator is the `'`,' character. A schema specific object may overide the default separators.

For example, the path parameters string "foo=1,bar=2" is splited by default into a vector containing the substrings "foo=1" and "bar=2".

Returns
  The encoded path parameters vector.

Definition at line 782 of file UrlBase.cc.

## ◆ getPathParamsMap()

zypp::url::ParamMap zypp::url::UrlBase::getPathParamsMap | ( | EEncoding | eflag | ) | const
| virtual

Returns a string map with path parameter keys and values.

The default path parameter separator is the `'`,' character, the default key/value separator for the path parameters is the `'='` character. A schema specific object may overide the default separators.

For example, the path parameters string "foo=1,bar=2" is splited into a map containing "foo" = "1" and "bar" = "2" by default.

Parameters

  eflag | Flag if the path parameter keys and values should be decoded or not.

Returns
  The path parameters key and values as a string map.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).
  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 803 of file UrlBase.cc.

## ◆ getPathParam()

std::string zypp::url::UrlBase::getPathParam | ( | const std::string & | param,
|  | EEncoding | eflag ) const
| virtual

Return the value for the specified path parameter.

For example, if the path parameters string is "foo=1,bar=2" the method will return the substring "1" for the param key "foo" and "2" for the param key "bar".

Parameters

  param | The path parameter key.
  eflag | Flag if the path parameter keys and values should be decoded or not.

Returns
  The value for the path parameter key or empty string.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).
  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 826 of file UrlBase.cc.

## ◆ getQueryString() [1/2]

std::string zypp::url::UrlBase::getQueryString | ( |  | ) | const
| virtual

Returns the encoded query string component of the URL.

The query string is returned without first "?" (separator) character. Further "?" characters as in e.g. LDAP URLs remains in the returned string.

Returns
  The encoded query string component of the URL.

Definition at line 698 of file UrlBase.cc.

## ◆ getQueryString() [2/2]

std::string zypp::url::UrlBase::getQueryString | ( | const ViewOptions & | viewopts_r | ) | const
| virtual

Definition at line 704 of file UrlBase.cc.

## ◆ getQueryStringVec()

zypp::url::ParamVec zypp::url::UrlBase::getQueryStringVec | ( |  | ) | const
| virtual

Returns a vector with query string parameter substrings.

The default query string parameter separator is the `'&'` character. A schema specific object may overide the default separators.

For example, the query string "foo=1&bar=2" is splited by default into a vector containing the substrings "foo=1" and "bar=2".

Returns
  The query string splited into a vector of substrings.

Definition at line 837 of file UrlBase.cc.

## ◆ getQueryStringMap()

zypp::url::ParamMap zypp::url::UrlBase::getQueryStringMap | ( | EEncoding | eflag | ) | const
| virtual

Returns a string map with query parameter and their values.

The default query string parameter separator is the `'`,' character, the default key/value separator the `'='` character. A schema specific object may overide the default separators.

For example, the query string "foo=1&bar=2" is splited by default into a map containing "foo" = "1" and "bar" = "2".

Parameters

  eflag | Flag if the query string keys and values should be decoded or not.

Returns
  The query string as a key/value string map.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).
  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 858 of file UrlBase.cc.

## ◆ getQueryParam()

std::string zypp::url::UrlBase::getQueryParam | ( | const std::string & | param,
|  | EEncoding | eflag ) const
| virtual

Return the value for the specified query parameter.

For example, if the query string is "foo=1,bar=2" the method will return the substring "1" for the param key "foo" and "2" for the param key "bar".

Parameters

  param | The query parameter key.
  eflag | Flag if the query parameter keys and values should be decoded or not.

Returns
  The value for the query parameter key or empty string.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).
  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 881 of file UrlBase.cc.

## ◆ getFragment()

std::string zypp::url::UrlBase::getFragment | ( | EEncoding | eflag | ) | const
| virtual

Returns the encoded fragment component of the URL.

Parameters

  eflag | Flag if the fragment should be percent-decoded or not.

Returns
  The encoded fragment component of the URL.

Exceptions

  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 711 of file UrlBase.cc.

## ◆ setScheme()

void zypp::url::UrlBase::setScheme | ( | const std::string & | scheme | ) |
| virtual

Set the scheme name in the URL.

Parameters

  scheme | The new scheme name.

Exceptions

  UrlBadComponentException | if the `scheme` contains an invalid character or is empty.

Definition at line 892 of file UrlBase.cc.

## ◆ setAuthority()

void zypp::url::UrlBase::setAuthority | ( | const std::string & | authority | ) |
| virtual

Set the authority component in the URL.

The `authority` string shoud not contain any leading "//" separator characters (just "user:pass@host:port").

Parameters

  authority | The authority component string.

Exceptions

  UrlNotAllowedException | if the `authority` has to be empty in for the current scheme.
  UrlBadComponentException | if the `authority` contains an invalid character.
  UrlParsingException | if `authority` parsing fails.

Definition at line 916 of file UrlBase.cc.

## ◆ setUsername()

void zypp::url::UrlBase::setUsername | ( | const std::string & | user,
|  | EEncoding | eflag )
| virtual

Set the username in the URL authority.

Parameters

  user | The new username.
  eflag | If the `username` is encoded or not.

Exceptions

  UrlNotAllowedException | if the `user` has to be empty in for the current scheme.
  UrlBadComponentException | if the `user` contains an invalid character.

Definition at line 1013 of file UrlBase.cc.

## ◆ setPassword()

void zypp::url::UrlBase::setPassword | ( | const std::string & | pass,
|  | EEncoding | eflag )
| virtual

Set the password in the URL authority.

Parameters

  pass | The new password.
  eflag | If the `password` is encoded or not.

Exceptions

  UrlNotAllowedException | if the `pass` has to be empty in for the current scheme.
  UrlBadComponentException | if the `pass` contains an invalid character.

Definition at line 1047 of file UrlBase.cc.

## ◆ setHost()

void zypp::url::UrlBase::setHost | ( | const std::string & | host | ) |
| virtual

Set the hostname or IP in the URL authority.

The `host` parameter may contain a hostname, an IPv4 address in dotted-decimal form or an IPv6 address literal encapsulated within square brackets (RFC3513, Sect. 2.2).

A hostname may contain national alphanumeric UTF8 characters (letters other than ASCII a-zA-Z), that will be encoded. This function allows to specify both, a encoded or decoded hostname.

Other IP literals in "[v ... ]" square bracket format are not supported by the implementation in UrlBase class.

Parameters

  host | The new hostname or IP address.

Exceptions

  UrlNotAllowedException | if the `host` has to be empty in for the current scheme.
  UrlBadComponentException | if the `host` is invalid.

Definition at line 1081 of file UrlBase.cc.

## ◆ setPort()

void zypp::url::UrlBase::setPort | ( | const std::string & | port | ) |
| virtual

Set the port number in the URL authority.

Parameters

  port | The new port number.

Exceptions

  UrlNotAllowedException | if the `port` has to be empty in for the current scheme.
  UrlBadComponentException | if the `port` is invalid.

Definition at line 1134 of file UrlBase.cc.

## ◆ setPathData()

void zypp::url::UrlBase::setPathData | ( | const std::string & | pathdata | ) |
| virtual

Set the path data component in the URL.

By default, the `pathdata` string may include path parameters separated by the ";" separator character.

Parameters

  pathdata | The encoded path data component string.

Exceptions

  UrlBadComponentException | if the `pathdata` contains an invalid character.

Definition at line 944 of file UrlBase.cc.

## ◆ setPathName()

void zypp::url::UrlBase::setPathName | ( | const std::string & | path,
|  | EEncoding | eflag )
| virtual

Set the path name.

Parameters

  path | The new path name.
  eflag | If the `path` name is encoded or not.

Exceptions

  UrlBadComponentException | if the `path` name contains an invalid character.

Definition at line 1166 of file UrlBase.cc.

## ◆ setPathParams()

void zypp::url::UrlBase::setPathParams | ( | const std::string & | params | ) |
| virtual

Set the path parameters.

Parameters

  params | The new encoded path parameter string.

Exceptions

  UrlBadComponentException | if the path `params` contains an invalid character.

Definition at line 1226 of file UrlBase.cc.

## ◆ setPathParamsVec()

void zypp::url::UrlBase::setPathParamsVec | ( | const zypp::url::ParamVec & | pvec | ) |
| virtual

Set the path parameters.

Parameters

  pvec | The vector with encoded path parameters.

Exceptions

  UrlBadComponentException | if the `pvec` contains an invalid character.

Definition at line 1243 of file UrlBase.cc.

## ◆ setPathParamsMap()

void zypp::url::UrlBase::setPathParamsMap | ( | const zypp::url::ParamMap & | pmap | ) |
| virtual

Set the path parameters.

Parameters

  pmap | The map with decoded path parameters.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).

Definition at line 1256 of file UrlBase.cc.

## ◆ setPathParam()

void zypp::url::UrlBase::setPathParam | ( | const std::string & | param,
|  | const std::string & | value )
| virtual

Set or add value for the specified path parameter.

Parameters

  param | The decoded path parameter name.
  value | The decoded path parameter value.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).
  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 1279 of file UrlBase.cc.

## ◆ setQueryString()

void zypp::url::UrlBase::setQueryString | ( | const std::string & | querystr | ) |
| virtual

Set the query string in the URL.

The `querystr` string parameter is supposed to not to contain the "?" URL query separator character (use just a "foo=bar&x=22" instead of "?foo=bar&x=22").

Parameters

  querystr | The new encoded query string.

Exceptions

  UrlBadComponentException | if the `querystr` contains an invalid character.

Definition at line 969 of file UrlBase.cc.

## ◆ setQueryStringVec()

void zypp::url::UrlBase::setQueryStringVec | ( | const zypp::url::ParamVec & | qvec | ) |
| virtual

Set the query parameters.

Parameters

  qvec | The vector with encoded query parameters.

Exceptions

  UrlBadComponentException | if the `qvec` contains an invalid character.

Definition at line 1289 of file UrlBase.cc.

## ◆ setQueryStringMap()

void zypp::url::UrlBase::setQueryStringMap | ( | const zypp::url::ParamMap & | qmap,
|  | EEncoding | eflag )
| virtual

Set the query parameters.

Parameters

  qmap | The map with decoded query parameters.
  eflag | Tells whether keys and values in pmap are already encoded or decoded.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).

Definition at line 1302 of file UrlBase.cc.

## ◆ setQueryParam()

void zypp::url::UrlBase::setQueryParam | ( | const std::string & | param,
|  | const std::string & | value )
| virtual

Set or add value for the specified query parameter.

Parameters

  param | The decoded query parameter name.
  value | The decoded query parameter value.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).
  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 1324 of file UrlBase.cc.

## ◆ delQueryParam()

void zypp::url::UrlBase::delQueryParam | ( | const std::string & | param | ) |
| virtual

remove the specified query parameter.

Parameters

  param | The decoded query parameter name.

Exceptions

  UrlNotSupportedException | if parameter parsing is not supported for a URL (scheme).
  UrlDecodingException | if the decoded result string would contain a '\0' character.

Definition at line 1348 of file UrlBase.cc.

## ◆ delQueryParams()

void zypp::url::UrlBase::delQueryParams | ( | const std::set< std::string > & | params | ) |

Definition at line 1364 of file UrlBase.cc.

## ◆ setFragment()

void zypp::url::UrlBase::setFragment | ( | const std::string & | fragment,
|  | EEncoding | eflag )
| virtual

Set the fragment string in the URL.

Parameters

  fragment | The new fragment string.
  eflag | If the `fragment` is encoded or not.

Exceptions

  UrlBadComponentException | if the `querystr` contains an invalid character.

Definition at line 986 of file UrlBase.cc.

## ◆ configure()

void zypp::url::UrlBase::configure | ( |  | ) |
| virtual

Configures behaviour of the instance.

This method is called in UrlBase constructors before any URL components are applied. Derived classes may reimplement this method to change the behaviour of the object. Use the config() methods to query and change them.

The UrlBase class uses following config variables:

- Common path parameter separators:
  - `sep_pathparams` `";"` Separator used to split path parameters from path name. Setting it to empty string disables splitting of path name and path parameters. Set also rx_pathparams to an empty string.
  - `psep_pathparam` `","` Separator between path parameters.
  - `vsep_pathparam` `"="` Separator between key and value of a path parameter.

- Common query string separators:
  - `psep_querystr` `"&"` Separator between query string parameters.
  - `vsep_querystr` `"="` Separator between key and value of a query parameter.

- Characters in URL components, that are safe without URL percent-encoding (see zypp::url::encode()).
  - safe_username
  - safe_password
  - safe_hostname
  - safe_pathname
  - safe_pathparams
  - safe_querystr
  - safe_fragment

- Regular expressions used to verify encoded URL components and their sub-components:
  - rx_username
  - rx_password
  - rx_pathname
  - rx_pathparams
  - rx_querystr
  - rx_fragment

Definition at line 315 of file UrlBase.cc.

## ◆ config() [1/2]

std::string zypp::url::UrlBase::config | ( | const std::string & | opt | ) | const

Get the value of a UrlBase configuration variable.

See configure() method for names an purpose of the configuration variables used in UrlBase class.

Parameters

  opt | The name of the configuration variable.

Returns
  The value of the specified variable or empty string.

Definition at line 368 of file UrlBase.cc.

## ◆ config() [2/2]

void zypp::url::UrlBase::config | ( | const std::string & | opt,
|  | const std::string & | val )

Set the value of a UrlBase configuration variable.

See configure() method for names an purpose of the configuration variables used in UrlBase class.

Parameters

  opt | The name of the configuration variable.
  val | The new value for the configuration variable.

Definition at line 360 of file UrlBase.cc.

## ◆ getViewOptions()

ViewOptions zypp::url::UrlBase::getViewOptions | ( |  | ) | const

Return the view options of the current object.

This method is used to query the view options used by the asString() method.

Returns
  The current view option combination.

Definition at line 380 of file UrlBase.cc.

## ◆ setViewOptions()

void zypp::url::UrlBase::setViewOptions | ( | const ViewOptions & | vopts | ) |

Change the view options of the current object.

This method is used to change the view options used by the asString() method.

Parameters

  vopts | New view options combination.

Definition at line 388 of file UrlBase.cc.

## ◆ asString1050625()

std::string zypp::url::UrlBase::asString1050625 | ( |  | ) | const

Definition at line 510 of file UrlBase.cc.

## ◆ cleanupPathName() [1/2]

std::string zypp::url::UrlBase::cleanupPathName | ( | const std::string & | path,
|  | bool | authority ) const
| protectedvirtual

Utility method to cleanup an encoded path name.

By default, this method makes sure, that the first slash in the path is not encoded, and that the second slash before the first path segment, is encoded (to "%2F"). It modifies the path in the url, for example: "ftp://host//aaa//bbb" to "ftp://host/%2Faaa//bbb" or as encoded path only also "%2f/name" to "/%2fname".

This operation is required to fulfill the path-absolute rule of RFC3986, if there is no authority. It avoids the missinterpretation of the path as an authority separator.

It is not required if there is an authority ("//" behind the "scheme:"), that is in the path-abempty rule, but it is used e.g. in ftp url's defined by RFC1738.

We apply this operation in both cases (for all paths), but if `authority` is true, the encoding of the second slash depends on the schema configuration (for ftp only).

Parameters

  path | The encoded path name to cleanup.
  authority | Whether the url contains authority or not.

Returns
  A modified encoded path.

Definition at line 1389 of file UrlBase.cc.

## ◆ cleanupPathName() [2/2]

std::string zypp::url::UrlBase::cleanupPathName | ( | const std::string & | path | ) | const
| protectedvirtual

Utility method to cleanup an encoded path name.

This variant of the method checks if the host component in the url is empty or not to differentiate if there is an authority.

Parameters

  path | The encoded path name to cleanup.

Returns
  A modified encoded path.

Definition at line 1381 of file UrlBase.cc.

## ◆ isValidHost()

bool zypp::url::UrlBase::isValidHost | ( | const std::string & | host | ) | const
| protectedvirtual

Verifies specified host or IP.

It verifies, if the specified `host` parameter contains a hostname, an IPv4 address in dotted-decimal form or an IPv6 address literal encapsulated within square brackets (RFC3513, Sect. 2.2).

A hostname in the `host` parameter, may contain national alphanumeric UTF8 characters (letters other than ASCII a-zA-Z) and allows to specify both, a encoded or decoded hostname.

This function does not perform any hostname lookups and supports only IPv6 addresses in "[ ... ]" notation. The "[v ... ]" square bracket format is not supported by this implementation.

Parameters

  host | The host name or IP to verify.

Returns
  True, if host seems to be valid.

Definition at line 1441 of file UrlBase.cc.

## ◆ isValidPort()

bool zypp::url::UrlBase::isValidPort | ( | const std::string & | port | ) | const
| protectedvirtual

Verifies specified port number.

Parameters

  port | The port number to verify.

Returns
  True, if port number is valid.

Definition at line 1470 of file UrlBase.cc.

## Member Data Documentation

## ◆ m_data

UrlBaseData* zypp::url::UrlBase::m_data
| private

Definition at line 1085 of file UrlBase.h.

The documentation for this class was generated from the following files:

- zypp-core/url/UrlBase.h
- zypp-core/url/UrlBase.cc