gtkmm 3.24.7
Public Types | Public Member Functions | Related Functions | List of all members
Gtk::TreeIter Class Reference

A Gtk::TreeModel::iterator is a reference to a specific node on a specific model. More...

#include <gtkmm/treeiter.h>

Inheritance diagram for Gtk::TreeIter:
Inheritance graph
[legend]

Public Types

typedef std::bidirectional_iterator_tag iterator_category
 
typedef Gtk::TreeRow value_type
 
typedef int difference_type
 
typedef const Gtk::TreeRowreference
 
typedef const Gtk::TreeRowpointer
 
typedef const void * BoolExpr
 This typedef is just to make it more obvious that our operator const void* should be used like operator bool(). More...
 

Public Member Functions

 TreeIter ()
 
TreeIteroperator++ ()
 
const TreeIter operator++ (int)
 
TreeIteroperator-- ()
 Please note that this is very slow compared to operator++(). More...
 
const TreeIter operator-- (int)
 Please note that this is very slow compared to operator++(). More...
 
reference operator* () const
 
pointer operator-> () const
 
bool equal (const TreeIter & other) const
 
 operator BoolExpr () const
 Discover whether the iterator is valid, and not equal to end(). More...
 
 operator bool () const
 Discover whether the iterator is valid, and not equal to end(). More...
 
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 TreeIter & lhs, const TreeIter & rhs)
 
bool operator!= (const TreeIter & lhs, const TreeIter & 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

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::TREE_MODEL_ITERS_PERSIST flag was added to indicate this behaviour - see Gtk::TreeModel::get_flags().

Typedefed as Gtk::TreeModel::iterator. The Gtk::TreeModel iterator.

Member Typedef Documentation

◆ BoolExpr

typedef const void* Gtk::TreeIter::BoolExpr

This typedef is just to make it more obvious that our operator const void* should be used like operator bool().

Deprecated:
Use the explicit operator bool() instead.

◆ difference_type

◆ iterator_category

◆ pointer

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ TreeIter()

Gtk::TreeIter::TreeIter ( )

Member Function Documentation

◆ equal()

bool Gtk::TreeIter::equal ( const TreeIter other) const

◆ get_stamp()

int Gtk::TreeIter::get_stamp ( ) const

This is only useful when implementing a custom Gtk::TreeModel class.

Compare the iterator's stamp with your model's stamp to discover whether it is valid.

See also
set_stamp().
Returns
The iterator's stamp.

◆ operator bool()

Gtk::TreeIter::operator bool ( ) const
explicit

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

For instance,

if(treeiter)
do_something()
Since gtkmm 3.22:

◆ operator BoolExpr()

Gtk::TreeIter::operator BoolExpr ( ) const

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

For instance,

if(treeiter)
do_something()
Deprecated:
Use the explicit operator bool() instead.

◆ operator*()

reference Gtk::TreeIter::operator* ( ) const
inline

◆ operator++() [1/2]

TreeIter & Gtk::TreeIter::operator++ ( )

◆ operator++() [2/2]

const TreeIter Gtk::TreeIter::operator++ ( int  )

◆ operator--() [1/2]

TreeIter & Gtk::TreeIter::operator-- ( )

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

◆ operator--() [2/2]

const TreeIter Gtk::TreeIter::operator-- ( int  )

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

◆ operator->()

pointer Gtk::TreeIter::operator-> ( ) const
inline

◆ set_stamp()

void Gtk::TreeIter::set_stamp ( int  stamp)

This is only useful when implementing a custom Gtk::TreeModel class.

Set the stamp to be equal to your model's stamp, to mark the iterator as valid. When your model's structure changes, you should increment your model's stamp to mark all older iterators as invalid. They will be recognised as invalid because they will then have an incorrect stamp.

Friends And Related Function Documentation

◆ operator!=()

bool operator!= ( const TreeIter lhs,
const TreeIter rhs 
)
related

◆ operator==()

bool operator== ( const TreeIter lhs,
const TreeIter rhs 
)
related