UI: RuleTextParser: Simplify parseLine()

This commit is contained in:
Nodir Temirkhodjaev 2024-11-07 11:35:25 +05:00
parent 973581ada4
commit daa710ff4a
2 changed files with 23 additions and 14 deletions

View File

@ -134,22 +134,9 @@ bool RuleTextParser::parseLine()
if (!parseLineSection(expectedSeparator))
break;
if (m_ruleFilter.isLineEnd || m_ruleFilter.isListEnd)
if (!processSectionFilter())
break;
const bool isSectionEnd = m_ruleFilter.isSectionEnd;
if (!checkAddFilter())
return false;
resetFilter();
// Next default type, if applicable
if (!isSectionEnd && !m_ruleFilter.hasFilterName) {
m_ruleFilter.type = m_ruleFilter.isTypeAddress() ? FORT_RULE_FILTER_TYPE_PORT
: FORT_RULE_FILTER_TYPE_INVALID;
}
expectedSeparator = CharColon | CharNewLine;
}
@ -158,6 +145,27 @@ bool RuleTextParser::parseLine()
return !hasError();
}
bool RuleTextParser::processSectionFilter()
{
if (m_ruleFilter.isLineEnd || m_ruleFilter.isListEnd)
return false;
if (!checkAddFilter())
return false;
const bool isSectionEnd = m_ruleFilter.isSectionEnd;
resetFilter();
// Next default type, if applicable
if (!isSectionEnd && !m_ruleFilter.hasFilterName) {
m_ruleFilter.type = m_ruleFilter.isTypeAddress() ? FORT_RULE_FILTER_TYPE_PORT
: FORT_RULE_FILTER_TYPE_INVALID;
}
return true;
}
bool RuleTextParser::parseLineSection(RuleCharTypes expectedSeparator)
{
for (;;) {

View File

@ -96,6 +96,7 @@ private:
bool parseLines();
bool parseLineComments();
bool parseLine();
bool processSectionFilter();
bool parseLineSection(RuleCharTypes expectedSeparator);
bool parseSection();
bool parseSectionBlock();