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
a6aa0e4c
Commit
a6aa0e4c
authored
Oct 29, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SongFilter: use std::string
parent
163848ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
21 deletions
+26
-21
SongFilter.cxx
src/SongFilter.cxx
+23
-12
SongFilter.hxx
src/SongFilter.hxx
+3
-9
No files found.
src/SongFilter.cxx
View file @
a6aa0e4c
...
...
@@ -46,32 +46,43 @@ locate_parse_type(const char *str)
return
tag_name_parse_i
(
str
);
}
SongFilter
::
Item
::
Item
(
unsigned
_tag
,
const
char
*
_value
,
bool
_fold_case
)
:
tag
(
_tag
),
fold_case
(
_fold_case
),
value
(
fold_case
?
g_utf8_casefold
(
_value
,
-
1
)
:
g_strdup
(
_value
))
gcc_pure
static
std
::
string
CaseFold
(
const
char
*
p
)
{
char
*
q
=
g_utf8_casefold
(
p
,
-
1
);
std
::
string
result
(
q
);
g_free
(
q
);
return
result
;
}
SongFilter
::
Item
::~
Item
()
gcc_pure
static
std
::
string
ImportString
(
const
char
*
p
,
bool
fold_case
)
{
return
fold_case
?
CaseFold
(
p
)
:
std
::
string
(
p
);
}
SongFilter
::
Item
::
Item
(
unsigned
_tag
,
const
char
*
_value
,
bool
_fold_case
)
:
tag
(
_tag
),
fold_case
(
_fold_case
),
value
(
ImportString
(
_value
,
_fold_case
))
{
g_free
(
value
);
}
bool
SongFilter
::
Item
::
StringMatch
(
const
char
*
s
)
const
{
assert
(
value
!=
nullptr
);
assert
(
s
!=
nullptr
);
if
(
fold_case
)
{
char
*
p
=
g_utf8_casefold
(
s
,
-
1
);
const
bool
result
=
strstr
(
p
,
value
)
!=
NULL
;
const
bool
result
=
strstr
(
p
,
value
.
c_str
()
)
!=
NULL
;
g_free
(
p
);
return
result
;
}
else
{
return
s
trcmp
(
s
,
value
)
==
0
;
return
s
==
value
;
}
}
...
...
@@ -99,10 +110,10 @@ SongFilter::Item::Match(const Tag &_tag) const
/* If the search critieron was not visited during the
sweep through the song's tag, it means this field
is absent from the tag or empty. Thus, if the
searched string is also empty
(first char is a \0),
searched string is also empty
then it's a match as well and we should return
true. */
if
(
*
value
==
0
)
if
(
value
.
empty
()
)
return
true
;
if
(
tag
==
TAG_ALBUM_ARTIST
&&
visited_types
[
TAG_ARTIST
])
{
...
...
src/SongFilter.hxx
View file @
a6aa0e4c
...
...
@@ -23,6 +23,7 @@
#include "Compiler.h"
#include <list>
#include <string>
#include <stdint.h>
...
...
@@ -39,21 +40,14 @@ class SongFilter {
bool
fold_case
;
char
*
value
;
std
::
string
value
;
public
:
gcc_nonnull
(
3
)
Item
(
unsigned
tag
,
const
char
*
value
,
bool
fold_case
=
false
);
Item
(
const
Item
&
other
)
=
delete
;
Item
(
Item
&&
other
)
:
tag
(
other
.
tag
),
fold_case
(
other
.
fold_case
),
value
(
other
.
value
)
{
other
.
value
=
nullptr
;
}
~
Item
();
Item
(
Item
&&
)
=
default
;
Item
&
operator
=
(
const
Item
&
other
)
=
delete
;
...
...
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