#include <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 ¶m, 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 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 ¶m, 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 ¶ms) |
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 ¶m, 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) |
Set the query parameters. | |
virtual void | setQueryParam (const std::string ¶m, const std::string &value) |
Set or add value for the specified query parameter. | |
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. | |
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 |
The UrlBase class implements default behaviour for URL manipulations and a base for implementation of scheme- specialized URL's for the Url class.
Definition at line 270 of file UrlBase.h.
|
Definition at line 176 of file UrlBase.cc. References m_data. |
|
Definition at line 184 of file UrlBase.cc. References configure(). Referenced by clone(). |
|
Create a new Url object as copy of the given one.
Definition at line 192 of file UrlBase.cc. |
|
Construct new object and initializes it with specified URL components.
Definition at line 199 of file UrlBase.cc. References configure(), and init(). |
|
Clears all data in the object.
Definition at line 310 of file UrlBase.cc. References zypp::url::UrlBaseData::config, config(), m_data, and zypp::url::UrlBaseData::vopts. |
|
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);
Definition at line 322 of file UrlBase.cc. References UrlBase(). |
|
Initializes current object with new URL components.
Definition at line 213 of file UrlBase.cc. References zypp::url::E_ENCODED, setAuthority(), setFragment(), setPathData(), setQueryString(), and setScheme(). Referenced by UrlBase(). |
|
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 URL's, this method may return "ldap" and "ldaps" scheme names. The UrlBase class returns an empty vector, that signals that it is useable with all URL's.
Definition at line 330 of file UrlBase.cc. Referenced by isKnownScheme(), and isValidScheme(). |
|
Returns if scheme name is known to this object.
Definition at line 338 of file UrlBase.cc. References getKnownSchemes(), and zypp::str::toLower(). |
|
Verifies specified scheme name.
Verifies the generic syntax of the specified
Definition at line 355 of file UrlBase.cc. References getKnownSchemes(), RX_VALID_SCHEME, and zypp::str::toLower(). Referenced by setScheme(). |
|
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.
Definition at line 387 of file UrlBase.cc. References config(), zypp::url::E_ENCODED, getHost(), getPathName(), and getScheme(). |
|
Returns a default string representation of the Url object. By default, a password in the URL will be hidden.
Definition at line 419 of file UrlBase.cc. References getViewOptions(). |
|
Returns a string representation of the Url object. To include a password in the resulting Url string, use:
Definition at line 427 of file UrlBase.cc. References zypp::url::E_ENCODED, getHost(), getPassword(), getScheme(), getUsername(), zypp::url::ViewOption::has(), zypp::url::UrlBaseData::host, zypp::url::UrlBaseData::pass, zypp::url::UrlBaseData::scheme, url, zypp::url::UrlBaseData::user, zypp::url::ViewOption::WITH_HOST, zypp::url::ViewOption::WITH_PASSWORD, zypp::url::ViewOption::WITH_SCHEME, and zypp::url::ViewOption::WITH_USERNAME. |
|
Returns the scheme name of the URL.
Definition at line 561 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::scheme. Referenced by asString(), and isValid(). |
|
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.
Definition at line 569 of file UrlBase.cc. References zypp::url::E_ENCODED, getHost(), getPassword(), getPort(), getUsername(), and zypp::solver::detail::str. |
|
Returns the username from the URL authority.
Definition at line 625 of file UrlBase.cc. References zypp::url::decode(), zypp::url::E_DECODED, m_data, and zypp::url::UrlBaseData::user. Referenced by asString(), and getAuthority(). |
|
Returns the password from the URL authority.
Definition at line 636 of file UrlBase.cc. References zypp::url::decode(), zypp::url::E_DECODED, m_data, and zypp::url::UrlBaseData::pass. Referenced by asString(), and getAuthority(). |
|
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.
Definition at line 647 of file UrlBase.cc. References zypp::url::decode(), zypp::url::E_DECODED, zypp::url::UrlBaseData::host, and m_data. Referenced by asString(), cleanupPathName(), getAuthority(), and isValid(). |
|
Returns the port number from the URL authority.
Definition at line 658 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::port. Referenced by getAuthority(). |
|
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".
Definition at line 596 of file UrlBase.cc. References config(), zypp::url::E_ENCODED, getPathName(), and getPathParams(). |
|
Returns the path name from the URL.
Definition at line 666 of file UrlBase.cc. References cleanupPathName(), zypp::url::decode(), zypp::url::E_DECODED, m_data, and zypp::url::UrlBaseData::pathname. Referenced by getPathData(), and isValid(). |
|
Returns the encoded path parameters from the URL.
Definition at line 677 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::pathparams. Referenced by getPathData(), getPathParamsMap(), and getPathParamsVec(). |
|
Returns a vector with encoded path parameter substrings.
The default path parameter separator is the 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".
Definition at line 685 of file UrlBase.cc. References config(), getPathParams(), and zypp::url::split(). |
|
Returns a string map with path parameter keys and values.
The default path parameter separator is the For example, the path parameters string "foo=1,bar=2" is splited into a map containing "foo" = "1" and "bar" = "2" by default.
Definition at line 706 of file UrlBase.cc. References config(), getPathParams(), zypp::url::split(), and ZYPP_THROW. Referenced by getPathParam(), and setPathParam(). |
|
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".
Definition at line 729 of file UrlBase.cc. References getPathParamsMap(). |
|
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 URL's remains in the returned string.
Definition at line 606 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::querystr. Referenced by getQueryStringMap(), and getQueryStringVec(). |
|
Returns a vector with query string parameter substrings.
The default query string parameter separator is the For example, the query string "foo=1&bar=2" is splited by default into a vector containing the substrings "foo=1" and "bar=2".
Definition at line 740 of file UrlBase.cc. References config(), getQueryString(), and zypp::url::split(). |
|
Returns a string map with query parameter and their values.
The default query string parameter separator is the For example, the query string "foo=1&bar=2" is splited by default into a map containing "foo" = "1" and "bar" = "2".
Definition at line 761 of file UrlBase.cc. References config(), getQueryString(), zypp::url::split(), and ZYPP_THROW. Referenced by getQueryParam(), and setQueryParam(). |
|
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".
Definition at line 784 of file UrlBase.cc. References getQueryStringMap(). |
|
Returns the encoded fragment component of the URL.
Definition at line 614 of file UrlBase.cc. References zypp::url::decode(), zypp::url::E_DECODED, zypp::url::UrlBaseData::fragment, and m_data. |
|
Set the scheme name in the URL.
Definition at line 795 of file UrlBase.cc. References isValidScheme(), m_data, zypp::url::UrlBaseData::scheme, zypp::str::toLower(), and ZYPP_THROW. Referenced by init(). |
|
Set the authority component in the URL.
The
Definition at line 819 of file UrlBase.cc. References zypp::url::E_ENCODED, RX_SPLIT_AUTHORITY, setHost(), setPassword(), setPort(), setUsername(), and zypp::solver::detail::str. Referenced by init(). |
|
Set the username in the URL authority.
Definition at line 918 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::user. Referenced by setAuthority(). |
|
Set the password in the URL authority.
Definition at line 952 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::pass. Referenced by setAuthority(). |
|
Set the hostname or IP in the URL authority.
The 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.
Definition at line 986 of file UrlBase.cc. References config(), zypp::url::UrlBaseData::host, m_data, and ZYPP_THROW. Referenced by setAuthority(). |
|
Set the port number in the URL authority.
Definition at line 1039 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::port. Referenced by setAuthority(). |
|
Set the path data component in the URL.
By default, the
Definition at line 849 of file UrlBase.cc. References config(), zypp::url::E_ENCODED, setPathName(), and setPathParams(). Referenced by init(). |
|
Set the path name.
Definition at line 1071 of file UrlBase.cc. References config(), m_data, zypp::url::UrlBaseData::pathname, and ZYPP_THROW. Referenced by setPathData(). |
|
Set the path parameters.
Definition at line 1131 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::pathparams. Referenced by setPathData(), setPathParamsMap(), and setPathParamsVec(). |
|
Set the path parameters.
Definition at line 1148 of file UrlBase.cc. References config(), zypp::url::join(), and setPathParams(). |
|
Set the path parameters.
Definition at line 1161 of file UrlBase.cc. References config(), zypp::url::join(), setPathParams(), and ZYPP_THROW. Referenced by setPathParam(). |
|
Set or add value for the specified path parameter.
Definition at line 1183 of file UrlBase.cc. References zypp::url::E_DECODED, getPathParamsMap(), and setPathParamsMap(). |
|
Set the query string in the URL.
The
Definition at line 874 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::querystr. Referenced by init(), setQueryStringMap(), and setQueryStringVec(). |
|
Set the query parameters.
Definition at line 1193 of file UrlBase.cc. References config(), zypp::url::join(), and setQueryString(). |
|
Set the query parameters.
Definition at line 1206 of file UrlBase.cc. References config(), zypp::url::join(), setQueryString(), and ZYPP_THROW. Referenced by setQueryParam(). |
|
Set or add value for the specified query parameter.
Definition at line 1227 of file UrlBase.cc. References zypp::url::E_DECODED, getQueryStringMap(), and setQueryStringMap(). |
|
Set the fragment string in the URL.
Definition at line 891 of file UrlBase.cc. References zypp::url::UrlBaseData::fragment, and m_data. Referenced by init(). |
|
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:
Definition at line 229 of file UrlBase.cc. References config(). Referenced by UrlBase(). |
|
Get the value of a UrlBase configuration variable. See configure() method for names an purpose of the configuration variables used in UrlBase class.
Definition at line 282 of file UrlBase.cc. References zypp::url::UrlBaseData::config, and m_data. Referenced by cleanupPathName(), clear(), configure(), getPathData(), getPathParamsMap(), getPathParamsVec(), getQueryStringMap(), getQueryStringVec(), isValid(), setHost(), setPathData(), setPathName(), setPathParamsMap(), setPathParamsVec(), setQueryStringMap(), and setQueryStringVec(). |
|
Set the value of a UrlBase configuration variable. See configure() method for names an purpose of the configuration variables used in UrlBase class.
Definition at line 274 of file UrlBase.cc. References zypp::url::UrlBaseData::config, and m_data. |
|
Return the view options of the current object. This method is used to query the view options used by the asString() method.
Definition at line 294 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::vopts. Referenced by asString(). |
|
Change the view options of the current object. This method is used to change the view options used by the asString() method.
Definition at line 302 of file UrlBase.cc. References m_data, and zypp::url::UrlBaseData::vopts. |
|
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
Definition at line 1245 of file UrlBase.cc. References config(), zypp::filesystem::copy(), and zypp::str::toLower(). Referenced by cleanupPathName(), and getPathName(). |
|
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.
Definition at line 1237 of file UrlBase.cc. References cleanupPathName(), zypp::url::E_ENCODED, and getHost(). |
|
Verifies specified host or IP.
It verifies, if the specified
A hostname in the 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.
Definition at line 1297 of file UrlBase.cc. References zypp::url::decode(), RX_VALID_HOSTIPV6, and RX_VALID_HOSTNAME. |
|
Verifies specified port number.
Definition at line 1326 of file UrlBase.cc. References RX_VALID_PORT. |
|
Definition at line 1066 of file UrlBase.h. Referenced by clear(), config(), getFragment(), getHost(), getPassword(), getPathName(), getPathParams(), getPort(), getQueryString(), getScheme(), getUsername(), getViewOptions(), setFragment(), setHost(), setPassword(), setPathName(), setPathParams(), setPort(), setQueryString(), setScheme(), setUsername(), setViewOptions(), and ~UrlBase(). |