gtkmm 4.17.0
|
Typedefed as TreeModel::iterator and TreeModel::const_iterator. More...
#include <gtkmm/treeiter.h>
Public Types | |
using | iterator_category = std::bidirectional_iterator_tag |
TreeIter instances can be incremented and decremented. | |
using | value_type = T |
The TreeRow or TreeConstRow type to which the iterator refers. | |
using | difference_type = int |
This is not used. | |
using | reference = T & |
A reference to the TreeRow or TreeConstRow type, as yielded by operator*() | |
using | pointer = T * |
A pointer to the TreeRow or TreeConstRow type, as yielded by operator->() | |
Public Member Functions | |
TreeIter () | |
Default constructor creates an invalid iterator, not referring to a model. | |
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. | |
template<typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type> | |
TreeIter & | operator= (const TreeIter< T2 > &src) |
iterator to const_iterator assignment. | |
TreeIter & | operator++ () |
Increment the iterator to refer to the next position in the model, and return a reference to the iterator as it is after the increment. | |
TreeIter | operator++ (int) |
Increment the iterator to refer to the next position in the model, but return a copy of the iterator as it was before the increment. | |
TreeIter & | operator-- () |
Note that this is very slow compared to operator++(). | |
TreeIter | operator-- (int) |
Note that this is very slow compared to operator++(int). | |
reference | operator* () const |
Dereference the iterator to get a TreeRow or TreeConstRow, as appropriate. | |
pointer | operator-> () const |
Dereference the iterator to get a TreeRow or TreeConstRow, as appropriate. | |
operator bool () const | |
Discover whether the iterator is valid, and not equal to end(). | |
![]() | |
bool | equal (const TreeIterBase3 &other) const |
int | get_stamp () const |
This is only useful when implementing a custom Gtk::TreeModel class. | |
void | set_stamp (int stamp) |
This is only useful when implementing a custom Gtk::TreeModel class. | |
![]() | |
TreeIterBase (const TreeIterBase &other) noexcept | |
TreeIterBase & | operator= (const TreeIterBase &other) noexcept |
TreeIterBase (TreeIterBase &&other) noexcept | |
TreeIterBase & | operator= (TreeIterBase &&other) noexcept |
TreeIterBase () | |
TreeIterBase (const GtkTreeIter *gobject) | |
GtkTreeIter * | gobj () |
Provides access to the underlying C instance. | |
const GtkTreeIter * | gobj () const |
Provides access to the underlying C instance. | |
Related Symbols | |
(Note that these are not member symbols.) | |
bool | operator== (const TreeIterBase3 &lhs, const TreeIterBase3 &rhs) |
bool | operator!= (const TreeIterBase3 &lhs, const TreeIterBase3 &rhs) |
Additional Inherited Members | |
![]() | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
![]() | |
GtkTreeIter | gobject_ |
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).
One can convert an iterator to a TreeRow or TreeConstRow, as appropriate, by dereferencing it via TreeIter::operator*() or TreeIter::operator->(). The row classes can give nicer syntax by avoiding repeatedly dereferencing iterators. But see the warning re: reference safety in the doc of TreeIter::operator*().
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().
T | TreeRow for an iterator, TreeConstRow for a const_iterator. |
using Gtk::TreeIter< T >::difference_type = int |
This is not used.
using Gtk::TreeIter< T >::iterator_category = std::bidirectional_iterator_tag |
TreeIter instances can be incremented and decremented.
using Gtk::TreeIter< T >::pointer = T* |
A pointer to the TreeRow or TreeConstRow type, as yielded by operator->()
using Gtk::TreeIter< T >::reference = T& |
A reference to the TreeRow or TreeConstRow type, as yielded by operator*()
using Gtk::TreeIter< T >::value_type = T |
The TreeRow or TreeConstRow type to which the iterator refers.
Gtk::TreeIter< T >::TreeIter | ( | ) |
Default constructor creates an invalid iterator, not referring to a model.
Gtk::TreeIter< T >::TreeIter | ( | const TreeIter< T2 > & | src | ) |
iterator to const_iterator conversion.
|
inlineexplicit |
Discover whether the iterator is valid, and not equal to end().
For instance,
|
inline |
Dereference the iterator to get a TreeRow or TreeConstRow, as appropriate.
Warning: The returned reference is implemented by casting from *this
, and so the returned reference is only valid while this iter is. Thus, if you do something like auto& row = *model->append()
, you get a dangling reference to the returned temporary and undefined behaviour. Thus for such cases, you must copy the returned row via auto row = *model->append()
or equivalent. This risk cannot be mitigated in gtkmm v4, and the class will not be in v5.
TreeIter & Gtk::TreeIter< T >::operator++ | ( | ) |
Increment the iterator to refer to the next position in the model, and return a reference to the iterator as it is after the increment.
TreeIter Gtk::TreeIter< T >::operator++ | ( | int | ) |
Increment the iterator to refer to the next position in the model, but return a copy of the iterator as it was before the increment.
TreeIter & Gtk::TreeIter< T >::operator-- | ( | ) |
Note that this is very slow compared to operator++().
Decrement the iterator to refer to the previous position in the model, and return a reference to the iterator as it is after the decrement.
TreeIter Gtk::TreeIter< T >::operator-- | ( | int | ) |
Note that this is very slow compared to operator++(int).
Decrement the iterator to refer to the previous position in the model, but return a copy of the iterator as it was before the decrement.
|
inline |
Dereference the iterator to get a TreeRow or TreeConstRow, as appropriate.
TreeIter & Gtk::TreeIter< T >::operator= | ( | const TreeIter< T2 > & | src | ) |
iterator to const_iterator assignment.
|
related |
|
related |