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
9f4e96fd
Commit
9f4e96fd
authored
Dec 03, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PaylistTag: use class TagBuilder
parent
c36af357
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
44 deletions
+54
-44
PlaylistTag.cxx
src/PlaylistTag.cxx
+17
-5
Tag.cxx
src/tag/Tag.cxx
+0
-20
Tag.hxx
src/tag/Tag.hxx
+0
-12
TagBuilder.cxx
src/tag/TagBuilder.cxx
+27
-7
TagBuilder.hxx
src/tag/TagBuilder.hxx
+10
-0
No files found.
src/PlaylistTag.cxx
View file @
9f4e96fd
...
...
@@ -28,6 +28,7 @@
#include "PlaylistError.hxx"
#include "Song.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "util/Error.hxx"
bool
...
...
@@ -48,9 +49,15 @@ playlist::AddSongIdTag(unsigned id, TagType tag_type, const char *value,
return
false
;
}
if
(
song
.
tag
==
nullptr
)
song
.
tag
=
new
Tag
();
song
.
tag
->
AddItem
(
tag_type
,
value
);
TagBuilder
tag
;
if
(
song
.
tag
!=
nullptr
)
{
tag
=
std
::
move
(
*
song
.
tag
);
delete
song
.
tag
;
}
tag
.
AddItem
(
tag_type
,
value
);
song
.
tag
=
tag
.
Commit
();
queue
.
ModifyAtPosition
(
position
);
OnModified
();
return
true
;
...
...
@@ -77,10 +84,15 @@ playlist::ClearSongIdTag(unsigned id, TagType tag_type,
if
(
song
.
tag
==
nullptr
)
return
true
;
TagBuilder
tag
(
std
::
move
(
*
song
.
tag
));
delete
song
.
tag
;
if
(
tag_type
==
TAG_NUM_OF_ITEM_TYPES
)
song
.
tag
->
RemoveAll
();
tag
.
RemoveAll
();
else
song
.
tag
->
RemoveType
(
tag_type
);
tag
.
RemoveType
(
tag_type
);
song
.
tag
=
tag
.
Commit
();
queue
.
ModifyAtPosition
(
position
);
OnModified
();
return
true
;
...
...
src/tag/Tag.cxx
View file @
9f4e96fd
...
...
@@ -187,23 +187,3 @@ Tag::AddItem(TagType type, const char *value)
{
AddItem
(
type
,
value
,
strlen
(
value
));
}
void
Tag
::
RemoveType
(
TagType
type
)
{
auto
dest
=
items
,
src
=
items
,
end
=
items
+
num_items
;
tag_pool_lock
.
lock
();
while
(
src
!=
end
)
{
TagItem
*
item
=
*
src
++
;
if
(
item
->
type
==
type
)
/* remove it */
tag_pool_put_item
(
item
);
else
/* keep it */
*
dest
++
=
item
;
}
tag_pool_lock
.
unlock
();
num_items
=
dest
-
items
;
}
src/tag/Tag.hxx
View file @
9f4e96fd
...
...
@@ -122,18 +122,6 @@ struct Tag {
void
AddItem
(
TagType
type
,
const
char
*
value
);
/**
* Removes all tag items.
*/
void
RemoveAll
()
{
num_items
=
0
;
}
/**
* Removes all tag items of the specified type.
*/
void
RemoveType
(
TagType
type
);
/**
* Merges the data from two tags. If both tags share data for the
* same TagType, only data from "add" is used.
*
...
...
src/tag/TagBuilder.cxx
View file @
9f4e96fd
...
...
@@ -108,13 +108,7 @@ TagBuilder::Clear()
{
time
=
-
1
;
has_playlist
=
false
;
tag_pool_lock
.
lock
();
for
(
auto
i
:
items
)
tag_pool_put_item
(
i
);
tag_pool_lock
.
unlock
();
items
.
clear
();
RemoveAll
();
}
void
...
...
@@ -216,3 +210,29 @@ TagBuilder::AddItem(TagType type, const char *value)
AddItem
(
type
,
value
,
strlen
(
value
));
}
void
TagBuilder
::
RemoveAll
()
{
tag_pool_lock
.
lock
();
for
(
auto
i
:
items
)
tag_pool_put_item
(
i
);
tag_pool_lock
.
unlock
();
items
.
clear
();
}
void
TagBuilder
::
RemoveType
(
TagType
type
)
{
const
auto
begin
=
items
.
begin
(),
end
=
items
.
end
();
items
.
erase
(
std
::
remove_if
(
begin
,
end
,
[
type
](
TagItem
*
item
)
{
if
(
item
->
type
!=
type
)
return
false
;
tag_pool_put_item
(
item
);
return
true
;
}),
end
);
}
src/tag/TagBuilder.hxx
View file @
9f4e96fd
...
...
@@ -147,6 +147,16 @@ public:
gcc_nonnull_all
void
AddItem
(
TagType
type
,
const
char
*
value
);
/**
* Removes all tag items.
*/
void
RemoveAll
();
/**
* Removes all tag items of the specified type.
*/
void
RemoveType
(
TagType
type
);
private
:
gcc_nonnull_all
void
AddItemInternal
(
TagType
type
,
const
char
*
value
,
size_t
length
);
...
...
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