[glibmm/vector] Split the VectorHandler to three classes.



commit 29df3d0a5ea54f7cc3bb72cbcc41d4ba6cff6831
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Fri Jan 21 11:39:21 2011 +0100

    Split the VectorHandler to three classes.
    
    By splitting the class we avoid writing bool specializations for
    list and slist stuff, which are useless and removed now.

 glib/glibmm/filelist.am    |    1 +
 glib/glibmm/vectorutils.cc |   75 ++++++++
 glib/glibmm/vectorutils.h  |  444 ++++++--------------------------------------
 3 files changed, 134 insertions(+), 386 deletions(-)
---
diff --git a/glib/glibmm/filelist.am b/glib/glibmm/filelist.am
index 24338f7..8e58b7b 100644
--- a/glib/glibmm/filelist.am
+++ b/glib/glibmm/filelist.am
@@ -36,6 +36,7 @@ glibmm_files_extra_cc =			\
 	utility.cc			\
 	value.cc			\
 	value_custom.cc			\
+	vectorutils.cc			\
 	wrap.cc
 
 glibmm_files_extra_h =			\
diff --git a/glib/glibmm/vectorutils.cc b/glib/glibmm/vectorutils.cc
new file mode 100644
index 0000000..244a1c1
--- /dev/null
+++ b/glib/glibmm/vectorutils.cc
@@ -0,0 +1,75 @@
+/* Copyright (C) 2011 The glibmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/vectorutils.h>
+
+
+
+namespace Glib
+{
+
+namespace Container_Helpers
+{
+
+gboolean* create_bool_array (std::vector<bool>::const_iterator pbegin,
+                             size_t size)
+{
+  gboolean *const array (static_cast<gboolean*>(g_malloc((size + 1) * sizeof (gboolean))));
+  gboolean *const array_end (array + size);
+
+  for (gboolean* pdest (array); pdest != array_end; ++pdest)
+  {
+    *pdest = *pbegin;
+    ++pbegin;
+  }
+
+  *array_end = false;
+  return array;
+}
+
+} // namespace Container_Helpers
+
+/**** Glib::ArrayHandler<bool> ************************/
+
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::array_to_vector (const CType* array, size_t array_size, Glib::OwnershipType ownership)
+{
+  // it will handle destroying data depending on passed ownership.
+  ArrayKeeperType keeper (array, array_size, ownership);
+#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
+  return VectorType (ArrayIteratorType (array), ArrayIteratorType (array + array_size));
+#else
+  VectorType temp;
+  temp.reserve (array_size);
+  Glib::Container_Helpers::fill_container (temp, ArrayIteratorType (array), ArrayIteratorType (array + array_size));
+  return temp;
+#endif
+}
+
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::array_to_vector(const CType* array, Glib::OwnershipType ownership)
+{
+  return array_to_vector (array, Glib::Container_Helpers::compute_array_size2 (array), ownership);
+}
+
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::ArrayKeeperType
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::vector_to_array (const VectorType& vector)
+{
+  return ArrayKeeperType (Glib::Container_Helpers::create_bool_array (vector.begin (), vector.size ()), vector.size (), Glib::OWNERSHIP_SHALLOW);
+}
+
+} // namespace Glib
diff --git a/glib/glibmm/vectorutils.h b/glib/glibmm/vectorutils.h
index 80025ca..fe67375 100644
--- a/glib/glibmm/vectorutils.h
+++ b/glib/glibmm/vectorutils.h
@@ -2,7 +2,7 @@
 #ifndef _GLIBMM_VECTORUTILS_H
 #define _GLIBMM_VECTORUTILS_H
 
-/* Copyright (C) 2010 The gtkmm Development Team
+/* Copyright (C) 2011 The glibmm Development Team
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -104,20 +104,7 @@ typename Tr::CType* create_array2(typename std::vector<typename Tr::CppType>::co
  * which does not conform to being an STL container.
  */
 gboolean* create_bool_array (std::vector<bool>::const_iterator pbegin,
-                             size_t size)
-{
-  gboolean *const array (static_cast<gboolean*>(g_malloc((size + 1) * sizeof (gboolean))));
-  gboolean *const array_end (array + size);
-
-  for (gboolean* pdest (array); pdest != array_end; ++pdest)
-  {
-    *pdest = *pbegin;
-    ++pbegin;
-  }
-
-  *array_end = false;
-  return array;
-}
+                             size_t size);
 
 /* Create and fill a GList as efficient as possible.
  * This requires bidirectional iterators.
@@ -138,23 +125,6 @@ GList* create_glist2(const typename std::vector<typename Tr::CppType>::const_ite
   return head;
 }
 
-/* first class function for bools, because std::vector<bool> is a specialization
- * which does not conform to being an STL container.
- */
-GList* create_bool_glist (const std::vector<bool>::const_iterator pbegin,
-                          std::vector<bool>::const_iterator pend)
-{
-  GList* head = 0;
-
-  while (pend != pbegin)
-  {
-    gboolean item (*--pend);
-    head = g_list_prepend (head, GINT_TO_POINTER(item));
-  }
-
-  return head;
-}
-
 /* Create and fill a GSList as efficient as possible.
  * This requires bidirectional iterators.
  */
