tag/Builder: CommitNew() returns std::unique_ptr<Tag>
This commit is contained in:
@@ -144,10 +144,10 @@ TagBuilder::Commit()
|
||||
return tag;
|
||||
}
|
||||
|
||||
Tag *
|
||||
std::unique_ptr<Tag>
|
||||
TagBuilder::CommitNew()
|
||||
{
|
||||
Tag *tag = new Tag();
|
||||
std::unique_ptr<Tag> tag(new Tag());
|
||||
Commit(*tag);
|
||||
return tag;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
struct StringView;
|
||||
struct TagItem;
|
||||
@@ -105,7 +106,7 @@ public:
|
||||
* returned object is owned by the caller. This object is
|
||||
* empty afterwards.
|
||||
*/
|
||||
Tag *CommitNew();
|
||||
std::unique_ptr<Tag> CommitNew();
|
||||
|
||||
void SetDuration(SignedSongTime _duration) {
|
||||
duration = _duration;
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "Handler.hxx"
|
||||
#include "Table.hxx"
|
||||
#include "Builder.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "Id3MusicBrainz.hxx"
|
||||
#include "util/Alloc.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
@@ -336,7 +337,7 @@ tag_id3_import(struct id3_tag *tag)
|
||||
scan_id3_tag(tag, add_tag_handler, &tag_builder);
|
||||
return tag_builder.empty()
|
||||
? nullptr
|
||||
: tag_builder.CommitNew();
|
||||
: tag_builder.CommitNew().release();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@@ -60,7 +60,7 @@ Tag::Merge(const Tag &base, const Tag &add)
|
||||
{
|
||||
TagBuilder builder(add);
|
||||
builder.Complement(base);
|
||||
return builder.CommitNew();
|
||||
return builder.CommitNew().release();
|
||||
}
|
||||
|
||||
Tag *
|
||||
|
Reference in New Issue
Block a user