Commit 7dff74cc authored by Murray Cumming's avatar Murray Cumming

Use a BoolExpr typedef to make operator const void* clearer.

* gtk/gtkmm/stockid.[h|cc]:
* gtk/src/iconinfo.hg:
* gtk/src/papersize.hg:
* gtk/src/textiter.hg:
* gtk/src/treeiter.hg:
* gtk/src/treepath.hg:
* gtk/src/treerowreference.hg: Use a BoolExpr typedef and add documentation
because not all people will know the purpose of operator const void*.
  This was suggested by Daniel Elstner.
parent c80c265c
2011-04-04 Murray Cumming <murrayc@murrayc.com>
Use a BoolExpr typedef to make operator const void* clearer.
* gtk/gtkmm/stockid.[h|cc]:
* gtk/src/iconinfo.hg:
* gtk/src/papersize.hg:
* gtk/src/textiter.hg:
* gtk/src/treeiter.hg:
* gtk/src/treepath.hg:
* gtk/src/treerowreference.hg: Use a BoolExpr typedef and add documentation
because not all people will know the purpose of operator const void*.
This was suggested by Daniel Elstner.
2011-04-04 Murray Cumming <murrayc@murrayc.com>
Remove RecentInfo::operator const void*.
......
......@@ -68,9 +68,19 @@ public:
*/
StockID& operator=(const StockID& other);
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Tests whether the StockID is not empty.
* For instance,
* @code
* if(stockid)
* do_something()
* @endcode
*/
operator const void*() const;
operator BoolExpr() const;
/** Check if two StockIDs are equal.
* @param rhs Another StockID.
......
......@@ -41,8 +41,19 @@ public:
IconInfo(const Glib::RefPtr<IconTheme>& icon_theme, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
_IGNORE(gtk_icon_info_new_for_pixbuf)
///Tests whether the IconInfo is valid.
operator const void*() const;
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Tests whether the IconInfo is valid.
* For instance,
* @code
* if(iconinfo)
* do_something()
* @endcode
*/
operator BoolExpr() const;
_WRAP_METHOD(int get_base_size() const, gtk_icon_info_get_base_size)
_WRAP_METHOD(Glib::ustring get_filename() const, gtk_icon_info_get_filename)
......
......@@ -68,10 +68,21 @@ public:
_IGNORE(gtk_paper_size_copy, gtk_paper_size_free, gtk_paper_size_is_equal)
bool equal(const PaperSize& other) const;
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Returns true if the PaperSize is a valid object.
* For instance,
* @code
* if(papersize)
* do_something()
* @endcode
*
* @newin{2,12}
*/
operator const void*() const;
operator BoolExpr() const;
#m4 _CONVERSION(`GList*', `std::vector<PaperSize>',`Glib::ListHandler<PaperSize, PaperSizeTraits>::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
_WRAP_METHOD(static std::vector<PaperSize> get_paper_sizes(bool include_custom = true), gtk_paper_size_get_paper_sizes)
......
......@@ -75,8 +75,19 @@ public:
/** Alias for get_char(). */
inline value_type operator*() const;
/** Alias for !is_end(). */
inline operator const void*() const;
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Alias for !is_end()
* For instance,
* @code
* if(textiter)
* do_something()
* @endcode
*/
inline operator BoolExpr() const;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
......@@ -325,7 +336,7 @@ TextIter::value_type TextIter::operator*() const
}
inline
TextIter::operator const void*() const
TextIter::operator BoolExpr() const
{
return (const void*)!is_end();
}
......
......@@ -118,9 +118,19 @@ public:
bool equal(const TreeIter& other) const;
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Discover whether the iterator is valid, and not equal to end().
* For instance,
* @code
* if(treeiter)
* do_something()
* @endcode
*/
operator const void*() const;
operator BoolExpr() 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.
......@@ -286,9 +296,19 @@ public:
*/
TreeIter parent() const;
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Discover whether this is a valid row.
* For instance,
* @code
* if(treeiter)
* do_something()
* @endcode
*/
operator const void*() const;
operator BoolExpr() const;
/// Provides access to the underlying C GObject.
GtkTreeIter* gobj() { return TreeIter::gobj(); }
......@@ -349,7 +369,20 @@ public:
size_type size() const;
bool empty() const;
operator const void*() const { return (const void*)!empty(); }
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Discover whether this is a valid TreeNodeChildren.
* For instance,
* @code
* if(children)
* do_something()
* @endcode
*/
operator BoolExpr() const { return (const void*)!empty(); }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
......
......@@ -83,10 +83,21 @@ public:
// I think it's OK for this assignment to be implicit. It's very useful.
TreePath& operator=(const TreeModel::iterator& iter);
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** Checks that the path is not empty, by calling empty().
* For instance,
* @code
* if(treepath)
* do_something()
* @endcode
*
* @newin{2,16}
*/
operator const void*() const;
operator BoolExpr() const;
template <class In> inline void assign(In pbegin, In pend);
template <class In> void append(In pbegin, In pend);
......
......@@ -39,8 +39,19 @@ class TreeRowReference
public:
TreeRowReference(const Glib::RefPtr<TreeModel>& model, const TreeModel::Path& path);
///The same as is_valid().
operator const void*() const;
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
*/
typedef const void* BoolExpr;
/** The same as is_valid().
* For instance,
* @code
* if(treerowreference)
* do_something()
* @endcode
*/
operator BoolExpr() const;
_WRAP_METHOD(TreeModel::Path get_path() const, gtk_tree_row_reference_get_path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment