gtkmm  4.8.0
Public Types | Public Member Functions | Related Functions | List of all members
Gtk::TreeIter< T > Class Template Reference

Typedefed as TreeModel::iterator and TreeModel::const_iterator. More...

#include <gtkmm/treeiter.h>

Inheritance diagram for Gtk::TreeIter< T >:
Inheritance graph
[legend]

Public Types

using iterator_category = std::bidirectional_iterator_tag
 
using value_type = T
 
using difference_type = int
 
using reference = T &
 
using pointer = T *
 

Public Member Functions

 TreeIter ()
 
template<typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
 TreeIter (const TreeIter< T2 > & src)
 iterator to const_iterator conversion. More...
 
template<typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
TreeIteroperator= (const TreeIter< T2 > & src)
 iterator to const_iterator assignment. More...
 
TreeIteroperator++ ()
 
TreeIter operator++ (int)
 
TreeIteroperator-- ()
 Note that this is very slow compared to operator++(). More...
 
TreeIter operator-- (int)
 Note that this is very slow compared to operator++(int). More...
 
reference operator* () const
 
pointer operator-> () const
 
 operator bool () const
 Discover whether the iterator is valid, and not equal to end(). More...
 
- Public Member Functions inherited from Gtk::TreeIterBase3
bool equal (const TreeIterBase3 & other) const
 
int get_stamp () const
 This is only useful when implementing a custom Gtk::TreeModel class. More...
 
void set_stamp (int stamp)
 This is only useful when implementing a custom Gtk::TreeModel class. More...
 
- Public Member Functions inherited from Gtk::TreeIterBase
 TreeIterBase (const TreeIterBase & other) noexcept
 
TreeIterBaseoperator= (const TreeIterBase & other) noexcept
 
 TreeIterBase (TreeIterBase && other) noexcept
 
TreeIterBaseoperator= (TreeIterBase && other) noexcept
 
 TreeIterBase ()
 
 TreeIterBase (const GtkTreeIter * gobject)
 
GtkTreeIter * gobj ()
 Provides access to the underlying C instance. More...
 
const GtkTreeIter * gobj () const
 Provides access to the underlying C instance. More...
 

Related Functions

(Note that these are not member functions.)

bool operator== (const TreeIterBase3 & lhs, const TreeIterBase3 & rhs)
 
bool operator!= (const TreeIterBase3 & lhs, const TreeIterBase3 & rhs)
 

Additional Inherited Members

- Static Public Member Functions inherited from Gtk::TreeIterBase
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
- Protected Attributes inherited from Gtk::TreeIterBase
GtkTreeIter gobject_
 

Detailed Description

template<typename T>
class Gtk::TreeIter< T >

Typedefed as TreeModel::iterator and TreeModel::const_iterator.

A Gtk::TreeModel::iterator is a reference to a specific node on a specific model. It is a generic structure with an integer and three generic pointers. These are filled in by the model in a model-specific way.

One can convert a path to an iterator by calling Gtk::TreeModel::get_iter().

These iterators are the primary way of accessing a model and are similar to the iterators used by Gtk::TextBuffer. The model interface defines a set of operations using them for navigating the model.

The lifecycle of an iterator can be a little confusing at first. Iterators are expected to always be valid for as long as the model is unchanged (and doesn't emit a signal). Additionally, some models guarantee that an iterator is valid for as long as the node it refers to is valid (most notably the Gtk::TreeStore and Gtk::ListStore).

Although generally uninteresting, as one always has to allow for the case where iterators do not persist beyond a signal, some very important performance enhancements were made in the sort model. As a result, the Gtk::TreeModel::Flags::ITERS_PERSIST flag was added to indicate this behaviour - see Gtk::TreeModel::get_flags().

Template Parameters
TTreeRow for an iterator, TreeConstRow for a const_iterator.
Deprecated:
4.10: Use Gio::ListModel instead.

Member Typedef Documentation

◆ difference_type

template <typename T >
using Gtk::TreeIter< T >::difference_type = int

◆ iterator_category

template <typename T >
using Gtk::TreeIter< T >::iterator_category = std::bidirectional_iterator_tag

◆ pointer

template <typename T >
using Gtk::TreeIter< T >::pointer = T*

◆ reference

template <typename T >
using Gtk::TreeIter< T >::reference = T&

◆ value_type

template <typename T >
using Gtk::TreeIter< T >::value_type = T

Constructor & Destructor Documentation

◆ TreeIter() [1/2]

template <typename T >
Gtk::TreeIter< T >::TreeIter ( )

◆ TreeIter() [2/2]

template <typename T >
template <typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
Gtk::TreeIter< T >::TreeIter ( const TreeIter< T2 > &  src)

iterator to const_iterator conversion.

Member Function Documentation

◆ operator bool()

template <typename T >
Gtk::TreeIter< T >::operator bool ( ) const
inlineexplicit

Discover whether the iterator is valid, and not equal to end().

For instance,

if (treeiter)
do_something();
Since gtkmm 3.22:

◆ operator*()

template <typename T >
reference Gtk::TreeIter< T >::operator* ( ) const
inline

◆ operator++() [1/2]

template <typename T >
TreeIter& Gtk::TreeIter< T >::operator++ ( )

◆ operator++() [2/2]

template <typename T >
TreeIter Gtk::TreeIter< T >::operator++ ( int  )

◆ operator--() [1/2]

template <typename T >
TreeIter& Gtk::TreeIter< T >::operator-- ( )

Note that this is very slow compared to operator++().

◆ operator--() [2/2]

template <typename T >
TreeIter Gtk::TreeIter< T >::operator-- ( int  )

Note that this is very slow compared to operator++(int).

◆ operator->()

template <typename T >
pointer Gtk::TreeIter< T >::operator-> ( ) const
inline

◆ operator=()

template <typename T >
template <typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
TreeIter& Gtk::TreeIter< T >::operator= ( const TreeIter< T2 > &  src)

iterator to const_iterator assignment.

Friends And Related Function Documentation

◆ operator!=()

template <typename T >
bool operator!= ( const TreeIterBase3 lhs,
const TreeIterBase3 rhs 
)
related

◆ operator==()

template <typename T >
bool operator== ( const TreeIterBase3 lhs,
const TreeIterBase3 rhs 
)
related