summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
Diffstat (limited to 'src/object')
-rw-r--r--src/object/uri.cpp45
-rw-r--r--src/object/uri.h38
2 files changed, 8 insertions, 75 deletions
diff --git a/src/object/uri.cpp b/src/object/uri.cpp
index 2604ee640..df55508da 100644
--- a/src/object/uri.cpp
+++ b/src/object/uri.cpp
@@ -43,12 +43,7 @@ static bool uri_needs_escaping(char const *uri)
}
URI::URI() {
- _impl = Impl::create(xmlCreateURI());
-}
-
-URI::URI(const URI &uri) {
- uri._impl->reference();
- _impl = uri._impl;
+ init(xmlCreateURI());
}
URI::URI(gchar const *preformed, char const *baseuri)
@@ -96,7 +91,7 @@ URI::URI(gchar const *preformed, char const *baseuri)
if (!uri) {
throw MalformedURIException();
}
- _impl = Impl::create(uri);
+ init(uri);
}
URI::URI(char const *preformed, URI const &baseuri)
@@ -104,42 +99,6 @@ URI::URI(char const *preformed, URI const &baseuri)
{
}
-URI::~URI() {
- _impl->unreference();
-}
-
-URI &URI::operator=(URI const &uri) {
-// No check for self-assignment needed, as _impl refcounting increments first.
- uri._impl->reference();
- _impl->unreference();
- _impl = uri._impl;
- return *this;
-}
-
-URI::Impl *URI::Impl::create(xmlURIPtr uri) {
- return new Impl(uri);
-}
-
-URI::Impl::Impl(xmlURIPtr uri)
-: _refcount(1), _uri(uri) {}
-
-URI::Impl::~Impl() {
- if (_uri) {
- xmlFreeURI(_uri);
- _uri = nullptr;
- }
-}
-
-void URI::Impl::reference() {
- _refcount++;
-}
-
-void URI::Impl::unreference() {
- if (!--_refcount) {
- delete this;
- }
-}
-
// From RFC 2396:
//
// URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
diff --git a/src/object/uri.h b/src/object/uri.h
index 4650be137..2e627cb59 100644
--- a/src/object/uri.h
+++ b/src/object/uri.h
@@ -12,8 +12,8 @@
#ifndef INKSCAPE_URI_H
#define INKSCAPE_URI_H
-#include <exception>
#include <libxml/uri.h>
+#include <memory>
#include <string>
namespace Inkscape {
@@ -39,11 +39,6 @@ public:
URI();
/**
- * Copy constructor.
- */
- URI(URI const &uri);
-
- /**
* Constructor from a C-style ASCII string.
*
* @param preformed Properly quoted C-style string to be represented.
@@ -55,11 +50,6 @@ public:
explicit URI(char const *preformed, URI const &baseuri);
/**
- * Destructor.
- */
- ~URI();
-
- /**
* Determines if the URI represented is an 'opaque' URI.
*
* @return \c true if the URI is opaque, \c false if hierarchial.
@@ -191,28 +181,12 @@ public:
*/
bool hasScheme(const char *scheme) const;
- /**
- * Assignment operator.
- */
- URI &operator=(URI const &uri);
-
private:
- class Impl {
- public:
- static Impl *create(xmlURIPtr uri);
- void reference();
- void unreference();
-
- private:
- Impl(xmlURIPtr uri);
- ~Impl();
- int _refcount;
- public:
- xmlURIPtr _uri;
- };
- Impl *_impl;
-
- xmlURIPtr _xmlURIPtr() const { return _impl->_uri; }
+ std::shared_ptr<xmlURI> m_shared;
+
+ void init(xmlURI *ptr) { m_shared.reset(ptr, xmlFreeURI); }
+
+ xmlURI *_xmlURIPtr() const { return m_shared.get(); }
};
} /* namespace Inkscape */