song/AudioFormatFilter: add mask support
This commit is contained in:
parent
b39bc85e60
commit
b4c517c501
@ -276,6 +276,14 @@
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
"<code>(AudioFormat =~ 'SAMPLERATE:BITS:CHANNELS')</code>":
|
||||||
|
matches the audio format with the given mask (i.e. one
|
||||||
|
or more attributes may be "<code>*</code>").
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
"<code>(!EXPRESSION)</code>": negate an expression.
|
"<code>(!EXPRESSION)</code>": negate an expression.
|
||||||
|
@ -24,13 +24,14 @@
|
|||||||
std::string
|
std::string
|
||||||
AudioFormatSongFilter::ToExpression() const noexcept
|
AudioFormatSongFilter::ToExpression() const noexcept
|
||||||
{
|
{
|
||||||
// TODO: support mask
|
return std::string("(AudioFormat ") +
|
||||||
return std::string("(AudioFormat == \"") + ToString(value).c_str() + "\")";
|
(value.IsFullyDefined() ? "==" : "=~") +
|
||||||
|
" \"" + ToString(value).c_str() + "\")";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AudioFormatSongFilter::Match(const LightSong &song) const noexcept
|
AudioFormatSongFilter::Match(const LightSong &song) const noexcept
|
||||||
{
|
{
|
||||||
// TODO: support mask
|
return song.audio_format.IsDefined() &&
|
||||||
return song.audio_format == value;
|
song.audio_format.MatchMask(value);
|
||||||
}
|
}
|
||||||
|
@ -245,14 +245,18 @@ SongFilter::ParseExpression(const char *&s, bool fold_case)
|
|||||||
|
|
||||||
return std::make_unique<BaseSongFilter>(std::move(value));
|
return std::make_unique<BaseSongFilter>(std::move(value));
|
||||||
} else if (type == LOCATE_TAG_AUDIO_FORMAT) {
|
} else if (type == LOCATE_TAG_AUDIO_FORMAT) {
|
||||||
if (s[0] != '=' || s[1] != '=')
|
bool mask;
|
||||||
throw std::runtime_error("'==' expected");
|
if (s[0] == '=' && s[1] == '=')
|
||||||
|
mask = false;
|
||||||
|
else if (s[0] == '=' && s[1] == '~')
|
||||||
|
mask = true;
|
||||||
|
else
|
||||||
|
throw std::runtime_error("'==' or '=~' expected");
|
||||||
|
|
||||||
s = StripLeft(s + 2);
|
s = StripLeft(s + 2);
|
||||||
|
|
||||||
// TODO: support mask
|
|
||||||
const auto value = ParseAudioFormat(ExpectQuoted(s).c_str(),
|
const auto value = ParseAudioFormat(ExpectQuoted(s).c_str(),
|
||||||
false);
|
mask);
|
||||||
|
|
||||||
if (*s != ')')
|
if (*s != ')')
|
||||||
throw std::runtime_error("')' expected");
|
throw std::runtime_error("')' expected");
|
||||||
|
Loading…
Reference in New Issue
Block a user