tag/Tag: add Merge() which takes Tag pointers
This commit is contained in:
parent
7d69cbbda7
commit
a74b07728e
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -132,6 +132,15 @@ struct Tag {
|
||||
static std::unique_ptr<Tag> Merge(std::unique_ptr<Tag> base,
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user