#include <Url.h>
Public Types | |
typedef zypp::url::EEncoding | EEncoding |
Encoding flags. | |
typedef zypp::url::ViewOptions | ViewOptions |
View options. | |
Public Member Functions | |
~Url () | |
Url () | |
Url (const Url &url) | |
Create a new Url object as shared copy of the given one. | |
Url (const zypp::url::UrlRef &url) | |
Create a new Url object as shared copy of the given reference. | |
Url (const std::string &encodedUrl) | |
Construct a Url object from percent-encoded URL string. | |
Url & | operator= (const std::string &encodedUrl) |
Assigns parsed percent-encoded URL string to the object. | |
Url & | operator= (const Url &url) |
Assign shared copy of url to the current object. | |
zypp::url::UrlSchemes | getKnownSchemes () const |
Returns scheme names known to this object. | |
bool | isValidScheme (const std::string &scheme) const |
Verifies specified scheme name. | |
bool | isValid () const |
Verifies the Url. | |
std::string | asString () const |
Returns a default string representation of the Url object. | |
std::string | asString (const ViewOptions &opts) const |
Returns a string representation of the Url object. | |
std::string | asCompleteString () const |
Returns a complete string representation of the Url object. | |
std::string | getScheme () const |
Returns the scheme name of the URL. | |
std::string | getAuthority () const |
Returns the encoded authority component of the URL. | |
std::string | getUsername (EEncoding eflag=zypp::url::E_DECODED) const |
Returns the username from the URL authority. | |
std::string | getPassword (EEncoding eflag=zypp::url::E_DECODED) const |
Returns the password from the URL authority. | |
std::string | getHost (EEncoding eflag=zypp::url::E_DECODED) const |
Returns the hostname or IP from the URL authority. | |
std::string | getPort () const |
Returns the port from the URL authority. | |
std::string | getPathData () const |
Returns the encoded path component of the URL. | |
std::string | getPathName (EEncoding eflag=zypp::url::E_DECODED) const |
Returns the path name from the URL. | |
std::string | getPathParams () const |
Returns the path parameters from the URL. | |
zypp::url::ParamVec | getPathParamsVec () const |
Returns a vector with path parameter substrings. | |
zypp::url::ParamMap | getPathParamsMap (EEncoding eflag=zypp::url::E_DECODED) const |
Returns a string map with path parameter keys and values. | |
std::string | getPathParam (const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const |
Return the value for the specified path parameter. | |
std::string | getQueryString () const |
Returns the encoded query string component of the URL. | |
zypp::url::ParamVec | getQueryStringVec () const |
Returns a vector with query string parameter substrings. | |
zypp::url::ParamMap | getQueryStringMap (EEncoding eflag=zypp::url::E_DECODED) const |
Returns a string map with query parameter and their values. | |
std::string | getQueryParam (const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const |
Return the value for the specified query parameter. | |
std::string | getFragment (EEncoding eflag=zypp::url::E_DECODED) const |
Returns the encoded fragment component of the URL. | |
void | setScheme (const std::string &scheme) |
Set the scheme name in the URL. | |
void | setAuthority (const std::string &authority) |
Set the authority component in the URL. | |
void | setUsername (const std::string &user, EEncoding eflag=zypp::url::E_DECODED) |
Set the username in the URL authority. | |
void | setPassword (const std::string &pass, EEncoding eflag=zypp::url::E_DECODED) |
Set the password in the URL authority. | |
void | setHost (const std::string &host) |
Set the hostname or IP in the URL authority. | |
void | setPort (const std::string &port) |
Set the port number in the URL authority. | |
void | setPathData (const std::string &pathdata) |
Set the path data component in the URL. | |
void | setPathName (const std::string &path, EEncoding eflag=zypp::url::E_DECODED) |
Set the path name. | |
void | setPathParams (const std::string ¶ms) |
Set the path parameters. | |
void | setPathParamsVec (const zypp::url::ParamVec &pvec) |
Set the path parameters. | |
void | setPathParamsMap (const zypp::url::ParamMap &pmap) |
Set the path parameters. | |
void | setPathParam (const std::string ¶m, const std::string &value) |
Set or add value for the specified path parameter. | |
void | setQueryString (const std::string &querystr) |
Set the query string in the URL. | |
void | setQueryStringVec (const zypp::url::ParamVec &qvec) |
Set the query parameters. | |
void | setQueryStringMap (const zypp::url::ParamMap &qmap) |
Set the query parameters. | |
void | setQueryParam (const std::string ¶m, const std::string &value) |
Set or add value for the specified query parameter. | |
void | setFragment (const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED) |
Set the fragment string in the URL. | |
ViewOptions | getViewOptions () const |
Return the view options of the current object. | |
void | setViewOptions (const ViewOptions &vopts) |
Change the view options of the current object. | |
Static Public Member Functions | |
static url::UrlRef | parseUrl (const std::string &encodedUrl) |
Parse a percent-encoded URL string. | |
static bool | registerScheme (const std::string &scheme, url::UrlRef urlImpl) |
Register a scheme-specific implementation. | |
static zypp::url::UrlSchemes | getRegisteredSchemes () |
Returns all registered scheme names. | |
static bool | isRegisteredScheme (const std::string &scheme) |
Returns if scheme name is registered. | |
Private Attributes | |
url::UrlRef | m_impl |
The generic URL (URI) syntax and its main components are defined in RFC3986 (http://rfc.net/rfc3986.html) Section 3, "Syntax Components". The scheme specific URL syntax and semantics is defined in the specification of the particular scheme. See also RFC1738 (http://rfc.net/rfc1738.html), that defines specific syntax for several URL schemes.
This class provides methods to access and manipulate generic and common scheme-specific URL components (or using the more general term, URI components). To consider the scheme-specifics of a URL, the Url class contains a reference object pointing to a UrlBase or derived object, that implements the scheme specifics.
Using the Url::registerScheme() method, it is possible to register a preconfigured or derived UrlBase object for a specific scheme name. The registered object will be cloned to handle all URL's containing the specified scheme name.
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] hier-part = "//" authority path-abempty / path-absolute / path-rootless / path-empty
The scheme and path components are required, though the path may be empty (no characters). When authority is present, the path must either be empty or begin with a slash ("/") character. When authority is not present, the path cannot begin with two slash characters ("//"). These restrictions result in five different ABNF rules for a path (Section 3.3), only one of which will match any given URI reference.
The following are two example URIs and their component parts:
foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose
Definition at line 83 of file Url.h.
|
Encoding flags.
|
|
View options.
|
|
|
|
|
|
Create a new Url object as shared copy of the given one. Upon return, both objects will point to the same underlying object. This state will remain until one of the object is modified.
Definition at line 282 of file Url.cc. References m_impl, and ZYPP_THROW. |
|
Create a new Url object as shared copy of the given reference. Upon return, both objects will point to the same underlying object. This state will remain until one of the object is modified.
Definition at line 295 of file Url.cc. References m_impl, and ZYPP_THROW. |
|
Construct a Url object from percent-encoded URL string.
Parses the
Definition at line 308 of file Url.cc. References m_impl, and ZYPP_THROW. |
|
Parse a percent-encoded URL string. Trys to parses the given string into generic URL components and created a clone of a scheme-specialized object or a new UrlBase object.
Definition at line 358 of file Url.cc. References zypp::g_urlSchemeRepository, RX_SPLIT_URL, zypp::solver::detail::str, and url. Referenced by operator=(). |
|
Assigns parsed percent-encoded URL string to the object.
Parses
Definition at line 322 of file Url.cc. References m_impl, parseUrl(), url, and ZYPP_THROW. |
|
Assign shared copy of Upon return, both objects will point to the same underlying object. This state will remain until one of the object is modified.
|
|
Register a scheme-specific implementation.
Definition at line 348 of file Url.cc. References zypp::g_urlSchemeRepository. |
|
Returns all registered scheme names.
Definition at line 392 of file Url.cc. References zypp::g_urlSchemeRepository. |
|
Returns if scheme name is registered.
Definition at line 401 of file Url.cc. References zypp::g_urlSchemeRepository. |
|
Returns scheme names known to this object.
Definition at line 409 of file Url.cc. References m_impl. |
|
Verifies specified scheme name.
Verifies the generic syntax of the specified The default implementation in the UrlBase class returns an emtpy list of known schemes, causing a check of the generic syntax only.
Definition at line 417 of file Url.cc. References m_impl. |
|
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 425 of file Url.cc. References m_impl. Referenced by zypp::SourceFactory::createFrom(), zypp::media::MediaCurl::doGetFileCopy(), zypp::SourceFactory::listProducts(), and zypp::media::MediaAccess::open(). |
|
Returns a default string representation of the Url object. By default, a password in the URL will be hidden.
Definition at line 433 of file Url.cc. References m_impl. Referenced by zypp::source::yum::YUMSourceImpl::downloadMetadata(), zypp::source::susetags::SuseTagsImpl::downloadMetadata(), zypp::source::yum::YUMSourceImpl::downloadNeeded(), zypp::media::MediaCD::MediaCD(), zypp::media::MediaManager::open(), zypp::operator<<(), zypp::source::susetags::ProductMetadataParser::parse(), zypp::source::susetags::parsePackages(), zypp::source::susetags::parseSelection(), and zypp::SourceManager::removeSourceByUrl(). |
|
Returns a string representation of the Url object. To include a password in the resulting Url string, use:
Definition at line 461 of file Url.cc. References m_impl. |
|
Returns a complete string representation of the Url object. This function ignores the configuration of the view options in the current object (see setViewOption()) and forces to return an string with all URL components included.
Definition at line 441 of file Url.cc. References getViewOptions(), m_impl, zypp::url::ViewOption::WITH_FRAGMENT, zypp::url::ViewOption::WITH_HOST, zypp::url::ViewOption::WITH_PASSWORD, zypp::url::ViewOption::WITH_PATH_NAME, zypp::url::ViewOption::WITH_PATH_PARAMS, zypp::url::ViewOption::WITH_PORT, zypp::url::ViewOption::WITH_QUERY_STR, zypp::url::ViewOption::WITH_SCHEME, and zypp::url::ViewOption::WITH_USERNAME. Referenced by zypp::SourceManager::findSourceByUrl(), zypp::SourceCache::removeSource(), zypp::SourceCache::storeSource(), and zypp::storage::toXML(). |
|
Returns the scheme name of the URL.
Definition at line 469 of file Url.cc. References m_impl. Referenced by zypp::media::MediaAccess::canBeVolatile(), zypp::media::MediaAccess::downloads(), zypp::media::MediaCD::forceEject(), zypp::media::MediaCD::MediaCD(), zypp::media::MediaCurl::MediaCurl(), zypp::media::MediaHandler::MediaHandler(), zypp::media::MediaHandler::protocol(), zypp::source::MediaSet::reattach(), and zypp::source::MediaSet::rewriteUrl(). |
|
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 477 of file Url.cc. References m_impl. |
|
Returns the username from the URL authority.
Definition at line 508 of file Url.cc. References m_impl. |
|
Returns the password from the URL authority.
Definition at line 516 of file Url.cc. References m_impl. |
|
Returns the hostname or IP from the URL authority. In case the Url contains an IP number, it may be surrounded by "[" and "]" characters, for example "[::1]" for an IPv6 localhost address.
Definition at line 524 of file Url.cc. References m_impl. Referenced by zypp::media::MediaCurl::doGetFileCopy(), and zypp::media::MediaDIR::MediaDIR(). |
|
Returns the port from the URL authority.
Definition at line 532 of file Url.cc. References m_impl. |
|
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 484 of file Url.cc. References m_impl. Referenced by zypp::media::MediaAccess::getFile(). |
|
Returns the path name from the URL.
Definition at line 540 of file Url.cc. References m_impl. Referenced by zypp::media::MediaCurl::doGetFileCopy(), and zypp::source::MediaSet::rewriteUrl(). |
|
Returns the path parameters from the URL.
Definition at line 548 of file Url.cc. References m_impl. |
|
Returns a vector with 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 556 of file Url.cc. References m_impl. |
|
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 564 of file Url.cc. References m_impl. |
|
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 572 of file Url.cc. References m_impl. |
|
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 492 of file Url.cc. References m_impl. |
|
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 580 of file Url.cc. References m_impl. |
|
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 588 of file Url.cc. References m_impl. |
|
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 596 of file Url.cc. References m_impl. Referenced by zypp::media::MediaDISK::MediaDISK(), zypp::media::MediaISO::MediaISO(), and zypp::source::MediaSet::rewriteUrl(). |
|
Returns the encoded fragment component of the URL.
Definition at line 500 of file Url.cc. References m_impl. |
|
Set the scheme name in the URL.
Definition at line 604 of file Url.cc. References m_impl. |
|
Set the authority component in the URL.
The
Definition at line 634 of file Url.cc. References m_impl. |
|
Set the username in the URL authority.
Definition at line 666 of file Url.cc. References m_impl. |
|
Set the password in the URL authority.
Definition at line 675 of file Url.cc. References m_impl. |
|
Set the hostname or IP in the URL authority.
The A hostname may contain national alphanumeric UTF8 characters (letters other than ASCII a-z0-9), 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 684 of file Url.cc. References m_impl. |
|
Set the port number in the URL authority.
Definition at line 692 of file Url.cc. References m_impl. |
|
Set the path data component in the URL.
By default, the
Definition at line 642 of file Url.cc. References m_impl. Referenced by zypp::media::MediaAccess::getFile(). |
|
Set the path name.
Definition at line 700 of file Url.cc. References m_impl. Referenced by zypp::source::MediaSet::rewriteUrl(). |
|
Set the path parameters.
Definition at line 709 of file Url.cc. References m_impl. |
|
Set the path parameters.
Definition at line 717 of file Url.cc. References m_impl. |
|
Set the path parameters.
Definition at line 725 of file Url.cc. References m_impl. |
|
Set or add value for the specified path parameter.
Definition at line 733 of file Url.cc. References m_impl. |
|
Set the query string in the URL.
Definition at line 650 of file Url.cc. References m_impl. |
|
Set the query parameters.
Definition at line 741 of file Url.cc. References m_impl. |
|
Set the query parameters.
Definition at line 749 of file Url.cc. References m_impl. |
|
Set or add value for the specified query parameter.
Definition at line 756 of file Url.cc. References m_impl. Referenced by zypp::source::MediaSet::rewriteUrl(). |
|
Set the fragment string in the URL.
Definition at line 658 of file Url.cc. References m_impl. |
|
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 763 of file Url.cc. References m_impl. Referenced by asCompleteString(). |
|
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 770 of file Url.cc. References m_impl. |
|