[gnote] Replace most std::string by Glib::ustring in NoteBase



commit 39c143e19c0f0db98721f7b6d22361510d204411
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Tue Jan 31 23:15:42 2017 +0200

    Replace most std::string by Glib::ustring in NoteBase

 src/note.cpp                      |    2 +-
 src/notebase.cpp                  |   28 ++++++++++++++--------------
 src/notebase.hpp                  |   14 +++++++-------
 src/synchronization/syncutils.cpp |    6 +++---
 src/synchronization/syncutils.hpp |    4 ++--
 5 files changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index 75fc408..9cc02e2 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -136,7 +136,7 @@ namespace gnote {
 
   const int  NoteData::s_noPosition = -1;
 
-  NoteData::NoteData(const std::string & _uri)
+  NoteData::NoteData(const Glib::ustring & _uri)
     : m_uri(_uri)
     , m_cursor_pos(s_noPosition)
     , m_selection_bound_pos(s_noPosition)
diff --git a/src/notebase.cpp b/src/notebase.cpp
index 177fd5f..fef0f16 100644
--- a/src/notebase.cpp
+++ b/src/notebase.cpp
@@ -101,12 +101,12 @@ int NoteBase::get_hash_code() const
   return h(get_title());
 }
 
-const std::string & NoteBase::uri() const
+const Glib::ustring & NoteBase::uri() const
 {
   return data_synchronizer().data().uri();
 }
 
-const std::string NoteBase::id() const
+const Glib::ustring NoteBase::id() const
 {
   return sharp::string_replace_first(data_synchronizer().data().uri(), "note://gnote/","");
 }
