[gnote] Remove string_index_of from uri



commit f1c7ff63c1fbf23a2bfcccc5afbe70a0b1991964
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Jan 22 20:59:04 2017 +0200

    Remove string_index_of from uri

 src/sharp/uri.cpp |   13 +++++++------
 src/sharp/uri.hpp |    7 ++++---
 2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/sharp/uri.cpp b/src/sharp/uri.cpp
index 9e151cc..11ba0ea 100644
--- a/src/sharp/uri.cpp
+++ b/src/sharp/uri.cpp
@@ -1,6 +1,7 @@
 /*
  * gnote
  *
+ * Copyright (C) 2017 Aurimas Cernius
  * Copyright (C) 2010 Debarshi Ray
  * Copyright (C) 2009 Hubert Figuiere
  * 
@@ -65,12 +66,12 @@ namespace sharp {
     if(!is_file()) {
       if(_is_scheme(HTTP_URI_SCHEME) || _is_scheme(HTTPS_URI_SCHEME)
          || _is_scheme(FTP_URI_SCHEME)) {
-        int idx = string_index_of(m_uri, "://");
-        if(idx != -1) {
-          std::string sub(m_uri.begin() + idx + 3, m_uri.end());
-          idx = string_index_of(sub, "/");
-          if(idx != -1) {
-            sub.erase(sub.begin() + idx, sub.end());
+        auto idx = m_uri.find("://");
+        if(idx != Glib::ustring::npos) {
+          Glib::ustring sub(m_uri.substr(idx + 3));
+          idx = sub.find("/");
+          if(idx != Glib::ustring::npos) {
+            sub.erase(idx);
             host = sub;
           }
         }
diff --git a/src/sharp/uri.hpp b/src/sharp/uri.hpp
index 8548ca7..df19ac2 100644
--- a/src/sharp/uri.hpp
+++ b/src/sharp/uri.hpp
@@ -1,6 +1,7 @@
 /*
  * gnote
  *
+ * Copyright (C) 2017 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,7 +30,7 @@
 #define __SHARP_URI_HPP_
 
 
-#include <string>
+#include <glibmm/ustring.h>
 
 namespace sharp {
 
@@ -40,7 +41,7 @@ namespace sharp {
       : m_uri(u)
       {
       }
-    const std::string & to_string() const
+    const Glib::ustring & to_string() const
       { 
         return m_uri; 
       }
@@ -52,7 +53,7 @@ namespace sharp {
   private:
     bool _is_scheme(const std::string & scheme) const;
 
-    std::string m_uri;
+    Glib::ustring m_uri;
   };
 
 }


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