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
a74b0772
Commit
a74b0772
authored
Aug 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag/Tag: add Merge() which takes Tag pointers
parent
7d69cbbd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
11 deletions
+26
-11
IcyInputStream.cxx
src/input/IcyInputStream.cxx
+1
-11
Tag.cxx
src/tag/Tag.cxx
+16
-0
Tag.hxx
src/tag/Tag.hxx
+9
-0
No files found.
src/input/IcyInputStream.cxx
View file @
a74b0772
...
...
@@ -82,17 +82,7 @@ IcyInputStream::ReadTag() noexcept
/* no change */
return
nullptr
;
if
(
input_tag
==
nullptr
&&
icy_tag
==
nullptr
)
/* no tag */
return
nullptr
;
if
(
input_tag
==
nullptr
)
return
std
::
make_unique
<
Tag
>
(
*
icy_tag
);
if
(
icy_tag
==
nullptr
)
return
std
::
make_unique
<
Tag
>
(
*
input_tag
);
return
Tag
::
MergePtr
(
*
input_tag
,
*
icy_tag
);
return
Tag
::
Merge
(
input_tag
.
get
(),
icy_tag
.
get
());
}
size_t
...
...
src/tag/Tag.cxx
View file @
a74b0772
...
...
@@ -81,6 +81,22 @@ Tag::Merge(std::unique_ptr<Tag> base, std::unique_ptr<Tag> add) noexcept
return
MergePtr
(
*
base
,
*
add
);
}
std
::
unique_ptr
<
Tag
>
Tag
::
Merge
(
const
Tag
*
base
,
const
Tag
*
add
)
noexcept
{
if
(
base
==
nullptr
&&
add
==
nullptr
)
/* no tag */
return
nullptr
;
if
(
base
==
nullptr
)
return
std
::
make_unique
<
Tag
>
(
*
add
);
if
(
add
==
nullptr
)
return
std
::
make_unique
<
Tag
>
(
*
base
);
return
MergePtr
(
*
base
,
*
add
);
}
const
char
*
Tag
::
GetValue
(
TagType
type
)
const
noexcept
{
...
...
src/tag/Tag.hxx
View file @
a74b0772
...
...
@@ -133,6 +133,15 @@ struct Tag {
std
::
unique_ptr
<
Tag
>
add
)
noexcept
;
/**
* Merges the data from two tags. Any of the two may be nullptr.
*
* @return a newly allocated tag (or nullptr if both
* parameters are nullptr)
*/
static
std
::
unique_ptr
<
Tag
>
Merge
(
const
Tag
*
base
,
const
Tag
*
add
)
noexcept
;
/**
* Returns the first value of the specified tag type, or
* nullptr if none is present in this tag object.
*/
...
...
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