@@ -174,23 +144,6 @@ GSList* create_gslist2(const typename std::vector<typename Tr::CppType>::const_i
   return head;
 }
 
-/* first class function for bools, because std::vector<bool> is a specialization
- * which does not conform to being an STL container.
- */
-GSList* create_bool_gslist (const std::vector<bool>::const_iterator pbegin,
-                            std::vector<bool>::const_iterator pend)
-{
-  GSList* head = 0;
-
-  while (pend != pbegin)
-  {
-    gboolean item (*--pend);
-    head = g_slist_prepend (head, GINT_TO_POINTER(item));
-  }
-
-  return head;
-}
-
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
 
@@ -270,32 +223,6 @@ private:
   const GList* node_;
 };
 
-template <>
-class ListIterator<TypeTraits<bool> >
-{
-public:
-  typedef bool                        CppType;
-  typedef gboolean                    CType;
-
-  typedef std::forward_iterator_tag   iterator_category;
-  typedef CppType                     value_type;
-  typedef ptrdiff_t                   difference_type;
-  typedef value_type                  reference;
-  typedef void                        pointer;
-
-  explicit inline ListIterator(const GList* node);
-
-  inline value_type                   operator*() const;
-  inline ListIterator<TypeTraits<bool> >& operator++();
-  inline const ListIterator<TypeTraits<bool> > operator++(int);
-
-  inline bool operator==(const ListIterator<TypeTraits<bool> >& rhs) const;
-  inline bool operator!=(const ListIterator<TypeTraits<bool> >& rhs) const;
-
-private:
-  const GList* node_;
-};
-
 /**
  * @ingroup ContHelpers
  * If a method takes this as an argument, or has this as a return type, then you can use a standard
@@ -327,32 +254,6 @@ private:
   const GSList* node_;
 };
 
-template <>
-class SListIterator<TypeTraits<bool> >
-{
-public:
-  typedef bool                        CppType;
-  typedef gboolean                    CType;
-
-  typedef std::forward_iterator_tag   iterator_category;
-  typedef CppType                     value_type;
-  typedef ptrdiff_t                   difference_type;
-  typedef value_type                  reference;
-  typedef void                        pointer;
-
-  explicit inline SListIterator (const GSList* node);
-
-  inline value_type                   operator*() const;
-  inline SListIterator<TypeTraits<bool> >& operator++();
-  inline const SListIterator<TypeTraits<bool> > operator++(int);
-
-  inline bool operator== (const SListIterator<TypeTraits<bool> >& rhs) const;
-  inline bool operator!= (const SListIterator<TypeTraits<bool> >& rhs) const;
-
-private:
-  const GSList* node_;
-};
-
 template <typename Tr>
 class ArrayKeeper
 {
@@ -390,24 +291,6 @@ private:
   mutable Glib::OwnershipType ownership_;
 };
 
-template <>
-class GListKeeper<TypeTraits<bool> >
-{
-public:
-  typedef bool               CppType;
-  typedef gboolean           CType;
-
-  explicit inline GListKeeper (const GList* glist, Glib::OwnershipType ownership);
-  inline GListKeeper (const GListKeeper& keeper);
-  ~GListKeeper ();
-
-  inline GList* data() const;
-
-private:
-  GList* glist_;
-  mutable Glib::OwnershipType ownership_;
-};
-
 template <typename Tr>
 class GSListKeeper
 {
@@ -426,73 +309,69 @@ private:
   mutable Glib::OwnershipType ownership_;
 };
 
-template <>
-class GSListKeeper<TypeTraits<bool> >
-{
-public:
-  typedef bool               CppType;
-  typedef gboolean           CType;
-
-  explicit inline GSListKeeper (const GSList* gslist, Glib::OwnershipType ownership);
-  inline GSListKeeper (const GSListKeeper& keeper);
-  ~GSListKeeper ();
-
-  inline GSList* data() const;
-
-private:
-  GSList* gslist_;
-  mutable Glib::OwnershipType ownership_;
-};
-
 } // namespace Container_Helpers
 
 // a struct instead of templated functions because standard template arguments
 // for function templates is a C++0x feature...
 template <typename T, typename Tr = Glib::Container_Helpers::TypeTraits<T> >
-class VectorHandler
+class ArrayHandler
 {
 public:
   typedef typename Tr::CType CType;
   typedef typename Tr::CppType CppType;
   typedef std::vector<CppType> VectorType;
   typedef typename Glib::Container_Helpers::ArrayKeeper<Tr> ArrayKeeperType;
-  typedef typename Glib::Container_Helpers::GListKeeper<Tr> GListKeeperType;
-  typedef typename Glib::Container_Helpers::GSListKeeper<Tr> GSListKeeperType;
   typedef typename Glib::Container_Helpers::ArrayIterator<Tr> ArrayIteratorType;
-  typedef typename Glib::Container_Helpers::ListIterator<Tr> ListIteratorType;
-  typedef typename Glib::Container_Helpers::SListIterator<Tr> SListIteratorType;
 
 // maybe think about using C++0x move constructors?
   static VectorType array_to_vector (const CType* array, size_t array_size, Glib::OwnershipType ownership);
   static VectorType array_to_vector (const CType* array, Glib::OwnershipType ownership);
-  static VectorType list_to_vector (GList* glist, Glib::OwnershipType ownership);
-  static VectorType slist_to_vector (GSList* gslist, Glib::OwnershipType ownership);
   static ArrayKeeperType vector_to_array (const VectorType& vector);
-  static GListKeeperType vector_to_list (const VectorType& vector);
-  static GSListKeeperType vector_to_slist (const VectorType& vector);
 };
 
 template <>
-class VectorHandler<bool>
+class ArrayHandler<bool>
 {
 public:
   typedef gboolean CType;
   typedef bool CppType;
   typedef std::vector<bool> VectorType;
   typedef Glib::Container_Helpers::ArrayKeeper<Glib::Container_Helpers::TypeTraits<bool> > ArrayKeeperType;
-  typedef Glib::Container_Helpers::GListKeeper<Glib::Container_Helpers::TypeTraits<bool> > GListKeeperType;
-  typedef Glib::Container_Helpers::GSListKeeper<Glib::Container_Helpers::TypeTraits<bool> > GSListKeeperType;
   typedef Glib::Container_Helpers::ArrayIterator<Glib::Container_Helpers::TypeTraits<bool> > ArrayIteratorType;
-  typedef Glib::Container_Helpers::ListIterator<Glib::Container_Helpers::TypeTraits<bool> > ListIteratorType;
-  typedef Glib::Container_Helpers::SListIterator<Glib::Container_Helpers::TypeTraits<bool> > SListIteratorType;
 
 // maybe think about using C++0x move constructors?
   static VectorType array_to_vector (const CType* array, size_t array_size, Glib::OwnershipType ownership);
   static VectorType array_to_vector (const CType* array, Glib::OwnershipType ownership);
-  static VectorType list_to_vector (GList* glist, Glib::OwnershipType ownership);
-  static VectorType slist_to_vector (GSList* gslist, Glib::OwnershipType ownership);
   static ArrayKeeperType vector_to_array (const VectorType& vector);
+};
+
+template <typename T, typename Tr = Glib::Container_Helpers::TypeTraits<T> >
+class ListHandler
+{
+public:
+  typedef typename Tr::CType CType;
+  typedef typename Tr::CppType CppType;
+  typedef std::vector<CppType> VectorType;
+  typedef typename Glib::Container_Helpers::GListKeeper<Tr> GListKeeperType;
+  typedef typename Glib::Container_Helpers::ListIterator<Tr> ListIteratorType;
+
+// maybe think about using C++0x move constructors?
+  static VectorType list_to_vector (GList* glist, Glib::OwnershipType ownership);
   static GListKeeperType vector_to_list (const VectorType& vector);
+};
+
+template <typename T, typename Tr = Glib::Container_Helpers::TypeTraits<T> >
+class SListHandler
+{
+public:
+  typedef typename Tr::CType CType;
+  typedef typename Tr::CppType CppType;
+  typedef std::vector<CppType> VectorType;
+  typedef typename Glib::Container_Helpers::GSListKeeper<Tr> GSListKeeperType;
+  typedef typename Glib::Container_Helpers::SListIterator<Tr> SListIteratorType;
+
+// maybe think about using C++0x move constructors?
+  static VectorType slist_to_vector (GSList* gslist, Glib::OwnershipType ownership);
   static GSListKeeperType vector_to_slist (const VectorType& vector);
 };
 
@@ -653,47 +532,6 @@ bool ListIterator<Tr>::operator!=(const ListIterator<Tr>& rhs) const
   return (node_ != rhs.node_);
 }
 
-/**** Glib::Container_Helpers::ListIterator<TypeTraits<bool> > ****************/
-
-inline
-ListIterator<TypeTraits<bool> >::ListIterator(const GList* node)
-:
-  node_ (node)
-{}
-
-inline
-ListIterator<TypeTraits<bool> >::value_type ListIterator<TypeTraits<bool> >::operator*() const
-{
-  return (GPOINTER_TO_INT (node_->data) ? true : false);
-}
-
-inline
-ListIterator<TypeTraits<bool> >& ListIterator<TypeTraits<bool> >::operator++()
-{
-  node_ = node_->next;
-  return *this;
-}
-
-inline
-const ListIterator<TypeTraits<bool> > ListIterator<TypeTraits<bool> >::operator++(int)
-{
-  const ListIterator<TypeTraits<bool> > tmp (*this);
-  node_ = node_->next;
-  return tmp;
-}
-
-inline
-bool ListIterator<TypeTraits<bool> >::operator==(const ListIterator<TypeTraits<bool> >& rhs) const
-{
-  return (node_ == rhs.node_);
-}
-
-inline
-bool ListIterator<TypeTraits<bool> >::operator!=(const ListIterator<TypeTraits<bool> >& rhs) const
-{
-  return (node_ != rhs.node_);
-}
-
 /**** Glib::Container_Helpers::SListIterator<> ************************/
 
 template <class Tr> inline
