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
9263d6d0
Commit
9263d6d0
authored
Jul 24, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongFilter: implement operator "!="
Closes #89
parent
5271e81e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
NEWS
NEWS
+1
-1
protocol.xml
doc/protocol.xml
+4
-0
SongFilter.cxx
src/SongFilter.cxx
+9
-5
No files found.
NEWS
View file @
9263d6d0
...
@@ -7,7 +7,7 @@ ver 0.21 (not yet released)
...
@@ -7,7 +7,7 @@ ver 0.21 (not yet released)
- "outputs" prints the plugin name
- "outputs" prints the plugin name
- "outputset" sets runtime attributes
- "outputset" sets runtime attributes
- close connection when client sends HTTP request
- close connection when client sends HTTP request
- new filter syntax for "find"/"search" etc.
- new filter syntax for "find"/"search" etc.
with negation
* database
* database
- simple: scan audio formats
- simple: scan audio formats
* player
* player
...
...
doc/protocol.xml
View file @
9263d6d0
...
@@ -223,6 +223,10 @@
...
@@ -223,6 +223,10 @@
</para>
</para>
<para>
<para>
"
<code>
(TAG != 'VALUE')
</code>
": mismatch a tag value.
</para>
<para>
The special tag "
<parameter>
any
</parameter>
" checks all
The special tag "
<parameter>
any
</parameter>
" checks all
tag values.
tag values.
</para>
</para>
...
...
src/SongFilter.cxx
View file @
9263d6d0
...
@@ -81,7 +81,7 @@ SongFilter::Item::ToExpression() const noexcept
...
@@ -81,7 +81,7 @@ SongFilter::Item::ToExpression() const noexcept
{
{
switch
(
tag
)
{
switch
(
tag
)
{
case
LOCATE_TAG_FILE_TYPE
:
case
LOCATE_TAG_FILE_TYPE
:
return
"("
LOCATE_TAG_FILE_KEY
" ==
\"
"
+
value
+
"
\"
)"
;
return
std
::
string
(
"("
LOCATE_TAG_FILE_KEY
" "
)
+
(
IsNegated
()
?
"!="
:
"=="
)
+
"
\"
"
+
value
+
"
\"
)"
;
case
LOCATE_TAG_BASE_TYPE
:
case
LOCATE_TAG_BASE_TYPE
:
return
"(base
\"
"
+
value
+
"
\"
)"
;
return
"(base
\"
"
+
value
+
"
\"
)"
;
...
@@ -90,10 +90,10 @@ SongFilter::Item::ToExpression() const noexcept
...
@@ -90,10 +90,10 @@ SongFilter::Item::ToExpression() const noexcept
return
"(modified-since
\"
"
+
value
+
"
\"
)"
;
return
"(modified-since
\"
"
+
value
+
"
\"
)"
;
case
LOCATE_TAG_ANY_TYPE
:
case
LOCATE_TAG_ANY_TYPE
:
return
"("
LOCATE_TAG_ANY_KEY
" ==
\"
"
+
value
+
"
\"
)"
;
return
std
::
string
(
"("
LOCATE_TAG_ANY_KEY
" "
)
+
(
IsNegated
()
?
"!="
:
"=="
)
+
"
\"
"
+
value
+
"
\"
)"
;
default
:
default
:
return
std
::
string
(
"("
)
+
tag_item_names
[
tag
]
+
"
==
\"
"
+
value
+
"
\"
)"
;
return
std
::
string
(
"("
)
+
tag_item_names
[
tag
]
+
"
"
+
(
IsNegated
()
?
"!="
:
"=="
)
+
"
\"
"
+
value
+
"
\"
)"
;
}
}
}
}
...
@@ -317,8 +317,11 @@ SongFilter::ParseExpression(const char *s, bool fold_case)
...
@@ -317,8 +317,11 @@ SongFilter::ParseExpression(const char *s, bool fold_case)
items
.
emplace_back
(
type
,
std
::
move
(
value
),
fold_case
);
items
.
emplace_back
(
type
,
std
::
move
(
value
),
fold_case
);
return
StripLeft
(
s
+
1
);
return
StripLeft
(
s
+
1
);
}
else
{
}
else
{
if
(
s
[
0
]
!=
'='
||
s
[
1
]
!=
'='
)
bool
negated
=
false
;
throw
std
::
runtime_error
(
"'==' expected"
);
if
(
s
[
0
]
==
'!'
&&
s
[
1
]
==
'='
)
negated
=
true
;
else
if
(
s
[
0
]
!=
'='
||
s
[
1
]
!=
'='
)
throw
std
::
runtime_error
(
"'==' or '!=' expected"
);
s
=
StripLeft
(
s
+
2
);
s
=
StripLeft
(
s
+
2
);
auto
value
=
ExpectQuoted
(
s
);
auto
value
=
ExpectQuoted
(
s
);
...
@@ -326,6 +329,7 @@ SongFilter::ParseExpression(const char *s, bool fold_case)
...
@@ -326,6 +329,7 @@ SongFilter::ParseExpression(const char *s, bool fold_case)
throw
std
::
runtime_error
(
"')' expected"
);
throw
std
::
runtime_error
(
"')' expected"
);
items
.
emplace_back
(
type
,
std
::
move
(
value
),
fold_case
);
items
.
emplace_back
(
type
,
std
::
move
(
value
),
fold_case
);
items
.
back
().
SetNegated
(
negated
);
return
StripLeft
(
s
+
1
);
return
StripLeft
(
s
+
1
);
}
}
}
}
...
...
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