Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
060908d5
Commit
060908d5
authored
Nov 12, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
song/Filter: add operator "contains"
Closes #410
parent
0b0f4c61
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
1 deletion
+21
-1
NEWS
NEWS
+1
-0
protocol.rst
doc/protocol.rst
+3
-0
Filter.cxx
src/song/Filter.cxx
+14
-0
StringFilter.hxx
src/song/StringFilter.hxx
+3
-1
No files found.
NEWS
View file @
060908d5
ver 0.21.2 (not yet released)
ver 0.21.2 (not yet released)
* protocol
* protocol
- operator "=~" matches a regular expression
- operator "=~" matches a regular expression
- operator "contains" matches substrings
* decoder
* decoder
- ffmpeg: require FFmpeg 3.1 or later
- ffmpeg: require FFmpeg 3.1 or later
- ffmpeg: fix broken sound with certain codecs
- ffmpeg: fix broken sound with certain codecs
...
...
doc/protocol.rst
View file @
060908d5
...
@@ -154,6 +154,9 @@ of:
...
@@ -154,6 +154,9 @@ of:
``AlbumArtist`` does not exist.
``AlbumArtist`` does not exist.
``VALUE`` is what to find.
``VALUE`` is what to find.
- ``(TAG contains 'VALUE')`` checks if the given value is a substring
of the tag value.
- ``(TAG =~ 'VALUE')`` and ``(TAG !~ 'VALUE')`` use a Perl-compatible
- ``(TAG =~ 'VALUE')`` and ``(TAG !~ 'VALUE')`` use a Perl-compatible
regular expression instead of doing a simple string comparison.
regular expression instead of doing a simple string comparison.
(This feature is only available if :program:`MPD` was compiled with
(This feature is only available if :program:`MPD` was compiled with
...
...
src/song/Filter.cxx
View file @
060908d5
...
@@ -206,6 +206,20 @@ ExpectQuoted(const char *&s)
...
@@ -206,6 +206,20 @@ ExpectQuoted(const char *&s)
static
StringFilter
static
StringFilter
ParseStringFilter
(
const
char
*&
s
,
bool
fold_case
)
ParseStringFilter
(
const
char
*&
s
,
bool
fold_case
)
{
{
if
(
auto
after_contains
=
StringAfterPrefixIgnoreCase
(
s
,
"contains "
))
{
s
=
StripLeft
(
after_contains
);
auto
value
=
ExpectQuoted
(
s
);
return
StringFilter
(
std
::
move
(
value
),
fold_case
,
true
,
false
);
}
if
(
auto
after_not_contains
=
StringAfterPrefixIgnoreCase
(
s
,
"!contains "
))
{
s
=
StripLeft
(
after_not_contains
);
auto
value
=
ExpectQuoted
(
s
);
return
StringFilter
(
std
::
move
(
value
),
fold_case
,
true
,
true
);
}
bool
negated
=
false
;
bool
negated
=
false
;
#ifdef HAVE_PCRE
#ifdef HAVE_PCRE
...
...
src/song/StringFilter.hxx
View file @
060908d5
...
@@ -96,7 +96,9 @@ public:
...
@@ -96,7 +96,9 @@ public:
const
char
*
GetOperator
()
const
noexcept
{
const
char
*
GetOperator
()
const
noexcept
{
return
IsRegex
()
return
IsRegex
()
?
(
negated
?
"!~"
:
"=~"
)
?
(
negated
?
"!~"
:
"=~"
)
:
(
negated
?
"!="
:
"=="
);
:
(
substring
?
(
negated
?
"!contains"
:
"contains"
)
:
(
negated
?
"!="
:
"=="
));
}
}
gcc_pure
gcc_pure
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment