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; }
AssEntryGroup Group() const override { return group; }
AssAttachment *Clone() const override { return new AssAttachment(*this); }
AssAttachment(AssAttachment const& rgt);
AssAttachment(std::string const& header, AssEntryGroup group);

View file

@ -255,9 +255,3 @@ std::string AssDialogue::GetStrippedText() const {
boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
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?
bool CollidesWith(const AssDialogue *target) const;
AssDialogue *Clone() const override;
AssDialogue();
AssDialogue(AssDialogue const&);
AssDialogue(AssDialogueBase const&);

View file

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

View file

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

View file

@ -26,7 +26,6 @@ public:
AssInfo(AssInfo const& o) = default;
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; }
std::string GetEntryData() const override { return key + ": " + value; }
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 GetSSAText() const override;
AssEntryGroup Group() const override { return AssEntryGroup::STYLE; }
AssStyle *Clone() const override { return new AssStyle(*this); }
/// Convert an ASS alignment to the equivalent SSA alignment
static int AssToSsa(int ass_align);

View file

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

View file

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