From cfcf4539ab72250d8932a3b17585fe142cf07690 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Thu, 7 Nov 2024 11:44:14 +0500 Subject: [PATCH] UI: RuleTextParser: Simplify parseValue() --- src/ui/util/conf/ruletextparser.cpp | 30 ++++++++++++++++------------- src/ui/util/conf/ruletextparser.h | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/ui/util/conf/ruletextparser.cpp b/src/ui/util/conf/ruletextparser.cpp index 99f9ba51..dbafec78 100644 --- a/src/ui/util/conf/ruletextparser.cpp +++ b/src/ui/util/conf/ruletextparser.cpp @@ -365,19 +365,8 @@ bool RuleTextParser::parseValue(bool expectValueEnd) { const QChar *value = parsedCharPtr(); - for (;;) { - const char *extraChars = expectValueEnd ? extraValueEndChars : extraValueChars; - - if (!parseChars(CharLetter | CharValue, extraChars)) - return false; - - if (!checkValueEnd(expectValueEnd)) { - if (hasError()) - return false; - - break; - } - } + if (!parseValueChars(expectValueEnd)) + return false; const QStringView valueView(value, currentCharPtr() - value); @@ -386,6 +375,21 @@ bool RuleTextParser::parseValue(bool expectValueEnd) return true; } +bool RuleTextParser::parseValueChars(bool &expectValueEnd) +{ + for (;;) { + const char *extraChars = expectValueEnd ? extraValueEndChars : extraValueChars; + + if (!parseChars(CharLetter | CharValue, extraChars)) + return false; + + if (!checkValueEnd(expectValueEnd)) + break; + } + + return !hasError(); +} + bool RuleTextParser::checkValueEnd(bool &expectValueEnd) { const bool isValueBegin = (m_charType == CharValueBegin); diff --git a/src/ui/util/conf/ruletextparser.h b/src/ui/util/conf/ruletextparser.h index 6307006d..7b23682b 100644 --- a/src/ui/util/conf/ruletextparser.h +++ b/src/ui/util/conf/ruletextparser.h @@ -112,6 +112,7 @@ private: bool checkBracketValuesSeparator(RuleCharTypes expectedSeparator); bool checkBracketValueEnd(); bool parseValue(bool expectValueEnd); + bool parseValueChars(bool &expectValueEnd); bool checkValueEnd(bool &expectValueEnd); bool checkAddFilter();