glibmm 2.80.0
Public Types | Static Public Member Functions | List of all members
Glib::SListHandler< T, Tr > Class Template Reference

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

#include <glibmm/vectorutils.h>

Public Types

using CType = typename Tr::CType
 
using CppType = T
 
using VectorType = std::vector< CppType >
 
using GSListKeeperType = typename Glib::Container_Helpers::GSListKeeper< Tr >
 
using SListIteratorType = typename Glib::Container_Helpers::SListIterator< Tr >
 

Static Public Member Functions

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

Detailed Description

template<typename T, typename Tr = Glib::Container_Helpers::TypeTraits<T>>
class Glib::SListHandler< T, Tr >

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()
{
>::slist_to_vector(gdk_display_manager_list_displays(gobj()), Glib::OWNERSHIP_SHALLOW);
}
A utility for converting between std::vector and GSList.
Definition: vectorutils.h:571
static VectorType slist_to_vector(GSList *gslist, Glib::OwnershipType ownership)
@ OWNERSHIP_SHALLOW
Definition: containerhandle_shared.h:52

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.

static GSListKeeperType vector_to_slist(const VectorType &vector)

Member Typedef Documentation

◆ CppType

template <typename T , typename Tr = Glib::Container_Helpers::TypeTraits<T>>
using Glib::SListHandler< T, Tr >::CppType = T

◆ CType

template <typename T , typename Tr = Glib::Container_Helpers::TypeTraits<T>>
using Glib::SListHandler< T, Tr >::CType = typename Tr::CType

◆ GSListKeeperType

template <typename T , typename Tr = Glib::Container_Helpers::TypeTraits<T>>
using Glib::SListHandler< T, Tr >::GSListKeeperType = typename Glib::Container_Helpers::GSListKeeper<Tr>

◆ SListIteratorType

template <typename T , typename Tr = Glib::Container_Helpers::TypeTraits<T>>
using Glib::SListHandler< T, Tr >::SListIteratorType = typename Glib::Container_Helpers::SListIterator<Tr>

◆ VectorType

template <typename T , typename Tr = Glib::Container_Helpers::TypeTraits<T>>
using Glib::SListHandler< T, Tr >::VectorType = std::vector<CppType>

Member Function Documentation

◆ slist_to_vector()

template <typename T , typename Tr = Glib::Container_Helpers::TypeTraits<T>>
static VectorType Glib::SListHandler< T, Tr >::slist_to_vector ( GSList *  gslist,
Glib::OwnershipType  ownership 
)
static

◆ vector_to_slist()

template <typename T , typename Tr = Glib::Container_Helpers::TypeTraits<T>>
static GSListKeeperType Glib::SListHandler< T, Tr >::vector_to_slist ( const VectorType vector)
static