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
efb2051b
Commit
efb2051b
authored
7 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongFilter: add ToExpression()
parent
a2b24cb5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
SongFilter.cxx
src/SongFilter.cxx
+42
-0
SongFilter.hxx
src/SongFilter.hxx
+12
-0
No files found.
src/SongFilter.cxx
View file @
efb2051b
...
...
@@ -73,6 +73,27 @@ SongFilter::Item::Item(unsigned _tag,
{
}
std
::
string
SongFilter
::
Item
::
ToExpression
()
const
noexcept
{
switch
(
tag
)
{
case
LOCATE_TAG_FILE_TYPE
:
return
"("
LOCATE_TAG_FILE_KEY
" ==
\"
"
+
value
+
"
\"
)"
;
case
LOCATE_TAG_BASE_TYPE
:
return
"(base
\"
"
+
value
+
"
\"
)"
;
case
LOCATE_TAG_MODIFIED_SINCE
:
return
"(modified-since
\"
"
+
value
+
"
\"
)"
;
case
LOCATE_TAG_ANY_TYPE
:
return
"("
LOCATE_TAG_ANY_KEY
" ==
\"
"
+
value
+
"
\"
)"
;
default
:
return
std
::
string
(
"("
)
+
tag_item_names
[
tag
]
+
" ==
\"
"
+
value
+
"
\"
)"
;
}
}
bool
SongFilter
::
Item
::
StringMatchNN
(
const
char
*
s
)
const
noexcept
{
...
...
@@ -177,6 +198,27 @@ SongFilter::~SongFilter()
/* this destructor exists here just so it won't get inlined */
}
std
::
string
SongFilter
::
ToExpression
()
const
noexcept
{
auto
i
=
items
.
begin
();
const
auto
end
=
items
.
end
();
if
(
std
::
next
(
i
)
==
end
)
return
i
->
ToExpression
();
std
::
string
e
(
"("
);
e
+=
i
->
ToExpression
();
for
(
++
i
;
i
!=
end
;
++
i
)
{
e
+=
" AND "
;
e
+=
i
->
ToExpression
();
}
e
.
push_back
(
')'
);
return
e
;
}
static
std
::
chrono
::
system_clock
::
time_point
ParseTimeStamp
(
const
char
*
s
)
{
...
...
This diff is collapsed.
Click to expand it.
src/SongFilter.hxx
View file @
efb2051b
...
...
@@ -70,6 +70,12 @@ public:
Item
(
unsigned
tag
,
std
::
string
&&
_value
,
bool
fold_case
=
false
);
Item
(
unsigned
tag
,
std
::
chrono
::
system_clock
::
time_point
time
);
/**
* Convert this object into an "expression". This is
* only useful for debugging.
*/
std
::
string
ToExpression
()
const
noexcept
;
unsigned
GetTag
()
const
{
return
tag
;
}
...
...
@@ -129,6 +135,12 @@ public:
~
SongFilter
();
/**
* Convert this object into an "expression". This is
* only useful for debugging.
*/
std
::
string
ToExpression
()
const
noexcept
;
private
:
gcc_nonnull
(
2
,
3
)
void
Parse
(
const
char
*
tag
,
const
char
*
value
,
bool
fold_case
=
false
);
...
...
This diff is collapsed.
Click to expand it.
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