@@ -245,7 +245,7 @@ void NoteBase::add_tag(const Tag::Ptr & tag)
 
 void NoteBase::remove_tag(Tag & tag)
 {
-  std::string tag_name = tag.normalized_name();
+  Glib::ustring tag_name = tag.normalized_name();
   NoteData::TagMap & thetags(data_synchronizer().data().tags());
   NoteData::TagMap::iterator iter;
 
@@ -313,7 +313,7 @@ void NoteBase::load_foreign_note_xml(const Glib::ustring & foreignNoteXml, Chang
   // Remove tags now, since a note with no tags has
   // no "tags" element in the XML
   std::list<Tag::Ptr> new_tags;
-  std::string name;
+  Glib::ustring name;
 
   while(xml.read()) {
     switch(xml.get_node_type()) {
@@ -454,7 +454,7 @@ void NoteArchiver::read(sharp::XmlReader & xml, NoteData & data)
 
 void NoteArchiver::_read(sharp::XmlReader & xml, NoteData & data, Glib::ustring & version)
 {
-  std::string name;
+  Glib::ustring name;
 
   while(xml.read ()) {
     switch(xml.get_node_type()) {
@@ -520,7 +520,7 @@ void NoteArchiver::_read(sharp::XmlReader & xml, NoteData & data, Glib::ustring
 
 Glib::ustring NoteArchiver::write_string(const NoteData & note)
 {
-  std::string str;
+  Glib::ustring str;
   sharp::XmlWriter xml;
   obj().write(xml, note);
   xml.close();
@@ -537,14 +537,14 @@ void NoteArchiver::write(const Glib::ustring & write_file, const NoteData & data
 void NoteArchiver::write_file(const Glib::ustring & _write_file, const NoteData & data)
 {
   try {
-    std::string tmp_file = _write_file + ".tmp";
+    Glib::ustring tmp_file = _write_file + ".tmp";
     // TODO Xml doc settings
     sharp::XmlWriter xml(tmp_file); //, XmlEncoder::DocumentSettings);
     write(xml, data);
     xml.close();
 
     if(sharp::file_exists(_write_file)) {
-      std::string backup_path = _write_file + "~";
+      Glib::ustring backup_path = _write_file + "~";
       if(sharp::file_exists(backup_path)) {
         sharp::file_delete(backup_path);
       }
@@ -635,15 +635,15 @@ Glib::ustring NoteArchiver::get_renamed_note_xml(const Glib::ustring & note_xml,
                                                  const Glib::ustring & old_title,
                                                  const Glib::ustring & new_title) const
 {
-  std::string updated_xml;
+  Glib::ustring updated_xml;
   // Replace occurences of oldTitle with newTitle in noteXml
-  std::string titleTagPattern = Glib::ustring::compose("<title>%1</title>", old_title);
-  std::string titleTagReplacement = Glib::ustring::compose("<title>%1</title>", new_title);
+  Glib::ustring titleTagPattern = Glib::ustring::compose("<title>%1</title>", old_title);
+  Glib::ustring titleTagReplacement = Glib::ustring::compose("<title>%1</title>", new_title);
   updated_xml = sharp::string_replace_regex(note_xml, titleTagPattern, titleTagReplacement);
 
-  std::string titleContentPattern = "<note-content([^>]*)>\\s*" + old_title;
-  std::string titleContentReplacement = "<note-content\\1>" + new_title;
-  std::string updated_xml2 = sharp::string_replace_regex(updated_xml, titleContentPattern, 
titleContentReplacement);
+  Glib::ustring titleContentPattern = "<note-content([^>]*)>\\s*" + old_title;
+  Glib::ustring titleContentReplacement = "<note-content\\1>" + new_title;
+  Glib::ustring updated_xml2 = sharp::string_replace_regex(updated_xml, titleContentPattern, 
titleContentReplacement);
 
   return updated_xml2;
 }
diff --git a/src/notebase.hpp b/src/notebase.hpp
index a5352bc..76de8d0 100644
--- a/src/notebase.hpp
+++ b/src/notebase.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2014 Aurimas Cernius
+ * Copyright (C) 2011-2014,2017 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -43,13 +43,13 @@ class NoteManagerBase;
 class NoteData
 {
 public:
-  typedef std::map<std::string, Tag::Ptr> TagMap;
+  typedef std::map<Glib::ustring, Tag::Ptr> TagMap;
 
   static const int s_noPosition;
 
-  NoteData(const std::string & _uri);
+  NoteData(const Glib::ustring & _uri);
 
-  const std::string & uri() const
+  const Glib::ustring & uri() const
     {
       return m_uri;
     }
@@ -139,7 +139,7 @@ public:
   bool has_extent();
 
 private:
-  const std::string m_uri;
+  const Glib::ustring m_uri;
   Glib::ustring     m_title;
   Glib::ustring     m_text;
   sharp::DateTime             m_create_date;
@@ -207,8 +207,8 @@ public:
     }
 
   int get_hash_code() const;
-  const std::string & uri() const;
-  const std::string id() const;
+  const Glib::ustring & uri() const;
+  const Glib::ustring id() const;
   const Glib::ustring & get_title() const;
   void set_title(const Glib::ustring & new_title);
   virtual void set_title(const Glib::ustring & new_title, bool from_user_action);
diff --git a/src/synchronization/syncutils.cpp b/src/synchronization/syncutils.cpp
index 661cca5..b00bd76 100644
--- a/src/synchronization/syncutils.cpp
+++ b/src/synchronization/syncutils.cpp
@@ -93,13 +93,13 @@ namespace sync {
   }
 
 
-  bool NoteUpdate::compare_tags(const std::map<std::string, Tag::Ptr> set1, const std::map<std::string, 
Tag::Ptr> set2) const
+  bool NoteUpdate::compare_tags(const std::map<Glib::ustring, Tag::Ptr> set1, const std::map<Glib::ustring, 
Tag::Ptr> set2) const
   {
     if(set1.size() != set2.size()) {
       return false;
     }
-    for(std::map<std::string, Tag::Ptr>::const_iterator iter = set1.begin(); iter != set1.end(); ++iter) {
-      if(set2.find(iter->first) == set2.end()) {
+    for(auto iter : set1) {
+      if(set2.find(iter.first) == set2.end()) {
         return false;
       }
     }
diff --git a/src/synchronization/syncutils.hpp b/src/synchronization/syncutils.hpp
index 3b1f6bb..cb88904 100644
--- a/src/synchronization/syncutils.hpp
+++ b/src/synchronization/syncutils.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2013 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -78,7 +78,7 @@ namespace sync {
     bool basically_equal_to(const Note::Ptr & existing_note);
   private:
     std::string get_inner_content(const std::string & full_content_element) const;
-    bool compare_tags(const std::map<std::string, Tag::Ptr> set1, const std::map<std::string, Tag::Ptr> 
set2) const;
+    bool compare_tags(const std::map<Glib::ustring, Tag::Ptr> set1, const std::map<Glib::ustring, Tag::Ptr> 
set2) const;
   };
 
 


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