@@ -735,47 +573,6 @@ bool SListIterator<Tr>::operator!=(const SListIterator<Tr>& rhs) const
   return (node_ != rhs.node_);
 }
 
-/**** Glib::Container_Helpers::SListIterator<TypeTraits<bool> > ************************/
-
-inline
-SListIterator<TypeTraits<bool> >::SListIterator(const GSList* node)
-:
-  node_ (node)
-{}
-
-inline
-SListIterator<TypeTraits<bool> >::value_type SListIterator<TypeTraits<bool> >::operator*() const
-{
-  return (GPOINTER_TO_INT(node_->data) ? true : false);
-}
-
-inline
-SListIterator<TypeTraits<bool> >& SListIterator<TypeTraits<bool> >::operator++()
-{
-  node_ = node_->next;
-  return *this;
-}
-
-inline
-const SListIterator<TypeTraits<bool> > SListIterator<TypeTraits<bool> >::operator++(int)
-{
-  const SListIterator<TypeTraits<bool> > tmp (*this);
-  node_ = node_->next;
-  return tmp;
-}
-
-inline
-bool SListIterator<TypeTraits<bool> >::operator==(const SListIterator<TypeTraits<bool> >& rhs) const
-{
-  return (node_ == rhs.node_);
-}
-
-inline
-bool SListIterator<TypeTraits<bool> >::operator!=(const SListIterator<TypeTraits<bool> >& rhs) const
-{
-  return (node_ != rhs.node_);
-}
-
 /**** Glib::Container_Helpers::ArrayKeeper<> ************************/
 
 template <typename Tr>
