[gnome-builder] libidemm: add wrapper for IdeUri class



commit ab407a8c177cd38c0b5cfa5fb9eaae899a1bd848
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Mon Apr 11 21:01:43 2016 +0200

    libidemm: add wrapper for IdeUri class

 libidemm/.gitignore                 |    2 +
 libidemm/idemm.h                    |    4 ++
 libidemm/src/filelist.am            |    3 +-
 libidemm/src/uri.ccg                |   44 ++++++++++++++++++++
 libidemm/src/uri.hg                 |   76 +++++++++++++++++++++++++++++++++++
 libidemm/tools/m4/convert_libide.m4 |    2 +
 6 files changed, 130 insertions(+), 1 deletions(-)
---
diff --git a/libidemm/.gitignore b/libidemm/.gitignore
index b6a0742..7bb9557 100644
--- a/libidemm/.gitignore
+++ b/libidemm/.gitignore
@@ -47,6 +47,8 @@ stamp-h2
 /idemm/object.h
 /idemm/recentprojects.cc
 /idemm/recentprojects.h
+/idemm/uri.cc
+/idemm/uri.h
 /idemm/wrap_init.cc
 
 # docs/
diff --git a/libidemm/idemm.h b/libidemm/idemm.h
index c45364e..6f5ddfb 100644
--- a/libidemm/idemm.h
+++ b/libidemm/idemm.h
@@ -3,8 +3,12 @@
 
 #include <idemm/application.h>
 #include <idemm/applicationaddin.h>
+#include <idemm/backforwardlist.h>
+#include <idemm/context.h>
+#include <idemm/object.h>
 #include <idemm/recentprojects.h>
 #include <idemm/registermmtype.h>
+#include <idemm/uri.h>
 #include <idemm/wrap_init.h>
 
 #endif
diff --git a/libidemm/src/filelist.am b/libidemm/src/filelist.am
index 7fa4241..29456e5 100644
--- a/libidemm/src/filelist.am
+++ b/libidemm/src/filelist.am
@@ -14,6 +14,7 @@ idemm_files_hg =              \
        backforwardlist.hg      \
        context.hg              \
        object.hg               \
-       recentprojects.hg
+       recentprojects.hg       \
+       uri.hg
 
 idemm_files_ccg = $(idemm_files_hg:.hg=.ccg)
