From e08efd9ad57fbe44c68cb98c5cb9b3ac46b96439 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 5 Nov 2015 14:45:08 +0100 Subject: Add config options IRC.User and IRC.Port --- src/Util.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/Util.cpp') diff --git a/src/Util.cpp b/src/Util.cpp index 3658802..41500da 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -151,4 +151,41 @@ namespace Util { } return string; } + + int indexOfEscaped(const QString& string, const QChar subject, int startPos, const QChar escapeChar) + { + if(string.isEmpty()) + { + return -1; + } + if(startPos < 0) + { + startPos += string.length(); + } + bool escaped = false; + for(int pos = startPos; pos < string.length(); ++pos) + { + QChar c = string.at(pos); + if(!escaped) + { + if(c == escapeChar) + { + escaped = true; + continue; + } + else + { + if(c == subject) + { + return pos; + } + } + } + else + { + escaped = false; + } + } + return -1; + } } -- cgit v1.2.3-54-g00ecf