SongFilter: implement the AND operator
This commit is contained in:
parent
7a8d5070f5
commit
7aa8497546
|
@ -268,6 +268,13 @@
|
||||||
time stamp).
|
time stamp).
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
"<code>EXPRESSION1 AND EXPRESSION2 ...</code>": combine two or
|
||||||
|
more expressions with logical "and".
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
|
|
@ -334,7 +334,23 @@ SongFilter::ParseExpression(const char *&s, bool fold_case)
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw std::runtime_error("Nested expressions not yet implemented");
|
if (ExpectWord(s) != "AND")
|
||||||
|
throw std::runtime_error("'AND' expected");
|
||||||
|
|
||||||
|
auto and_filter = std::make_unique<AndSongFilter>();
|
||||||
|
and_filter->AddItem(std::move(first));
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
and_filter->AddItem(ParseExpression(s, fold_case));
|
||||||
|
|
||||||
|
if (*s == ')') {
|
||||||
|
++s;
|
||||||
|
return and_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ExpectWord(s) != "AND")
|
||||||
|
throw std::runtime_error("'AND' expected");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto type = ExpectFilterType(s);
|
auto type = ExpectFilterType(s);
|
||||||
|
|
Loading…
Reference in New Issue