[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - common/Util.hpp

Tor Lillqvist tml at collabora.com
Wed Apr 4 17:05:26 UTC 2018


 common/Util.hpp |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit c637d60a9276abb8df5405f11f73b1f37eca437f
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Jan 15 13:37:40 2018 +0200

    Add Util::startsWith() to check whether a std::string starts with another
    
    Odd that we have managed without such a helper for so long, or did I
    just not find it?
    
    (cherry picked from commit 7bf59d8f648680747c3a2c26b7836d1b92f9e63a)
    
    Change-Id: I64cb79b755295763fb4ffb8cbcd34d8b6f44cb76

diff --git a/common/Util.hpp b/common/Util.hpp
index b57947882..f90081730 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -12,6 +12,7 @@
 
 #include <atomic>
 #include <cassert>
+#include <cstring>
 #include <functional>
 #include <memory>
 #include <mutex>
@@ -223,6 +224,11 @@ namespace Util
         return trimmed(std::string(s));
     }
 
+    inline bool startsWith(const std::string& s, const std::string& t)
+    {
+        return s.length() >= t.length() && memcmp(s.c_str(), t.c_str(), t.length()) == 0;
+    }
+
     /// Check for the URI scheme validity.
     /// For now just a basic sanity check, can be extended if necessary.
     bool isValidURIScheme(const std::string& scheme);


More information about the Libreoffice-commits mailing list