[gtksourceviewmm] Buffer: Use const_iterator where appropriate.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceviewmm] Buffer: Use const_iterator where appropriate.
- Date: Fri, 31 Mar 2017 12:18:59 +0000 (UTC)
commit f1688e66c44217fd38fdcdc1568cbb6d5d084696
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Mar 31 13:58:56 2017 +0200
Buffer: Use const_iterator where appropriate.
gtksourceview/src/buffer.ccg | 9 +++++----
gtksourceview/src/buffer.hg | 21 +++++++++++----------
2 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/gtksourceview/src/buffer.ccg b/gtksourceview/src/buffer.ccg
index bc1e5c9..91dee97 100644
--- a/gtksourceview/src/buffer.ccg
+++ b/gtksourceview/src/buffer.ccg
@@ -25,6 +25,7 @@
#include <glibmm/vectorutils.h>
using iterator = Gsv::Buffer::iterator;
+using const_iterator = Gsv::Buffer::const_iterator;
namespace Gsv
{
@@ -53,7 +54,7 @@ bool Buffer::forward_iter_to_source_mark(iterator& iter)
}
Glib::RefPtr<Gsv::Mark>
-Buffer::create_source_mark(const Glib::ustring& category, const iterator& where)
+Buffer::create_source_mark(const Glib::ustring& category, const const_iterator& where)
{
return Glib::wrap(gtk_source_buffer_create_source_mark(gobj(), 0, category.c_str(), where.gobj()));
}
@@ -63,13 +64,13 @@ std::vector<Glib::RefPtr<Gsv::Mark> > Buffer::get_source_marks_at_line(int line)
return Glib::SListHandler<Glib::RefPtr<Gsv::Mark>
::slist_to_vector(gtk_source_buffer_get_source_marks_at_line(const_cast<GtkSourceBuffer*>(gobj()), line, 0),
Glib::OWNERSHIP_SHALLOW);
}
-std::vector<Glib::RefPtr<Gsv::Mark> > Buffer::get_source_marks_at_iter(iterator& iter) const
+std::vector<Glib::RefPtr<Gsv::Mark> > Buffer::get_source_marks_at_iter(const const_iterator& iter) const
{
- return Glib::SListHandler<Glib::RefPtr<Gsv::Mark>
::slist_to_vector(gtk_source_buffer_get_source_marks_at_iter(const_cast<GtkSourceBuffer*>(gobj()),
iter.gobj(), 0), Glib::OWNERSHIP_SHALLOW);
+ return Glib::SListHandler<Glib::RefPtr<Gsv::Mark>
::slist_to_vector(gtk_source_buffer_get_source_marks_at_iter(const_cast<GtkSourceBuffer*>(gobj()),
const_cast<GtkTextIter*>(iter.gobj()), 0), Glib::OWNERSHIP_SHALLOW);
}
void
-Buffer::remove_source_marks(const iterator& start, const iterator& end)
+Buffer::remove_source_marks(const const_iterator& start, const const_iterator& end)
{
gtk_source_buffer_remove_source_marks(gobj(), start.gobj(), end.gobj(), 0);
}
diff --git a/gtksourceview/src/buffer.hg b/gtksourceview/src/buffer.hg
index c94c82f..1f37fba 100644
--- a/gtksourceview/src/buffer.hg
+++ b/gtksourceview/src/buffer.hg
@@ -77,6 +77,7 @@ protected:
public:
using iterator = TextBuffer::iterator;
+ using const_iterator = TextBuffer::const_iterator;
/** Create a new source buffer.
*
@@ -228,7 +229,7 @@ public:
*/
bool forward_iter_to_source_mark(iterator& iter);
-#m4 _CONVERSION(`const iterator&',`const GtkTextIter*',`($3).gobj()')
+#m4 _CONVERSION(`const const_iterator&',`GtkTextIter*',`const_cast<GtkTextIter*>(($3).gobj())')
/** Forces buffer to analyze and highlight the given area synchronously.
*
* @note This is a potentially slow operation and should be used only when you
@@ -238,7 +239,7 @@ public:
* @param start Start of the area to highlight.
* @param end End of the area to highlight.
*/
- _WRAP_METHOD(void ensure_highlight(const iterator& start, const iterator& end),
gtk_source_buffer_ensure_highlight)
+ _WRAP_METHOD(void ensure_highlight(const const_iterator& start, const const_iterator& end),
gtk_source_buffer_ensure_highlight)
/** Returns the StyleScheme currently used in buffer.
*
@@ -286,7 +287,7 @@ public:
*
* @return A new Mark.
*/
- _WRAP_METHOD(Glib::RefPtr<Gsv::Mark> create_source_mark(const Glib::ustring& name, const Glib::ustring&
category, const iterator& where), gtk_source_buffer_create_source_mark, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<Gsv::Mark> create_source_mark(const Glib::ustring& name, const Glib::ustring&
category, const const_iterator& where), gtk_source_buffer_create_source_mark, refreturn)
/** Creates an anonymous source mark in the buffer of category category.
*
@@ -309,7 +310,7 @@ public:
*
* @newin{2,10}
*/
- Glib::RefPtr<Gsv::Mark> create_source_mark(const Glib::ustring& category, const iterator& where);
+ Glib::RefPtr<Gsv::Mark> create_source_mark(const Glib::ustring& category, const const_iterator& where);
#m4 _CONVERSION(`GSList*',`std::vector<Glib::RefPtr<Gsv::Mark> >',
`Glib::SListHandler<Glib::RefPtr<Gsv::Mark> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
#m4 _CONVERSION(`GSList*',`std::vector<Glib::RefPtr<const Gsv::Mark> >',
`Glib::SListHandler<Glib::RefPtr<const Gsv::Mark> >slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
@@ -339,7 +340,7 @@ public:
*
* @return A list of source marks.
*/
- _WRAP_METHOD(std::vector<Glib::RefPtr<Gsv::Mark> > get_source_marks_at_iter(iterator& iter, const
Glib::ustring& category) const, gtk_source_buffer_get_source_marks_at_iter)
+ _WRAP_METHOD(std::vector<Glib::RefPtr<Gsv::Mark> > get_source_marks_at_iter(const const_iterator& iter,
const Glib::ustring& category) const, gtk_source_buffer_get_source_marks_at_iter)
/** Returns the list of marks of any category at @a iter.
*
@@ -347,7 +348,7 @@ public:
*
* @return A list of source marks.
*/
- std::vector<Glib::RefPtr<Gsv::Mark> > get_source_marks_at_iter(iterator& iter) const;
+ std::vector<Glib::RefPtr<Gsv::Mark> > get_source_marks_at_iter(const const_iterator& iter) const;
/** Remove all marks of @a category between start and end from the buffer.
*
@@ -355,7 +356,7 @@ public:
* @param end A iterator.
* @param category Category to search for.
*/
- _WRAP_METHOD(void remove_source_marks(const iterator& start, const iterator& end, const Glib::ustring&
category), gtk_source_buffer_remove_source_marks)
+ _WRAP_METHOD(void remove_source_marks(const const_iterator& start, const const_iterator& end, const
Glib::ustring& category), gtk_source_buffer_remove_source_marks)
/** Remove all marks of any category between start and end from the buffer.
*
@@ -364,7 +365,7 @@ public:
*
* @newin{2,10}
*/
- void remove_source_marks(const iterator& start, const iterator& end);
+ void remove_source_marks(const const_iterator& start, const const_iterator& end);
/** Check if the class @a context_class is set on @c iter.
*
@@ -375,7 +376,7 @@ public:
*
* @newin{2,10}
*/
- _WRAP_METHOD(bool iter_has_context_class(const iterator& iter, const Glib::ustring& context_class) const,
gtk_source_buffer_iter_has_context_class)
+ _WRAP_METHOD(bool iter_has_context_class(const const_iterator& iter, const Glib::ustring& context_class)
const, gtk_source_buffer_iter_has_context_class)
/** Moves backward to the next toggle (on or off) of the context class.
*
@@ -419,7 +420,7 @@ public:
*
* @newin{2,10}
*/
- _WRAP_METHOD(std::vector<Glib::ustring> get_context_classes_at_iter(const iterator& iter) const,
gtk_source_buffer_get_context_classes_at_iter)
+ _WRAP_METHOD(std::vector<Glib::ustring> get_context_classes_at_iter(const const_iterator& iter) const,
gtk_source_buffer_get_context_classes_at_iter)
/** Get the undo manager associated with the buffer.
* @return A UndoManager.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]