Remove AssEntry::Clone

This commit is contained in:
Thomas Goyne 2014-03-07 16:44:49 -08:00
parent 8acce1a9ee
commit cc7595e3c6
9 changed files with 11 additions and 19 deletions

View File

@ -48,7 +48,6 @@ public:
std::string GetEntryData() const override { return entry_data; } std::string GetEntryData() const override { return entry_data; }
AssEntryGroup Group() const override { return group; } AssEntryGroup Group() const override { return group; }
AssAttachment *Clone() const override { return new AssAttachment(*this); }
AssAttachment(AssAttachment const& rgt); AssAttachment(AssAttachment const& rgt);
AssAttachment(std::string const& header, AssEntryGroup group); AssAttachment(std::string const& header, AssEntryGroup group);

View File

@ -255,9 +255,3 @@ std::string AssDialogue::GetStrippedText() const {
boost::ptr_vector<AssDialogueBlock> blocks(ParseTags()); boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
return join(blocks | agi::of_type<AssDialogueBlockPlain>() | transformed(get_text_p), ""); return join(blocks | agi::of_type<AssDialogueBlockPlain>() | transformed(get_text_p), "");
} }
AssDialogue *AssDialogue::Clone() const {
auto clone = new AssDialogue(*this);
clone->Id = Id;
return clone;
}

View File

@ -177,8 +177,6 @@ public:
/// Does this line collide with the passed line? /// Does this line collide with the passed line?
bool CollidesWith(const AssDialogue *target) const; bool CollidesWith(const AssDialogue *target) const;
AssDialogue *Clone() const override;
AssDialogue(); AssDialogue();
AssDialogue(AssDialogue const&); AssDialogue(AssDialogue const&);
AssDialogue(AssDialogueBase const&); AssDialogue(AssDialogueBase const&);

View File

@ -50,9 +50,6 @@ class AssEntry : public boost::intrusive::make_list_base_hook<boost::intrusive::
public: public:
virtual ~AssEntry() { } virtual ~AssEntry() { }
/// Create a copy of this entry
virtual AssEntry *Clone() const=0;
/// Section of the file this entry belongs to /// Section of the file this entry belongs to
virtual AssEntryGroup Group() const=0; virtual AssEntryGroup Group() const=0;

View File

@ -57,9 +57,15 @@ void AssFile::LoadDefault(bool include_dialogue_line) {
AssFile::AssFile(const AssFile &from) AssFile::AssFile(const AssFile &from)
: Info(from.Info) : Info(from.Info)
{ {
Styles.clone_from(from.Styles, std::mem_fun_ref(&AssStyle::Clone), [](AssStyle *e) { delete e; }); Styles.clone_from(from.Styles,
Events.clone_from(from.Events, std::mem_fun_ref(&AssDialogue::Clone), [](AssDialogue *e) { delete e; }); [](AssStyle const& e) { return new AssStyle(e); },
Attachments.clone_from(from.Attachments, std::mem_fun_ref(&AssAttachment::Clone), [](AssAttachment *e) { delete e; }); [](AssStyle *e) { delete e; });
Events.clone_from(from.Events,
[](AssDialogue const& e) { return new AssDialogue(e); },
[](AssDialogue *e) { delete e; });
Attachments.clone_from(from.Attachments,
[](AssAttachment const & e) { return new AssAttachment(e); },
[](AssAttachment *e) { delete e; });
} }
void AssFile::swap(AssFile& from) throw() { void AssFile::swap(AssFile& from) throw() {

View File

@ -26,7 +26,6 @@ public:
AssInfo(AssInfo const& o) = default; AssInfo(AssInfo const& o) = default;
AssInfo(std::string key, std::string value) : key(std::move(key)), value(std::move(value)) { } AssInfo(std::string key, std::string value) : key(std::move(key)), value(std::move(value)) { }
AssInfo *Clone() const override { return new AssInfo(*this); }
AssEntryGroup Group() const override { return AssEntryGroup::INFO; } AssEntryGroup Group() const override { return AssEntryGroup::INFO; }
std::string GetEntryData() const override { return key + ": " + value; } std::string GetEntryData() const override { return key + ": " + value; }
std::string GetSSAText() const override { return boost::iequals(key, "scripttype: v4.00+") ? "ScriptType: v4.00" : GetEntryData(); } std::string GetSSAText() const override { return boost::iequals(key, "scripttype: v4.00+") ? "ScriptType: v4.00" : GetEntryData(); }

View File

@ -80,7 +80,6 @@ public:
std::string GetEntryData() const override { return data; } std::string GetEntryData() const override { return data; }
std::string GetSSAText() const override; std::string GetSSAText() const override;
AssEntryGroup Group() const override { return AssEntryGroup::STYLE; } AssEntryGroup Group() const override { return AssEntryGroup::STYLE; }
AssStyle *Clone() const override { return new AssStyle(*this); }
/// Convert an ASS alignment to the equivalent SSA alignment /// Convert an ASS alignment to the equivalent SSA alignment
static int AssToSsa(int ass_align); static int AssToSsa(int ass_align);

View File

@ -629,7 +629,7 @@ void DialogStyleManager::OnCurrentImport() {
// Copy // Copy
modified = true; modified = true;
c->ass->Styles.push_back(*temp.GetStyle(styles[sel])->Clone()); c->ass->Styles.push_back(*new AssStyle(*temp.GetStyle(styles[sel])));
} }
// Update // Update

View File

@ -141,7 +141,7 @@ void ThreadedFrameSource::UpdateSubtitles(const AssFile *new_subs, std::set<cons
size_t i = 0; size_t i = 0;
for (auto const& e : new_subs->Events) { for (auto const& e : new_subs->Events) {
if (changes.count(&e)) if (changes.count(&e))
changed.emplace_back(i, e.Clone()); changed.emplace_back(i, new AssDialogue(e));
++i; ++i;
} }