loolwsd/LOOLProtocol.cpp | 43 ------------------------------------------- loolwsd/LOOLProtocol.hpp | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 46 deletions(-)
New commits: commit 3f42ba342c30707cfeba6eae34554cf341f6547a Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Oct 8 12:40:21 2016 -0400 loolwsd: inline some common LOOLProtocol functions and more args Change-Id: If75fa5c7c606377b9a79aa6e8d927840b9da39fa Reviewed-on: https://gerrit.libreoffice.org/29632 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/LOOLProtocol.cpp b/loolwsd/LOOLProtocol.cpp index 7e08864..ba62132 100644 --- a/loolwsd/LOOLProtocol.cpp +++ b/loolwsd/LOOLProtocol.cpp @@ -58,31 +58,6 @@ namespace LOOLProtocol return true; } - bool parseNameIntegerPair(const std::string& token, std::string& name, int& value) - { - const auto mid = token.find_first_of('='); - if (mid != std::string::npos) - { - name = token.substr(0, mid); - return stringToInteger(token.substr(mid + 1), value); - } - - return false; - } - - 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; @@ -224,24 +199,6 @@ namespace LOOLProtocol return true; } - - std::string getAbbreviatedMessage(const char *message, const int length) - { - if (message == nullptr || length <= 0) - { - return ""; - } - - const auto firstLine = getFirstLine(message, length); - - // If first line is less than the length (minus newline), add ellipsis. - if (firstLine.size() < static_cast<std::string::size_type>(length) - 1) - { - return firstLine + "..."; - } - - return firstLine; - } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/loolwsd/LOOLProtocol.hpp b/loolwsd/LOOLProtocol.hpp index d4fb8a6..e5e79b9 100644 --- a/loolwsd/LOOLProtocol.hpp +++ b/loolwsd/LOOLProtocol.hpp @@ -38,8 +38,26 @@ namespace LOOLProtocol std::tuple<int, int, std::string> ParseVersion(const std::string& version); bool stringToInteger(const std::string& input, int& value); - bool parseNameIntegerPair(const std::string& token, std::string& name, int& value); - bool parseNameValuePair(const std::string& token, std::string& name, std::string& value); + inline + bool parseNameValuePair(const std::string& token, std::string& name, std::string& value, const char delim = '=') + { + const auto mid = token.find_first_of(delim); + if (mid != std::string::npos) + { + name = token.substr(0, mid); + value = token.substr(mid + 1); + return true; + } + + return false; + } + + inline + bool parseNameIntegerPair(const std::string& token, std::string& name, int& value, const char delim = '=') + { + std::string strValue; + return parseNameValuePair(token, name, strValue, delim) && stringToInteger(strValue, 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); @@ -115,7 +133,24 @@ namespace LOOLProtocol } /// Returns an abbereviation of the message (the first line, indicating truncation). - std::string getAbbreviatedMessage(const char *message, const int length); + inline + std::string getAbbreviatedMessage(const char *message, const int length) + { + if (message == nullptr || length <= 0) + { + return ""; + } + + const auto firstLine = getFirstLine(message, length); + + // If first line is less than the length (minus newline), add ellipsis. + if (firstLine.size() < static_cast<std::string::size_type>(length) - 1) + { + return firstLine + "..."; + } + + return firstLine; + } inline std::string getAbbreviatedMessage(const std::string& message) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits