RE: [gtkmm] last-minute API decision



std::map<>::insert( .. ) returns a std::pair< interator, bool > 

(http://www.dinkumware.com/manuals/reader.aspx?b=p/&h=map.html#map::insert)

and so should we.

-Mike Garriss

-----Original Message-----
From: Daniel Elstner [mailto:daniel elstner gmx net]
Sent: Tuesday, October 15, 2002 8:39 PM
To: gtkmm-list gnome org
Subject: [gtkmm] last-minute API decision


Hi,

currently the following Gtk::TextBuffer methods are broken API wise:

   iterator insert_interactive(...); // all 4 overloads
   iterator erase_interactive(...);

The parameter lists aren't interesting in this context, thus I omitted
them for clarity.

The problem is as follows:  These methods are currently defined to
return the end() iterator if the insertion/erasure fails (which can
happen due to the operation being interactive), otherwise iterators
pointing after the inserted/erased range are returned (just as the STL
does).  Unfortunately it is possible that the action was successful and
end() is returned, i.e. when inserting the empty string at the end or
erasing a range that reaches till end().

While the insert case could be quite easily worked around by the
programmer, it's not that easy (or clean) for erase_interactive().  GTK+
doesn't have the problem because it returns a bool (true on success) and
modifies the iterator input parameter.  So my proposal is to fix it like
this:

  std::pair<iterator,bool> insert_interactive(...);
  std::pair<iterator,bool> erase_interactive(...);

These methods probably aren't used often so the API change shouldn't be
a problem.  But if they're used they should work.  If you've a better
idea how to solve this please send in your comments now.

Cheers,
--Daniel


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]