summaryrefslogtreecommitdiffstats
path: root/src/object/uri.cpp
diff options
context:
space:
mode:
authorThomas Holder <thomas@thomas-holder.de>2018-12-13 08:57:08 +0000
committerThomas Holder <thomas@thomas-holder.de>2018-12-13 17:36:53 +0000
commit04045fd798a5be753d498bc596215caab638bc7a (patch)
treea58eff4ad87dfa36e8271bcd80e8e88064cbdf38 /src/object/uri.cpp
parentMisc. source comment typo fixes (diff)
downloadinkscape-04045fd798a5be753d498bc596215caab638bc7a.tar.gz
inkscape-04045fd798a5be753d498bc596215caab638bc7a.zip
remove most of Inkscape::URI::Impl
Diffstat (limited to 'src/object/uri.cpp')
-rw-r--r--src/object/uri.cpp60
1 files changed, 24 insertions, 36 deletions
diff --git a/src/object/uri.cpp b/src/object/uri.cpp
index 52fc9dc44..2604ee640 100644
--- a/src/object/uri.cpp
+++ b/src/object/uri.cpp
@@ -43,8 +43,7 @@ static bool uri_needs_escaping(char const *uri)
}
URI::URI() {
- const gchar *in = "";
- _impl = Impl::create(xmlParseURI(in));
+ _impl = Impl::create(xmlCreateURI());
}
URI::URI(const URI &uri) {
@@ -162,52 +161,52 @@ void URI::Impl::unreference() {
//
// authority = server | reg_name
-bool URI::Impl::isOpaque() const {
+bool URI::isOpaque() const {
return getOpaque() != nullptr;
}
-bool URI::Impl::isRelative() const {
- return !_uri->scheme;
+bool URI::isRelative() const {
+ return !_xmlURIPtr()->scheme;
}
-bool URI::Impl::isNetPath() const {
- return isRelative() && _uri->server;
+bool URI::isNetPath() const {
+ return isRelative() && _xmlURIPtr()->server;
}
-bool URI::Impl::isRelativePath() const {
- if (isRelative() && !_uri->server) {
+bool URI::isRelativePath() const {
+ if (isRelative() && !_xmlURIPtr()->server) {
const gchar *path = getPath();
return path && path[0] != '/';
}
return false;
}
-bool URI::Impl::isAbsolutePath() const {
- if (isRelative() && !_uri->server) {
+bool URI::isAbsolutePath() const {
+ if (isRelative() && !_xmlURIPtr()->server) {
const gchar *path = getPath();
return path && path[0] == '/';
}
return false;
}
-const gchar *URI::Impl::getScheme() const {
- return (gchar *)_uri->scheme;
+const gchar *URI::getScheme() const {
+ return (gchar *)_xmlURIPtr()->scheme;
}
-const gchar *URI::Impl::getPath() const {
- return (gchar *)_uri->path;
+const gchar *URI::getPath() const {
+ return (gchar *)_xmlURIPtr()->path;
}
-const gchar *URI::Impl::getQuery() const {
- return (gchar *)_uri->query;
+const gchar *URI::getQuery() const {
+ return (gchar *)_xmlURIPtr()->query;
}
-const gchar *URI::Impl::getFragment() const {
- return (gchar *)_uri->fragment;
+const gchar *URI::getFragment() const {
+ return (gchar *)_xmlURIPtr()->fragment;
}
-const gchar *URI::Impl::getOpaque() const {
- if (!isRelative() && !_uri->server) {
+const gchar *URI::getOpaque() const {
+ if (!isRelative() && !_xmlURIPtr()->server) {
const gchar *path = getPath();
if (path && path[0] != '/') {
return path;
@@ -262,18 +261,6 @@ URI URI::from_href_and_basedir(char const *href, char const *basedir)
}
}
-gchar *URI::Impl::toString() const {
- xmlChar *string = xmlSaveUri(_uri);
- if (string) {
- /* hand the string off to glib memory management */
- gchar *glib_string = g_strdup((gchar *)string);
- xmlFree(string);
- return glib_string;
- } else {
- return nullptr;
- }
-}
-
/**
* Replacement for buggy xmlBuildRelativeURI
* https://gitlab.gnome.org/GNOME/libxml2/merge_requests/12
@@ -335,14 +322,15 @@ static std::string build_relative_uri(char const *uri, char const *base)
std::string URI::str(char const *baseuri) const
{
std::string s;
- gchar *save = _impl->toString();
- if (save) {
+ auto saveuri = xmlSaveUri(_xmlURIPtr());
+ if (saveuri) {
+ auto save = (const char *)saveuri;
if (baseuri && baseuri[0]) {
s = build_relative_uri(save, baseuri);
} else {
s = save;
}
- g_free(save);
+ xmlFree(saveuri);
}
return s;
}