diff --git a/libidemm/src/uri.ccg b/libidemm/src/uri.ccg
new file mode 100644
index 0000000..9a3a83f
--- /dev/null
+++ b/libidemm/src/uri.ccg
@@ -0,0 +1,44 @@
+/* uri.hg
+ *
+ * Copyright (C) 2016 Marcin Kolny <marcin kolny gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Ide {
+
+Uri::Uri(const Glib::ustring& uri_string, Ide::UriParseFlags flags)
+{
+  GError* gerror = nullptr;
+  gobject_ = ide_uri_new(uri_string.c_str(), static_cast<IdeUriParseFlags>(flags), &gerror);
+
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+}
+
+Uri::Uri(const Uri& base_uri, const Glib::ustring& uri_string, Ide::UriParseFlags flags)
+{
+  GError* gerror = nullptr;
+  gobject_ = ide_uri_new_relative(const_cast<IdeUri*>(base_uri.gobj()), uri_string.c_str(), 
static_cast<IdeUriParseFlags>(flags), &gerror);
+
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+}
+
+Uri::Uri(const Glib::RefPtr<Gio::File>& file)
+{
+  gobject_ = ide_uri_new_from_file(file->gobj());
+}
+
+}
\ No newline at end of file
diff --git a/libidemm/src/uri.hg b/libidemm/src/uri.hg
new file mode 100644
index 0000000..f483e9d
--- /dev/null
+++ b/libidemm/src/uri.hg
@@ -0,0 +1,76 @@
+/* uri.hg
+ *
+ * Copyright (C) 2016 Marcin Kolny <marcin kolny gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <giomm/file.h>
+
+#include <ide.h>
+
+_DEFS(idemm, libide)
+
+namespace Ide {
+
+_WRAP_ENUM(UriParseFlags, IdeUriParseFlags, NO_GTYPE)
+_WRAP_ENUM(UriToStringFlags, IdeUriToStringFlags, NO_GTYPE)
+
+class Uri
+{
+  // TODO: IdeUri defines ide_uri_ref as a copy method. why?
+  _CLASS_BOXEDTYPE(Uri, IdeUri, NONE, ide_uri_copy, ide_uri_unref)
+
+public:
+  Uri(const Glib::ustring& uri_string, Ide::UriParseFlags flags);
+  Uri(const Uri& base_uri, const Glib::ustring& uri_string, Ide::UriParseFlags flags);
+  Uri(const Glib::RefPtr<Gio::File>& file);
+
+  _IGNORE(ide_uri_unref, ide_uri_new_relative, ide_uri_ref, ide_uri_copy)
+
+  // todo operator string?
+  _WRAP_METHOD(Glib::ustring to_string(Ide::UriToStringFlags flags) const, ide_uri_to_string)
+  
+  _WRAP_METHOD(Glib::ustring get_scheme() const, ide_uri_get_scheme)
+  _WRAP_METHOD(void set_scheme(const Glib::ustring& scheme), ide_uri_set_scheme)
+  
+  _WRAP_METHOD(Glib::ustring get_user() const, ide_uri_get_user)
+  _WRAP_METHOD(void set_user(const Glib::ustring& user), ide_uri_set_user)
+  
+  _WRAP_METHOD(Glib::ustring get_password() const, ide_uri_get_password)
+  _WRAP_METHOD(void set_password(const Glib::ustring& password), ide_uri_set_password)
+  
+  _WRAP_METHOD(Glib::ustring get_auth_params() const, ide_uri_get_auth_params)
+  _WRAP_METHOD(void set_auth_params(const Glib::ustring& auth_params), ide_uri_set_auth_params)
+  
+  _WRAP_METHOD(Glib::ustring get_host() const, ide_uri_get_host)
+  _WRAP_METHOD(void set_host(const Glib::ustring& host), ide_uri_set_host)
+  
+  _WRAP_METHOD(gushort get_port() const, ide_uri_get_port)
+  _WRAP_METHOD(void set_port(gushort port), ide_uri_set_port)
+  
+  _WRAP_METHOD(Glib::ustring get_path() const, ide_uri_get_path)
+  _WRAP_METHOD(void set_path(const Glib::ustring& path), ide_uri_set_path)
+  
+  _WRAP_METHOD(Glib::ustring get_query() const, ide_uri_get_query)
+  _WRAP_METHOD(void set_query(const Glib::ustring& query), ide_uri_set_query)
+  
+  _WRAP_METHOD(Glib::ustring get_fragment() const, ide_uri_get_fragment)
+  _WRAP_METHOD(void set_fragment(const Glib::ustring& fragment), ide_uri_set_fragment)
+  
+  _WRAP_METHOD(bool is_file(const Glib::RefPtr<Gio::File>& file) const, ide_uri_is_file)
+  _WRAP_METHOD(Glib::RefPtr<Gio::File> to_file() const, ide_uri_to_file)
+};
+
+}
diff --git a/libidemm/tools/m4/convert_libide.m4 b/libidemm/tools/m4/convert_libide.m4
index 18a09fb..76c9dc2 100644
--- a/libidemm/tools/m4/convert_libide.m4
+++ b/libidemm/tools/m4/convert_libide.m4
@@ -1,5 +1,7 @@
 dnl Enums
 _CONV_ENUM(Ide,ApplicationMode)
+_CONV_ENUM(Ide,UriParseFlags)
+_CONV_ENUM(Ide,UriToStringFlags)
 
 dnl Glibmm Enums
 #_CONV_GLIB_ENUM(ThreadPriority)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]