glibmm  2.33.2
Public Types | Static Public Member Functions
Glib::SListHandler Class Reference

A utility for converting between std::vector and GSList. More...

#include <glibmm/vectorutils.h>

List of all members.

Public Types

typedef Tr::CType CType
typedef T CppType
typedef std::vector< CppTypeVectorType
typedef
Glib::Container_Helpers::GSListKeeper
< Tr > 
GSListKeeperType
typedef
Glib::Container_Helpers::SListIterator
< Tr > 
SListIteratorType

Static Public Member Functions

static VectorType slist_to_vector (GSList* gslist, Glib::OwnershipType ownership)
static GSListKeeperType vector_to_slist (const VectorType& vector)

Detailed Description

A utility for converting between std::vector and GSList.

This would normally only be used by glibmm or gtkmm itself, or similar libraries that wrap C APIs.

For instance:

 std::vector< Glib::RefPtr<Display> > DisplayManager::list_displays()
 {
   return Glib::SListHandler<Glib::RefPtr<Display> >::slist_to_vector(gdk_display_manager_list_displays(gobj()), Glib::OWNERSHIP_SHALLOW);
 }

or

 void Stuff::set_slist(const std::vector<int>& ints)
 {
   g_stuff_set_slist(gobj(), Glib::SListHandler<int>::vector_to_slist(ints).data ());
 }

Note that usage below is wrong - data() returns a pointer to data owned by a temporary SListKeeper returned by vector_to_slist(), which is destroyed at the end of this instruction. For details, see Glib::SListKeeper.

 GSList* gslist = Glib::SListHandler< Glib::RefPtr<Display> >::vector_to_slist(vec).data();

Member Typedef Documentation

typedef Tr::CType Glib::SListHandler::CType

Member Function Documentation

static VectorType Glib::SListHandler::slist_to_vector ( GSList *  gslist,
Glib::OwnershipType  ownership 
) [static]
static GSListKeeperType Glib::SListHandler::vector_to_slist ( const VectorType vector) [static]