[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-0' - loolwsd/LOOLProtocol.cpp loolwsd/LOOLProtocol.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Fri Jul 1 13:51:00 UTC 2016


 loolwsd/LOOLProtocol.cpp |   13 +++++++++++++
 loolwsd/LOOLProtocol.hpp |    1 +
 2 files changed, 14 insertions(+)

New commits:
commit 4f2323ae3a2482d2f8f12eb619ae0548b83f6950
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 22 11:26:30 2016 -0400

    loolwsd: new name=value pair parser for strings
    
    Change-Id: I01c56f9c452fe0ac75b3d9f2aa67787c5bb4d8c6
    Reviewed-on: https://gerrit.libreoffice.org/25336
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLProtocol.cpp b/loolwsd/LOOLProtocol.cpp
index 2d5893b..1ab6d5e 100644
--- a/loolwsd/LOOLProtocol.cpp
+++ b/loolwsd/LOOLProtocol.cpp
@@ -57,6 +57,19 @@ namespace LOOLProtocol
         return true;
     }
 
+    bool parseNameValuePair(const std::string& token, std::string& name, std::string& value)
+    {
+        const auto mid = token.find_first_of('=');
+        if (mid != std::string::npos)
+        {
+            name = token.substr(0, mid);
+            value = token.substr(mid + 1);
+            return true;
+        }
+
+        return false;
+    }
+
     bool getTokenInteger(const std::string& token, const std::string& name, int& value)
     {
         size_t nextIdx;
diff --git a/loolwsd/LOOLProtocol.hpp b/loolwsd/LOOLProtocol.hpp
index 21d488b..f4b606c 100644
--- a/loolwsd/LOOLProtocol.hpp
+++ b/loolwsd/LOOLProtocol.hpp
@@ -37,6 +37,7 @@ namespace LOOLProtocol
     std::tuple<int, int, std::string> ParseVersion(const std::string& version);
 
     bool stringToInteger(const std::string& input, int& value);
+    bool parseNameValuePair(const std::string& token, std::string& name, std::string& value);
 
     bool getTokenInteger(const std::string& token, const std::string& name, int& value);
     bool getTokenString(const std::string& token, const std::string& name, std::string& value);


More information about the Libreoffice-commits mailing list