glibmm: Glib::ListHandler< T, Tr > Class Template Reference

glibmm 2.66.9

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

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

`#include <glibmm/vectorutils.h>`

## Public Types
using | CType = typename Tr::CType
using | CppType = T
using | VectorType = std::vector<CppType>
using | GListKeeperType = typename Glib::Container_Helpers::GListKeeper<Tr>
using | ListIteratorType = typename Glib::Container_Helpers::ListIterator<Tr>

## Static Public Member Functions
static VectorType | list_to_vector (GList * glist, Glib::OwnershipType ownership)
static GListKeeperType | vector_to_list (const VectorType & vector)

## Detailed Description

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

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

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

For instance:

std::vector< Glib::RefPtr<Window> > Window::get_children()
{
return Glib::ListHandler<Glib::RefPtr<Window>
>::list_to_vector(gdk_window_get_children(gobj()), Glib::OWNERSHIP_SHALLOW);
}
std::vector
Glib::ListHandler
A utility for converting between std::vector and GList.
Definition vectorutils.h:530
Glib::ListHandler::list_to_vector
static VectorType list_to_vector(GList *glist, Glib::OwnershipType ownership)
Glib::OWNERSHIP_SHALLOW
@ OWNERSHIP_SHALLOW
Definition containerhandle_shared.h:52

or

void Window::set_icon_list(const std::vector< Glib::RefPtr<Gdk::Pixbuf> >& pixbufs)
{
gdk_window_set_icon_list(gobj(), Glib::ListHandler<Glib::RefPtr<Gdk::Pixbuf>
>::vector_to_list(pixbufs).data ());
}
data
constexpr auto data(_Container &__cont) noexcept(noexcept(__cont.data())) -> decltype(__cont.data())
Glib::ListHandler::vector_to_list
static GListKeeperType vector_to_list(const VectorType &vector)
Glib::RefPtr
RefPtr<> is a reference-counting shared smartpointer.
Definition refptr.h:52

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

GList* glist = Glib::ListHandler<Glib::RefPtr<Gdk::Pixbuf> >::vector_to_list(pixbufs).data();

## Member Typedef Documentation

## ◆ CppType

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

using Glib::ListHandler< T, Tr >::CppType = T

## ◆ CType

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

using Glib::ListHandler< T, Tr >::CType = typename Tr::CType

## ◆ GListKeeperType

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

using Glib::ListHandler< T, Tr >::GListKeeperType = typename Glib::Container_Helpers::GListKeeper<Tr>

## ◆ ListIteratorType

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

using Glib::ListHandler< T, Tr >::ListIteratorType = typename Glib::Container_Helpers::ListIterator<Tr>

## ◆ VectorType

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

using Glib::ListHandler< T, Tr >::VectorType = std::vector<CppType>

## Member Function Documentation

## ◆ list_to_vector()

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

VectorType Glib::ListHandler< T, Tr >::list_to_vector | ( | GList * | glist,
|  | Glib::OwnershipType | ownership )
| static

## ◆ vector_to_list()

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

GListKeeperType Glib::ListHandler< T, Tr >::vector_to_list | ( | const VectorType & | vector | ) |
| static