[glibmm: 4/8] Add Typetraits for SrvTarget so we can return a list of them
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: svn-commits-list gnome org
- Subject: [glibmm: 4/8] Add Typetraits for SrvTarget so we can return a list of them
- Date: Thu, 18 Jun 2009 12:42:04 -0400 (EDT)
commit 64af295730357c41fde5659d0bf20919245e37f9
Author: Jonathon Jongsma <jonathon quotidian org>
Date: Thu Jun 18 11:05:37 2009 -0500
Add Typetraits for SrvTarget so we can return a list of them
ChangeLog | 7 ++++
gio/src/resolver.ccg | 93 --------------------------------------------------
gio/src/resolver.hg | 25 +++-----------
gio/src/srvtarget.hg | 25 +++++++++++++
4 files changed, 37 insertions(+), 113 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0f15e85..aa3e6d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-18 Jonathon Jongsma <jonathon quotidian org>
+
+ * gio/src/resolver.ccg:
+ * gio/src/resolver.hg: remove some overloads for now and get the
+ lookup_service() API working with the list of SrvTargets
+ * gio/src/srvtarget.hg: add TypeTraits for lists of SrvTargets
+
2009-06-17 Jonathon Jongsma <jonathon quotidian org>
Add initial wrappers for SocketConnectable, SocketAddress
diff --git a/gio/src/resolver.ccg b/gio/src/resolver.ccg
index f861e5a..1fe7b01 100644
--- a/gio/src/resolver.ccg
+++ b/gio/src/resolver.ccg
@@ -19,38 +19,6 @@
#include <gio/gio.h>
-#if 0
-namespace Glib
-{
-namespace Container_Helpers
-{
-
-template <>
-struct TypeTraits<Gio::SrvTarget >
-{
- typedef Gio::SrvTarget CppType;
- typedef GSrvTarget* CType;
- typedef GSrvTarget* CTypeNonConst;
-
- static CType to_c_type (const CppType& item)
- { return item.gobj(); }
-
- static CppType to_cpp_type (const CType& item)
- {
- return Glib::wrap(item, true /* take_copy */);
- }
-
- static void release_c_type (CType item)
- {
- g_srv_target_free(item);
- }
-};
-
-
-} // namespace Container_Helpers
-} // namespace Glib
-#endif
-
namespace Gio
{
@@ -64,65 +32,4 @@ void Resolver::set_default(const Glib::RefPtr<Resolver>& resolver)
g_resolver_set_default(Glib::unwrap(resolver));
}
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::ListHandle< Glib::RefPtr<InetAddress> > Resolver::lookup_by_name(const Glib::ustring& hostname)
-#else
-Glib::ListHandle< Glib::RefPtr<InetAddress> > Resolver::lookup_by_name(const Glib::ustring& hostname, std::auto_ptr<Glib::Error>& error)
-#endif
-{
- GError* gerror = 0;
- Glib::ListHandle< Glib::RefPtr<InetAddress> > retvalue = Glib::ListHandle< Glib::RefPtr<InetAddress> >(g_resolver_lookup_by_name(gobj(), hostname.c_str(), NULL, &(gerror)), Glib::OWNERSHIP_SHALLOW);
- if(gerror)
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- ::Glib::Error::throw_exception(gerror);
-#else
- error = ::Glib::Error::throw_exception(gerror);
-#endif //GLIBMM_EXCEPTIONS_ENABLED
-
- return retvalue;
-}
-
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::ustring Resolver::lookup_by_address(const Glib::RefPtr<InetAddress>& address)
-#else
-Glib::ustring Resolver::lookup_by_address(const Glib::RefPtr<InetAddress>& address, std::auto_ptr<Glib::Error>& error)
-#endif //GLIBMM_EXCEPTIONS_ENABLED
-{
- GError* gerror = 0;
- Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_resolver_lookup_by_address(gobj(), const_cast<GInetAddress*>(Glib::unwrap(address)), NULL, &(gerror)));
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- if(gerror)
- ::Glib::Error::throw_exception(gerror);
-#else
- if(gerror)
- error = ::Glib::Error::throw_exception(gerror);
-#endif //GLIBMM_EXCEPTIONS_ENABLED
-
- return retvalue;
-
-}
-
-/*
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::ListHandle<SrvTarget> Resolver::lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain)
-#else
-Glib::ListHandle<SrvTarget> Resolver::lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, std::auto_ptr<Glib::Error>& error)
-#endif //GLIBMM_EXCEPTIONS_ENABLED
-{
- GError* gerror = 0;
- Glib::ListHandle<SrvTarget> retvalue = Glib::ListHandle<SrvTarget>(g_resolver_lookup_service(gobj(), service.c_str(), protocol.c_str(), domain.c_str(), NULL, &(gerror)), Glib::OWNERSHIP_SHALLOW);
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- if(gerror)
- ::Glib::Error::throw_exception(gerror);
-#else
- if(gerror)
- error = ::Glib::Error::throw_exception(gerror);
-#endif //GLIBMM_EXCEPTIONS_ENABLED
-
- return retvalue;
-
-}
-*/
-
-
} //namespace Gio
diff --git a/gio/src/resolver.hg b/gio/src/resolver.hg
index 5b8bb96..ef09efa 100644
--- a/gio/src/resolver.hg
+++ b/gio/src/resolver.hg
@@ -57,33 +57,18 @@ public:
_IGNORE(g_resolver_free_addresses)
#m4 _CONVERSION(`GList*',`Glib::ListHandle< Glib::RefPtr<InetAddress> >',`$2($3, Glib::OWNERSHIP_SHALLOW)')
+ //TODO without cancellable
_WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<InetAddress> > lookup_by_name(const Glib::ustring& hostname, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_by_name, errthrow)
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- Glib::ListHandle< Glib::RefPtr<InetAddress> > lookup_by_name(const Glib::ustring& hostname);
-#else
- Glib::ListHandle< Glib::RefPtr<InetAddress> > lookup_by_name(const Glib::ustring& hostname, std::auto_ptr<Glib::Error>& error);
-#endif
//TODO lookup_by_name_async
#m4 _CONVERSION(`GList*',`Glib::ListHandle< Glib::RefPtr<InetAddress> >',`$2($3, Glib::OWNERSHIP_SHALLOW)')
+ //TODO without cancellable
_WRAP_METHOD(Glib::ustring lookup_by_address(const Glib::RefPtr<InetAddress>& address, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_by_address, errthrow)
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- Glib::ustring lookup_by_address(const Glib::RefPtr<InetAddress>& address);
-#else
- Glib::ustring lookup_by_address(const Glib::RefPtr<InetAddress>& address, std::auto_ptr<Glib::Error>& error);
-#endif //GLIBMM_EXCEPTIONS_ENABLED
//TODO lookup_by_address_async
- // TODO: need a TypeTraits in order to return a ListHandle for SrvTarget? I'm
- // getting some strange build failures I don't understand
-//#m4 _CONVERSION(`GList*',`Glib::ListHandle<SrvTarget>',`$2($3, Glib::OWNERSHIP_SHALLOW)')
- //_WRAP_METHOD(Glib::ListHandle<SrvTarget> lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_service, errthrow)
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
- Glib::ListHandle<SrvTarget> lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain);
-#else
- Glib::ListHandle<SrvTarget> lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, std::auto_ptr<Glib::Error>& error);
-#endif //GLIBMM_EXCEPTIONS_ENABLED
- //TODO lookup_service_async
+#m4 _CONVERSION(`GList*',`ListHandle_SrvTarget',`$2($3, Glib::OWNERSHIP_SHALLOW)')
+ _WRAP_METHOD(ListHandle_SrvTarget lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_service, errthrow)
+ //TODO without cancellable
};
} // namespace Gio
diff --git a/gio/src/srvtarget.hg b/gio/src/srvtarget.hg
index c44ecd0..331af51 100644
--- a/gio/src/srvtarget.hg
+++ b/gio/src/srvtarget.hg
@@ -15,6 +15,12 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <glibmm/listhandle.h>
+
+// unfortunately we need to include the C header for the type traits
+// implementation
+#include <gio/gio.h>
+
_DEFS(giomm,gio)
namespace Gio
@@ -52,4 +58,23 @@ public:
};
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+struct SrvTargetListTraits
+{
+ typedef Gio::SrvTarget CppType;
+ typedef const GSrvTarget* CType;
+ typedef GSrvTarget* CTypeNonConst;
+
+ static CType to_c_type(const CppType& item) { return item.gobj(); }
+ static CType to_c_type(CType ptr) { return ptr; }
+ static CppType to_cpp_type(CType item) { return CppType(const_cast<CTypeNonConst>(item), true /* take_copy */); }
+ static void release_c_type(CType item) { g_srv_target_free(const_cast<CTypeNonConst>(item)); }
+};
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+typedef Glib::ListHandle<Gio::SrvTarget, SrvTargetListTraits> ListHandle_SrvTarget;
+
} // namespace Gio
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]