[gnote] Replace std::string by Glib::ustring in NoteBuffer



commit 009e1e821355c0590086bff166fe600a0f9fa8e1
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Feb 4 15:36:54 2017 +0200

    Replace std::string by Glib::ustring in NoteBuffer

 src/notebuffer.cpp |   34 ++++++++++++++--------------------
 src/notebuffer.hpp |   22 +++++++++++-----------
 2 files changed, 25 insertions(+), 31 deletions(-)
---
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index b19cb30..98452cb 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2016 Aurimas Cernius
+ * Copyright (C) 2010-2017 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -21,6 +21,7 @@
 
 
 #include <algorithm>
+#include <array>
 
 #include <glibmm/i18n.h>
 #include <glibmm/main.h>
@@ -36,13 +37,6 @@
 #include "sharp/xmlreader.hpp"
 #include "sharp/xmlwriter.hpp"
 
-#if HAVE_CXX11
-  #include <array>
-  using std::array;
-#else
-  #include <tr1/array>
-  using std::tr1::array;
-#endif
 
 namespace gnote {
 
@@ -88,7 +82,7 @@ namespace gnote {
     delete m_undomanager;
   }
 
-  void NoteBuffer::toggle_active_tag(const std::string & tag_name)
+  void NoteBuffer::toggle_active_tag(const Glib::ustring & tag_name)
   {
     DBG_OUT("ToggleTag called for '%s'", tag_name.c_str());
     
@@ -119,7 +113,7 @@ namespace gnote {
     }
   }
 
-  void NoteBuffer::set_active_tag (const std::string & tag_name)
+  void NoteBuffer::set_active_tag (const Glib::ustring & tag_name)
   {
     DBG_OUT("SetTag called for '%s'", tag_name.c_str());
 
@@ -134,7 +128,7 @@ namespace gnote {
     }
   }
 
-  void NoteBuffer::remove_active_tag (const std::string & tag_name)
+  void NoteBuffer::remove_active_tag (const Glib::ustring & tag_name)
   {
     DBG_OUT("remove_tagcalled for '%s'", tag_name.c_str());
 
@@ -158,7 +152,7 @@ namespace gnote {
   /// Returns the specified DynamicNoteTag if one exists on the TextIter
   /// or null if none was found.
   /// </summary>
-  DynamicNoteTag::ConstPtr NoteBuffer::get_dynamic_tag (const std::string  & tag_name, 
+  DynamicNoteTag::ConstPtr NoteBuffer::get_dynamic_tag (const Glib::ustring  & tag_name,
                                                         const Gtk::TextIter & iter)
   {
     // TODO: Is this variables used, or do we just need to
@@ -216,7 +210,7 @@ namespace gnote {
   }
 
 
-  bool NoteBuffer::is_active_tag(const std::string & tag_name)
+  bool NoteBuffer::is_active_tag(const Glib::ustring & tag_name)
   {
     Glib::RefPtr<Gtk::TextTag> tag = get_tag_table()->lookup(tag_name);
     return is_active_tag(tag);
@@ -336,7 +330,7 @@ namespace gnote {
   void NoteBuffer::range_deleted_event(const Gtk::TextIter & start,const Gtk::TextIter & end_iter)
   {
     //
-    array<Gtk::TextIter, 2> iters;
+    std::array<Gtk::TextIter, 2> iters;
     iters[0] = start;
     iters[1] = end_iter;
 
@@ -866,10 +860,10 @@ namespace gnote {
     Gtk::TextBuffer::on_remove_tag(tag, start, end_iter);
   }
 
-  std::string NoteBuffer::get_selection() const
+  Glib::ustring NoteBuffer::get_selection() const
   {
     Gtk::TextIter select_start, select_end;
-    std::string text;
+    Glib::ustring text;
     
     if (get_selection_bounds(select_start, select_end)) {
       text = get_text(select_start, select_end, false);
@@ -1163,13 +1157,13 @@ namespace gnote {
     move_mark(get_insert(), end());
   }
 
-  std::string NoteBufferArchiver::serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer)
+  Glib::ustring NoteBufferArchiver::serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer)
   {
     return serialize(buffer, buffer->begin(), buffer->end());
   }
 
 
-  std::string NoteBufferArchiver::serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer, 
+  Glib::ustring NoteBufferArchiver::serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer,
                                             const Gtk::TextIter & start,
                                             const Gtk::TextIter & end)
   {
@@ -1177,7 +1171,7 @@ namespace gnote {
     
     serialize(buffer, start, end, xml);
     xml.close();
-    std::string serializedBuffer = xml.to_string();
+    Glib::ustring serializedBuffer = xml.to_string();
     // FIXME: there is some sort of attempt to ensure the endline are the
     // same on all platforms.
     return serializedBuffer;
@@ -1454,7 +1448,7 @@ namespace gnote {
 
   void NoteBufferArchiver::deserialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer, 
                                        const Gtk::TextIter & iter,
-                                       const std::string & content)
+                                       const Glib::ustring & content)
   {
     if(!content.empty()) {
       // it looks like an empty string does not really make the cut
diff --git a/src/notebuffer.hpp b/src/notebuffer.hpp
index dc69301..7f3dc59 100644
--- a/src/notebuffer.hpp
+++ b/src/notebuffer.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2016 Aurimas Cernius
+ * Copyright (C) 2011-2017 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -74,13 +74,13 @@ public:
   ChangeDepthHandler                               signal_change_text_depth;
   NewBulletHandler                                 signal_new_bullet_inserted;
 
-  void toggle_active_tag(const std::string &);
-  void set_active_tag(const std::string &);
-  void remove_active_tag(const std::string &);
-  DynamicNoteTag::ConstPtr get_dynamic_tag(const std::string  & tag_name, const Gtk::TextIter & iter);
+  void toggle_active_tag(const Glib::ustring &);
+  void set_active_tag(const Glib::ustring &);
+  void remove_active_tag(const Glib::ustring &);
+  DynamicNoteTag::ConstPtr get_dynamic_tag(const Glib::ustring & tag_name, const Gtk::TextIter & iter);
   void on_tag_applied(const Glib::RefPtr<Gtk::TextTag> &,
                       const Gtk::TextIter &,const Gtk::TextIter &);
-  bool is_active_tag(const std::string & );
+  bool is_active_tag(const Glib::ustring & );
   bool is_active_tag(const Glib::RefPtr<Gtk::TextTag> & tag);
   bool is_bulleted_list_active();
   bool is_bulleted_list_active(Gtk::TextIter iter);
@@ -97,7 +97,7 @@ public:
     { 
       return *m_undomanager; 
     }
-  std::string get_selection() const;
+  Glib::ustring get_selection() const;
   static void get_block_extents(Gtk::TextIter &, Gtk::TextIter &,
                            int threshold, const Glib::RefPtr<Gtk::TextTag> & avoid_tag);
   void toggle_selection_bullets();
@@ -163,18 +163,18 @@ private:
 class NoteBufferArchiver
 {
 public:
-  static std::string serialize(const Glib::RefPtr<Gtk::TextBuffer> & );
-  static std::string serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer, const Gtk::TextIter &,
+  static Glib::ustring serialize(const Glib::RefPtr<Gtk::TextBuffer> & );
+  static Glib::ustring serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer, const Gtk::TextIter &,
                                const Gtk::TextIter &);
   static void serialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer, const Gtk::TextIter &,
                         const Gtk::TextIter &, sharp::XmlWriter & xml);
   static void deserialize(const Glib::RefPtr<Gtk::TextBuffer> &buffer,
-                          const std::string & content)
+                          const Glib::ustring & content)
     {
       deserialize(buffer, buffer->begin(), content);
     }
   static void deserialize(const Glib::RefPtr<Gtk::TextBuffer> &, const Gtk::TextIter & ,
-                          const std::string & );
+                          const Glib::ustring & );
   static void deserialize(const Glib::RefPtr<Gtk::TextBuffer> & buffer, 
                           const Gtk::TextIter & iter, sharp::XmlReader & xml);
 private:


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