From 50693be2a2d78daca0bac6e507a8bf37dfa531c4 Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Tue, 10 Jan 2006 13:26:00 +0000 Subject: [PATCH] - Added assignment operators --- zypp/Url.cc | 25 +++++++++++++++++++++++++ zypp/Url.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/zypp/Url.cc b/zypp/Url.cc index bae8e94..7265bc2 100644 --- a/zypp/Url.cc +++ b/zypp/Url.cc @@ -204,6 +204,31 @@ namespace zypp // ----------------------------------------------------------------- + Url& + Url::operator = (const std::string &encodedUrl) + { + UrlRef url( parseUrl(encodedUrl)); + if( !url) + { + throw std::invalid_argument( + "Unable to parse Url components" + ); + } + m_impl = url; + return *this; + } + + + // ----------------------------------------------------------------- + Url& + Url::operator = (const Url &url) + { + m_impl = url.m_impl; + return *this; + } + + + // ----------------------------------------------------------------- // static bool Url::registerScheme(const std::string &scheme, diff --git a/zypp/Url.h b/zypp/Url.h index f92701c..87c966a 100644 --- a/zypp/Url.h +++ b/zypp/Url.h @@ -87,13 +87,20 @@ namespace zypp ~Url(); Url(); + + /** + * Create a new Url object as shared copy of the given one. + * + * \param url The Url object to make a copy of. + */ Url(const Url &url); /** * \brief Construct a Url object from percent-encoded URL string. * - * Parses the \p encodedUrl string using the parseUrl() method. + * Parses the \p encodedUrl string using the parseUrl() method + * and assings the result to the new created object. * * \param encodedUrl A percent-encoded URL string. * \throws A std::invalid_argument exception if parsing fails. @@ -102,18 +109,6 @@ namespace zypp /** - * \brief Register a scheme-specific implementation. - * - * \param scheme A name of a scheme. - * \param urlImpl A UrlBase object specialized for this scheme. - * \return True, if the object claims to implement the scheme. - */ - static bool - registerScheme(const std::string &scheme, - url::UrlRef urlImpl); - - - /** * \brief Parse a percent-encoded URL string. * * Trys to parses the given string into generic URL components @@ -132,6 +127,45 @@ namespace zypp /** + * \brief Assigns parsed percent-encoded URL string. + * + * Parses \p encodedUrl string using the parseUrl() method + * and assigns the result to the current object. + * + * \param encodedUrl A percent-encoded URL string. + * \return A reference to this Url object. + * \throws A std::invalid_argument exception if parsing fails. + */ + Url& + operator = (const std::string &encodedUrl); + + + /** + * \brief Assigns the \p url to the current object. + * + * After this operation the current object will be a shared + * copy of the object specified in the \p url parameter. + * + * \param url The Url object to make a copy of. + * \return A reference to this Url object. + */ + Url& + operator = (const Url &url); + + + /** + * \brief Register a scheme-specific implementation. + * + * \param scheme A name of a scheme. + * \param urlImpl A UrlBase object specialized for this scheme. + * \return True, if the object claims to implement the scheme. + */ + static bool + registerScheme(const std::string &scheme, + url::UrlRef urlImpl); + + + /** * \return A vector with registered URL scheme names. */ static url::UrlBase::Schemes -- 2.7.4