@@ -863,35 +660,6 @@ inline GList* GListKeeper<Tr>::data () const
   return glist_;
 }
 
-/**** Glib::Container_Helpers::GListKeeper<TypeTraits<bool> > ***************/
-
-inline GListKeeper<TypeTraits<bool> >::GListKeeper (const GList* glist, Glib::OwnershipType ownership)
-:
-  glist_ (const_cast<GList*> (glist)),
-  ownership_ (ownership)
-{}
-
-inline GListKeeper<TypeTraits<bool> >::GListKeeper (const GListKeeper& keeper)
-:
-  glist_ (keeper.glist_),
-  ownership_ (keeper.ownership_)
-{
-  keeper.ownership_ = Glib::OWNERSHIP_NONE;
-}
-
-GListKeeper<TypeTraits<bool> >::~GListKeeper ()
-{
-  if (glist_ && ownership_ != Glib::OWNERSHIP_NONE)
-  {
-    g_list_free (glist_);
-  }
-}
-
-inline GList* GListKeeper<TypeTraits<bool> >::data () const
-{
-  return glist_;
-}
-
 /**** Glib::Container_Helpers::GSListKeeper<> ************************/
 
 template <typename Tr>
@@ -934,42 +702,13 @@ inline GSList* GSListKeeper<Tr>::data () const
   return gslist_;
 }
 
