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
7f1b1341
Commit
7f1b1341
authored
Jul 21, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongFilter: basic support for negated items
Not yet wired to the protocol.
parent
504776a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
18 deletions
+38
-18
SongFilter.cxx
src/SongFilter.cxx
+12
-12
SongFilter.hxx
src/SongFilter.hxx
+26
-6
No files found.
src/SongFilter.cxx
View file @
7f1b1341
...
...
@@ -74,7 +74,7 @@ SongFilter::Item::Item(unsigned _tag,
}
bool
SongFilter
::
Item
::
StringMatch
(
const
char
*
s
)
const
noexcept
SongFilter
::
Item
::
StringMatch
NN
(
const
char
*
s
)
const
noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
...
...
@@ -91,14 +91,14 @@ SongFilter::Item::StringMatch(const char *s) const noexcept
}
bool
SongFilter
::
Item
::
Match
(
const
TagItem
&
item
)
const
noexcept
SongFilter
::
Item
::
Match
NN
(
const
TagItem
&
item
)
const
noexcept
{
return
(
tag
==
LOCATE_TAG_ANY_TYPE
||
(
unsigned
)
item
.
type
==
tag
)
&&
StringMatch
(
item
.
value
);
StringMatch
NN
(
item
.
value
);
}
bool
SongFilter
::
Item
::
Match
(
const
Tag
&
_tag
)
const
noexcept
SongFilter
::
Item
::
Match
NN
(
const
Tag
&
_tag
)
const
noexcept
{
bool
visited_types
[
TAG_NUM_OF_ITEM_TYPES
];
std
::
fill_n
(
visited_types
,
size_t
(
TAG_NUM_OF_ITEM_TYPES
),
false
);
...
...
@@ -106,7 +106,7 @@ SongFilter::Item::Match(const Tag &_tag) const noexcept
for
(
const
auto
&
i
:
_tag
)
{
visited_types
[
i
.
type
]
=
true
;
if
(
Match
(
i
))
if
(
Match
NN
(
i
))
return
true
;
}
...
...
@@ -125,7 +125,7 @@ SongFilter::Item::Match(const Tag &_tag) const noexcept
only "artist" exists, use that */
for
(
const
auto
&
item
:
_tag
)
if
(
item
.
type
==
TAG_ARTIST
&&
StringMatch
(
item
.
value
))
StringMatch
NN
(
item
.
value
))
return
true
;
}
}
...
...
@@ -134,7 +134,7 @@ SongFilter::Item::Match(const Tag &_tag) const noexcept
}
bool
SongFilter
::
Item
::
Match
(
const
DetachedSong
&
song
)
const
noexcept
SongFilter
::
Item
::
Match
NN
(
const
DetachedSong
&
song
)
const
noexcept
{
if
(
tag
==
LOCATE_TAG_BASE_TYPE
)
return
uri_is_child_or_same
(
value
.
c_str
(),
song
.
GetURI
());
...
...
@@ -143,13 +143,13 @@ SongFilter::Item::Match(const DetachedSong &song) const noexcept
return
song
.
GetLastModified
()
>=
time
;
if
(
tag
==
LOCATE_TAG_FILE_TYPE
)
return
StringMatch
(
song
.
GetURI
());
return
StringMatch
NN
(
song
.
GetURI
());
return
Match
(
song
.
GetTag
());
return
Match
NN
(
song
.
GetTag
());
}
bool
SongFilter
::
Item
::
Match
(
const
LightSong
&
song
)
const
noexcept
SongFilter
::
Item
::
Match
NN
(
const
LightSong
&
song
)
const
noexcept
{
if
(
tag
==
LOCATE_TAG_BASE_TYPE
)
{
const
auto
uri
=
song
.
GetURI
();
...
...
@@ -161,10 +161,10 @@ SongFilter::Item::Match(const LightSong &song) const noexcept
if
(
tag
==
LOCATE_TAG_FILE_TYPE
)
{
const
auto
uri
=
song
.
GetURI
();
return
StringMatch
(
uri
.
c_str
());
return
StringMatch
NN
(
uri
.
c_str
());
}
return
Match
(
song
.
tag
);
return
Match
NN
(
song
.
tag
);
}
SongFilter
::
SongFilter
(
unsigned
tag
,
const
char
*
value
,
bool
fold_case
)
...
...
src/SongFilter.hxx
View file @
7f1b1341
...
...
@@ -52,6 +52,8 @@ public:
class
Item
{
unsigned
tag
;
bool
negated
=
false
;
std
::
string
value
;
/**
...
...
@@ -73,6 +75,14 @@ public:
return
tag
;
}
bool
IsNegated
()
const
noexcept
{
return
negated
;
}
void
SetNegated
(
bool
_negated
=
true
)
noexcept
{
negated
=
_negated
;
}
bool
GetFoldCase
()
const
{
return
fold_case
;
}
...
...
@@ -82,21 +92,31 @@ public:
}
private
:
/* note: the "NN" suffix means "no negation", i.e. the
method pretends negation is unset, and the caller
is responsibly for considering it */
gcc_pure
gcc_nonnull
(
2
)
bool
StringMatch
(
const
char
*
s
)
const
noexcept
;
bool
StringMatch
NN
(
const
char
*
s
)
const
noexcept
;
gcc_pure
bool
Match
(
const
TagItem
&
tag_item
)
const
noexcept
;
bool
Match
NN
(
const
TagItem
&
tag_item
)
const
noexcept
;
gcc_pure
bool
Match
(
const
Tag
&
tag
)
const
noexcept
;
bool
Match
NN
(
const
Tag
&
tag
)
const
noexcept
;
public
:
gcc_pure
bool
Match
(
const
DetachedSong
&
song
)
const
noexcept
;
bool
Match
NN
(
const
DetachedSong
&
song
)
const
noexcept
;
gcc_pure
bool
Match
(
const
LightSong
&
song
)
const
noexcept
;
bool
MatchNN
(
const
LightSong
&
song
)
const
noexcept
;
public
:
template
<
typename
T
>
gcc_pure
bool
Match
(
const
T
&
t
)
const
noexcept
{
return
MatchNN
(
t
)
!=
IsNegated
();
}
};
private
:
...
...
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