[gnote] Remove last uses of boost



commit a5b6319a84c45ea8000f9dc4e4229caaec4aa246
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Jan 28 18:46:06 2017 +0200

    Remove last uses of boost

 src/search.cpp |   34 ++++++++++++----------------------
 src/search.hpp |   15 ++++++---------
 src/utils.cpp  |   12 +++++-------
 src/utils.hpp  |    6 +++---
 4 files changed, 26 insertions(+), 41 deletions(-)
---
diff --git a/src/search.cpp b/src/search.cpp
index 0493d7e..4bb0e12 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -44,12 +44,12 @@ namespace gnote {
       search_text = search_text.lowercase();
     }
 
-    std::vector<std::string> words;
-    Search::split_watching_quotes(words, std::string(search_text));
+    std::vector<Glib::ustring> words;
+    Search::split_watching_quotes(words, search_text);
 
     // Used for matching in the raw note XML
-    std::vector<std::string> encoded_words; 
-    Search::split_watching_quotes(encoded_words, utils::XmlEncoder::encode (search_text));
+    std::vector<Glib::ustring> encoded_words;
+    Search::split_watching_quotes(encoded_words, utils::XmlEncoder::encode(search_text));
     ResultsPtr temp_matches(new Results);
       
       // Skip over notes that are template notes
@@ -72,16 +72,11 @@ namespace gnote {
       // if there is no match check the note's raw
       // XML for at least one match, to avoid
       // deserializing Buffers unnecessarily.
-      if (0 < find_match_count_in_note (note->get_title(),
-                                        words,
-                                        case_sensitive)) {
+      if (0 < find_match_count_in_note(note->get_title(), words, case_sensitive)) {
         temp_matches->insert(std::make_pair(INT_MAX, note));
       }
-      else if (check_note_has_match (note, encoded_words,
-                                case_sensitive)) {
-        int match_count =
-          find_match_count_in_note (note->text_content(),
-                                    words, case_sensitive);
+      else if (check_note_has_match(note, encoded_words, case_sensitive)) {
+        int match_count = find_match_count_in_note(note->text_content(), words, case_sensitive);
         if (match_count > 0) {
           // TODO: Improve note.GetHashCode()
           temp_matches->insert(std::make_pair(match_count, note));
@@ -92,7 +87,7 @@ namespace gnote {
   }
 
   bool Search::check_note_has_match(const Note::Ptr & note, 
-                                    const std::vector<std::string> & encoded_words,
+                                    const std::vector<Glib::ustring> & encoded_words,
                                     bool match_case)
   {
     Glib::ustring note_text = note->xml_content();
@@ -100,9 +95,8 @@ namespace gnote {
       note_text = note_text.lowercase();
     }
 
-    for(std::vector<std::string>::const_iterator iter = encoded_words.begin();
-        iter != encoded_words.end(); ++iter) {
-      if(note_text.find(*iter) != std::string::npos) {
+    for(auto iter : encoded_words) {
+      if(note_text.find(iter) != std::string::npos) {
         continue;
       }
       else {
@@ -114,7 +108,7 @@ namespace gnote {
   }
 
   int Search::find_match_count_in_note(Glib::ustring note_text,
-                                       const std::vector<std::string> & words,
+                                       const std::vector<Glib::ustring> & words,
                                        bool match_case)
   {
     int matches = 0;
@@ -123,11 +117,7 @@ namespace gnote {
       note_text = note_text.lowercase();
     }
 
-    for(std::vector<std::string>::const_iterator iter = words.begin();
-        iter != words.end(); ++iter) {
-
-      const Glib::ustring word(*iter);
-
+    for(auto word : words) {
       Glib::ustring::size_type idx = 0;
       bool this_word_found = false;
 
diff --git a/src/search.hpp b/src/search.hpp
index 518588f..d4e1822 100644
--- a/src/search.hpp
+++ b/src/search.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011,2013-2014 Aurimas Cernius
+ * Copyright (C) 2011,2013-2014,2017 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -25,15 +25,12 @@
 
 #include <map>
 #include <memory>
-#include <string>
 #include <vector>
 
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
-
 #include "base/macros.hpp"
 #include "note.hpp"
 #include "notebooks/notebook.hpp"
+#include "sharp/string.hpp"
 
 namespace gnote {
 
@@ -74,9 +71,9 @@ public:
   /// </returns>  
   ResultsPtr search_notes(const std::string &, bool, 
                           const notebooks::Notebook::Ptr & );
-  bool check_note_has_match(const Note::Ptr & note, const std::vector<std::string> & ,
+  bool check_note_has_match(const Note::Ptr & note, const std::vector<Glib::ustring> & ,
                             bool match_case);
-  int find_match_count_in_note(Glib::ustring note_text, const std::vector<std::string> &,
+  int find_match_count_in_note(Glib::ustring note_text, const std::vector<Glib::ustring> &,
                                bool match_case);
 private:
 
@@ -87,7 +84,7 @@ template<typename T>
 void Search::split_watching_quotes(std::vector<T> & split,
                                    const T & source)
 {
-  boost::split(split, source, boost::is_any_of("\""));
+  sharp::string_split(split, source, "\"");
 
   std::vector<T> tmp;
 
@@ -96,7 +93,7 @@ void Search::split_watching_quotes(std::vector<T> & split,
        i++) {
     const T & part = *i;
     std::vector<T> parts;
-    boost::split(parts, part, boost::is_any_of(" \t\n"));
+    sharp::string_split(parts, part, " \t\n");
 
     for (typename std::vector<T>::const_iterator j = parts.begin();
          parts.end() != j;
diff --git a/src/utils.cpp b/src/utils.cpp
index 35a1ae2..abab5c0 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -615,7 +615,7 @@ namespace gnote {
     }
 
 
-    std::string XmlEncoder::encode(const std::string & source)
+    Glib::ustring XmlEncoder::encode(const Glib::ustring & source)
     {
       sharp::XmlWriter xml;
       //need element so that source is properly escaped
@@ -624,8 +624,8 @@ namespace gnote {
       xml.write_end_element();
 
       xml.close();
-      std::string result = xml.to_string();
-      std::string::size_type end_pos = result.find("</x>");
+      Glib::ustring result = xml.to_string();
+      Glib::ustring::size_type end_pos = result.find("</x>");
       if(end_pos == result.npos) {
         return "";
       }
@@ -634,11 +634,9 @@ namespace gnote {
     }
 
 
-    std::string XmlDecoder::decode(const std::string & source)
+    Glib::ustring XmlDecoder::decode(const Glib::ustring & source)
     {
-      // TODO there is probably better than a std::string for that.
-      // this will do for now.
-      std::string builder;
+      Glib::ustring builder;
 
       sharp::XmlReader xml;
       xml.load_buffer(source);
diff --git a/src/utils.hpp b/src/utils.hpp
index d479144..78b45c9 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2013,2015-2016 Aurimas Cernius
+ * Copyright (C) 2011-2013,2015-2017 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -154,13 +154,13 @@ namespace gnote {
     class XmlEncoder
     {
     public:
-      static std::string encode(const std::string & source);
+      static Glib::ustring encode(const Glib::ustring & source);
     };
 
     class XmlDecoder
     {
     public:
-      static std::string decode(const std::string & source);
+      static Glib::ustring decode(const Glib::ustring & source);
 
     };
 


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