-/**** Glib::Container_Helpers::GSListKeeper<TypeTraits<bool> > ****************/
-
-inline GSListKeeper<TypeTraits<bool> >::GSListKeeper (const GSList* gslist, Glib::OwnershipType ownership)
-:
-  gslist_ (const_cast<GSList*> (gslist)),
-  ownership_ (ownership)
-{}
-
-inline GSListKeeper<TypeTraits<bool> >::GSListKeeper (const GSListKeeper& keeper)
-:
-  gslist_ (keeper.gslist_),
-  ownership_ (keeper.ownership_)
-{
-  keeper.ownership_ = Glib::OWNERSHIP_NONE;
-}
-
-GSListKeeper<TypeTraits<bool> >::~GSListKeeper ()
-{
-  if (gslist_ && ownership_ != Glib::OWNERSHIP_NONE)
-  {
-    g_slist_free (gslist_);
-  }
-}
-
-inline GSList* GSListKeeper<TypeTraits<bool> >::data () const
-{
-  return gslist_;
-}
-
 } // namespace Container_Helpers
 
-/**** Glib::VectorHandler<> ************************/
+/**** Glib::ArrayHandler<> ************************/
 
 template <typename T, class Tr>
-typename VectorHandler<T, Tr>::VectorType
-VectorHandler<T, Tr>::array_to_vector (const CType* array, size_t array_size, Glib::OwnershipType ownership)
+typename ArrayHandler<T, Tr>::VectorType
+ArrayHandler<T, Tr>::array_to_vector (const CType* array, size_t array_size, Glib::OwnershipType ownership)
 {
   // it will handle destroying data depending on passed ownership.
   ArrayKeeperType keeper (array, array_size, ownership);
@@ -984,90 +723,24 @@ VectorHandler<T, Tr>::array_to_vector (const CType* array, size_t array_size, Gl
 }
 
 template <typename T, class Tr>
-typename VectorHandler<T, Tr>::VectorType
-VectorHandler<T, Tr>::array_to_vector(const CType* array, Glib::OwnershipType ownership)
+typename ArrayHandler<T, Tr>::VectorType
+ArrayHandler<T, Tr>::array_to_vector(const CType* array, Glib::OwnershipType ownership)
 {
   return array_to_vector (array, Glib::Container_Helpers::compute_array_size2 (array), ownership);
 }
 
 template <typename T, class Tr>
-typename VectorHandler<T, Tr>::VectorType
-VectorHandler<T, Tr>::list_to_vector (GList* glist, Glib::OwnershipType ownership)
-{
-  // it will handle destroying data depending on passed ownership.
-  GListKeeperType keeper (glist, ownership);
-#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
-  return VectorType (ListIteratorType (glist), ListIteratorType (0));
-#else
-  VectorType temp;
-  temp.reserve (g_list_length (glist));
-  Glib::Container_Helpers::fill_container (temp, ListIteratorType (glist), ListIteratorType (0));
-  return temp;
-#endif
-}
-
-template <typename T, class Tr>
-typename VectorHandler<T, Tr>::VectorType
-VectorHandler<T, Tr>::slist_to_vector (GSList* gslist, Glib::OwnershipType ownership)
-{
-  // it will handle destroying data depending on passed ownership.
-  GSListKeeperType keeper (gslist, ownership);
-#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
-  return VectorType (SListIteratorType (gslist), SListIteratorType (0));
-#else
-  VectorType temp;
-  temp.reserve (g_slist_length (gslist));
-  Glib::Container_Helpers::fill_container (temp, SListIteratorType (gslist), SListIteratorType (0));
-  return temp;
-#endif
-}
-
-template <typename T, class Tr>
-typename VectorHandler<T, Tr>::ArrayKeeperType
-VectorHandler<T, Tr>::vector_to_array (const VectorType& vector)
+typename ArrayHandler<T, Tr>::ArrayKeeperType
+ArrayHandler<T, Tr>::vector_to_array (const VectorType& vector)
 {
   return ArrayKeeperType (Glib::Container_Helpers::create_array2<Tr> (vector.begin (), vector.size ()), vector.size (), Glib::OWNERSHIP_SHALLOW);
 }
 
-template <typename T, class Tr>
-typename VectorHandler<T, Tr>::GListKeeperType
-VectorHandler<T, Tr>::vector_to_list (const VectorType& vector)
-{
-  return GListKeeperType (Glib::Container_Helpers::create_glist2<Tr> (vector.begin(), vector.end()), Glib::OWNERSHIP_SHALLOW);
-}
+/**** Glib::ListHandler<> ************************/
 
 template <typename T, class Tr>
-typename VectorHandler<T, Tr>::GSListKeeperType
-VectorHandler<T, Tr>::vector_to_slist (const VectorType& vector)
-{
-  return GSListKeeperType (Glib::Container_Helpers::create_gslist2<Tr> (vector.begin (), vector.end ()), Glib::OWNERSHIP_SHALLOW);
-}
-
-/**** Glib::VectorHandler<bool> ************************/
-
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::array_to_vector (const CType* array, size_t array_size, Glib::OwnershipType ownership)
-{
-  // it will handle destroying data depending on passed ownership.
-  ArrayKeeperType keeper (array, array_size, ownership);
-#ifdef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
-  return VectorType (ArrayIteratorType (array), ArrayIteratorType (array + array_size));
-#else
-  VectorType temp;
-  temp.reserve (array_size);
-  Glib::Container_Helpers::fill_container (temp, ArrayIteratorType (array), ArrayIteratorType (array + array_size));
-  return temp;
-#endif
-}
-
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::array_to_vector(const CType* array, Glib::OwnershipType ownership)
-{
-  return array_to_vector (array, Glib::Container_Helpers::compute_array_size2 (array), ownership);
-}
-
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::list_to_vector (GList* glist, Glib::OwnershipType ownership)
+typename ListHandler<T, Tr>::VectorType
+ListHandler<T, Tr>::list_to_vector (GList* glist, Glib::OwnershipType ownership)
 {
   // it will handle destroying data depending on passed ownership.
   GListKeeperType keeper (glist, ownership);
@@ -1081,8 +754,18 @@ VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::list_to_vector
 #endif
 }
 
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::slist_to_vector (GSList* gslist, Glib::OwnershipType ownership)
+template <typename T, class Tr>
+typename ListHandler<T, Tr>::GListKeeperType
+ListHandler<T, Tr>::vector_to_list (const VectorType& vector)
+{
+  return GListKeeperType (Glib::Container_Helpers::create_glist2<Tr> (vector.begin(), vector.end()), Glib::OWNERSHIP_SHALLOW);
+}
+
+/**** Glib::SListHandler<> ************************/
+
+template <typename T, class Tr>
+typename SListHandler<T, Tr>::VectorType
+SListHandler<T, Tr>::slist_to_vector (GSList* gslist, Glib::OwnershipType ownership)
 {
   // it will handle destroying data depending on passed ownership.
   GSListKeeperType keeper (gslist, ownership);
@@ -1096,22 +779,11 @@ VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::slist_to_vector
 #endif
 }
 
-typename VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::ArrayKeeperType
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::vector_to_array (const VectorType& vector)
-{
-  return ArrayKeeperType (Glib::Container_Helpers::create_bool_array (vector.begin (), vector.size ()), vector.size (), Glib::OWNERSHIP_SHALLOW);
-}
-
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::GListKeeperType
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::vector_to_list (const VectorType& vector)
-{
-  return GListKeeperType (Glib::Container_Helpers::create_bool_glist (vector.begin (), vector.end ()), Glib::OWNERSHIP_SHALLOW);
-}
-
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::GSListKeeperType
-VectorHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::vector_to_slist (const VectorType& vector)
+template <typename T, class Tr>
+typename SListHandler<T, Tr>::GSListKeeperType
+SListHandler<T, Tr>::vector_to_slist (const VectorType& vector)
 {
-  return GSListKeeperType (Glib::Container_Helpers::create_bool_gslist (vector.begin (), vector.end ()), Glib::OWNERSHIP_SHALLOW);
+  return GSListKeeperType (Glib::Container_Helpers::create_gslist2<Tr> (vector.begin (), vector.end ()), Glib::OWNERSHIP_SHALLOW);
 }
 
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */



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