mirror of
https://github.com/tnodir/fort
synced 2024-11-14 16:23:03 +00:00
UI: RuleTextParser: Refactor filter lists count
This commit is contained in:
parent
bf99e98c9d
commit
3dd6fbc7a5
@ -94,7 +94,7 @@ void RuleTextParser::setError(ErrorCode errorCode, const QString &errorMessage)
|
||||
|
||||
bool RuleTextParser::parseLines()
|
||||
{
|
||||
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_OR);
|
||||
const int filterIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_OR);
|
||||
|
||||
for (;;) {
|
||||
if (!parseLineComments())
|
||||
@ -104,7 +104,7 @@ bool RuleTextParser::parseLines()
|
||||
break;
|
||||
}
|
||||
|
||||
endList(nodeIndex);
|
||||
endList(filterIndex);
|
||||
|
||||
return !hasError();
|
||||
}
|
||||
@ -124,7 +124,7 @@ bool RuleTextParser::parseLineComments()
|
||||
|
||||
bool RuleTextParser::parseLine()
|
||||
{
|
||||
const int nodeIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_AND);
|
||||
const int filterIndex = beginList(FORT_RULE_FILTER_TYPE_LIST_AND);
|
||||
|
||||
RuleCharTypes expectedSeparator = CharNone;
|
||||
|
||||
@ -153,7 +153,7 @@ bool RuleTextParser::parseLine()
|
||||
expectedSeparator = CharColon | CharNewLine;
|
||||
}
|
||||
|
||||
endList(nodeIndex);
|
||||
endList(filterIndex);
|
||||
|
||||
return !hasError();
|
||||
}
|
||||
@ -423,18 +423,18 @@ int RuleTextParser::beginList(qint8 listType)
|
||||
return nodeIndex;
|
||||
}
|
||||
|
||||
void RuleTextParser::endList(int nodeIndex)
|
||||
void RuleTextParser::endList(int filterIndex)
|
||||
{
|
||||
const int currentIndex = m_ruleFilters.size();
|
||||
const int currentIndex = m_ruleFilters.size() - 1;
|
||||
|
||||
if (currentIndex == nodeIndex + 1) {
|
||||
if (currentIndex == filterIndex) {
|
||||
m_ruleFilters.removeLast(); // Empty list
|
||||
return;
|
||||
}
|
||||
|
||||
RuleFilter &ruleFilter = m_ruleFilters[nodeIndex];
|
||||
RuleFilter &ruleFilter = m_ruleFilters[filterIndex];
|
||||
|
||||
ruleFilter.listCount = currentIndex - nodeIndex;
|
||||
ruleFilter.filterListCount = currentIndex - filterIndex;
|
||||
}
|
||||
|
||||
bool RuleTextParser::skipComments(RuleCharTypes expectedCharTypes)
|
||||
|
@ -49,7 +49,7 @@ struct RuleFilter
|
||||
|
||||
qint8 type = 0;
|
||||
|
||||
quint16 listCount = 0;
|
||||
quint16 filterListCount = 0;
|
||||
|
||||
StringViewList values;
|
||||
};
|
||||
@ -117,7 +117,7 @@ private:
|
||||
|
||||
void addFilter();
|
||||
int beginList(qint8 listType);
|
||||
void endList(int nodeIndex);
|
||||
void endList(int filterIndex);
|
||||
|
||||
void resetParsedCharTypes() { m_parsedCharTypes = CharNone; }
|
||||
bool hasParsedCharTypes(RuleCharTypes v) { return v == 0 || (m_parsedCharTypes & v) != 0; }
|
||||
@ -130,7 +130,7 @@ private:
|
||||
|
||||
bool isEmpty() const { return m_p >= m_end; }
|
||||
|
||||
RuleFilter &listNode(int listIndex) { return m_ruleFilters[listIndex]; }
|
||||
RuleFilter &listNode(int filterIndex) { return m_ruleFilters[filterIndex]; }
|
||||
|
||||
bool skipComments(RuleCharTypes expectedCharTypes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user