diff --git a/aegisub/src/ass_dialogue.cpp b/aegisub/src/ass_dialogue.cpp index caa664ba6..d52833ca0 100644 --- a/aegisub/src/ass_dialogue.cpp +++ b/aegisub/src/ass_dialogue.cpp @@ -228,7 +228,7 @@ std::auto_ptr> AssDialogue::ParseTags() cons // Look for \p in block for (auto tag : block->Tags) { if (tag->Name == "\\p") - drawingLevel = tag->Params[0]->Get(0); + drawingLevel = tag->Params[0].Get(0); } } diff --git a/aegisub/src/ass_karaoke.cpp b/aegisub/src/ass_karaoke.cpp index 90c37a922..5f633ad07 100644 --- a/aegisub/src/ass_karaoke.cpp +++ b/aegisub/src/ass_karaoke.cpp @@ -140,7 +140,7 @@ void AssKaraoke::ParseSyllables(AssDialogue *line, Syllable &syl) { syl.tag_type = tag->Name; syl.start_time += syl.duration; - syl.duration = tag->Params[0]->Get(0) * 10; + syl.duration = tag->Params[0].Get(0) * 10; } else { wxString& otext = syl.ovr_tags[syl.text.size()]; diff --git a/aegisub/src/ass_override.cpp b/aegisub/src/ass_override.cpp index 21d239e13..9288fdcae 100644 --- a/aegisub/src/ass_override.cpp +++ b/aegisub/src/ass_override.cpp @@ -100,14 +100,14 @@ wxString AssDialogueBlockOverride::GetText() { void AssDialogueBlockOverride::ProcessParameters(ProcessParametersCallback callback, void *userData) { for (auto tag : Tags) { - for (auto par : tag->Params) { - if (par->GetType() == VARDATA_NONE || par->omitted) continue; + for (auto& par : tag->Params) { + if (par.GetType() == VARDATA_NONE || par.omitted) continue; - callback(tag->Name, par, userData); + callback(tag->Name, &par, userData); // Go recursive if it's a block parameter - if (par->GetType() == VARDATA_BLOCK) - par->Get()->ProcessParameters(callback, userData); + if (par.GetType() == VARDATA_BLOCK) + par.Get()->ProcessParameters(callback, userData); } } } @@ -269,12 +269,8 @@ AssOverrideTag::AssOverrideTag(wxString text) { SetText(text); } -AssOverrideTag::~AssOverrideTag () { - delete_clear(Params); -} - void AssOverrideTag::Clear() { - delete_clear(Params); + Params.clear(); Params.reserve(6); valid = false; } @@ -365,9 +361,9 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto:: unsigned curPar = 0; for (auto& curproto : proto_it->params) { // Create parameter - AssOverrideParameter *newparam = new AssOverrideParameter; + Params.emplace_back(); + AssOverrideParameter *newparam = &Params.back(); newparam->classification = curproto.classification; - Params.push_back(newparam); // Check if it's optional and not present if (!(curproto.optional & parsFlag) || curPar >= totalPars) { @@ -423,7 +419,7 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto:: } } -static wxString param_str(AssOverrideParameter *p) { return p->Get(); } +static wxString param_str(AssOverrideParameter const& p) { return p.Get(); } AssOverrideTag::operator wxString() const { wxString result = Name; @@ -433,7 +429,7 @@ AssOverrideTag::operator wxString() const { // Add parameters result += join(Params - | filtered([](AssOverrideParameter *p) { return p->GetType() != VARDATA_NONE && !p->omitted; }) + | filtered([](AssOverrideParameter const& p) { return p.GetType() != VARDATA_NONE && !p.omitted; }) | transformed(param_str), wxS(",")); diff --git a/aegisub/src/ass_override.h b/aegisub/src/ass_override.h index 95e9cdc84..8a9b83904 100644 --- a/aegisub/src/ass_override.h +++ b/aegisub/src/ass_override.h @@ -113,16 +113,15 @@ struct AssOverrideTagProto { void Set(wxString name, VariableDataType type, AssParameterClass classi = PARCLASS_NORMAL, int opt = NOT_OPTIONAL); }; -class AssOverrideTag { +class AssOverrideTag : boost::noncopyable { bool valid; public: wxString Name; - std::vector Params; + std::vector Params; AssOverrideTag(); AssOverrideTag(wxString text); - ~AssOverrideTag(); bool IsValid() const { return valid; } /// @brief Parses the parameters for the ass override tag diff --git a/aegisub/src/command/edit.cpp b/aegisub/src/command/edit.cpp index e5846c769..51d678206 100644 --- a/aegisub/src/command/edit.cpp +++ b/aegisub/src/command/edit.cpp @@ -171,7 +171,7 @@ T get_value(boost::ptr_vector const& blocks, int blockn, T ini for (auto ovr : blocks | sliced(0, blockn + 1) | reversed | agi::of_type()) { for (auto tag : ovr->Tags | reversed) { if (tag->Name == tag_name || tag->Name == alt) - return tag->Params[0]->Get(initial); + return tag->Params[0].Get(initial); } } return initial; @@ -247,8 +247,8 @@ void set_tag(AssDialogue *line, boost::ptr_vector &blocks, wxS i--; } else { - ovr->Tags[i]->Params[0]->Set(value); - ovr->Tags[i]->Params[0]->omitted = false; + ovr->Tags[i]->Params[0].Set(value); + ovr->Tags[i]->Params[0].omitted = false; found = true; } } diff --git a/aegisub/src/font_file_lister.cpp b/aegisub/src/font_file_lister.cpp index 9c4e276a1..b7511b382 100644 --- a/aegisub/src/font_file_lister.cpp +++ b/aegisub/src/font_file_lister.cpp @@ -60,19 +60,19 @@ void FontCollector::ProcessDialogueLine(const AssDialogue *line, int index) { wxString name = tag->Name; if (name == "\\r") { - style = styles[tag->Params[0]->Get(line->Style)]; + style = styles[tag->Params[0].Get(line->Style)]; overriden = false; } else if (name == "\\b") { - style.bold = tag->Params[0]->Get(initial.bold); + style.bold = tag->Params[0].Get(initial.bold); overriden = true; } else if (name == "\\i") { - style.italic = tag->Params[0]->Get(initial.italic); + style.italic = tag->Params[0].Get(initial.italic); overriden = true; } else if (name == "\\fn") { - style.facename = tag->Params[0]->Get(initial.facename); + style.facename = tag->Params[0].Get(initial.facename); overriden = true; } } diff --git a/aegisub/src/subtitle_format_ebu3264.cpp b/aegisub/src/subtitle_format_ebu3264.cpp index f8da0bab4..d63565118 100644 --- a/aegisub/src/subtitle_format_ebu3264.cpp +++ b/aegisub/src/subtitle_format_ebu3264.cpp @@ -125,13 +125,13 @@ namespace for (auto t : ob->Tags) { if (t->Name == "\\u") - underline = t->Params[0]->Get(style_underline); + underline = t->Params[0].Get(style_underline); else if (t->Name == "\\i") - italic = t->Params[0]->Get(style_italic); + italic = t->Params[0].Get(style_italic); else if (t->Name == "\\an") - align = t->Params[0]->Get(align); - else if (t->Name == "\\a" && !t->Params[0]->omitted) - align = AssStyle::SsaToAss(t->Params[0]->Get()); + align = t->Params[0].Get(align); + else if (t->Name == "\\a" && !t->Params[0].omitted) + align = AssStyle::SsaToAss(t->Params[0].Get()); } } diff --git a/aegisub/src/subtitle_format_srt.cpp b/aegisub/src/subtitle_format_srt.cpp index 2e281bbc1..ca4c18929 100644 --- a/aegisub/src/subtitle_format_srt.cpp +++ b/aegisub/src/subtitle_format_srt.cpp @@ -563,7 +563,7 @@ wxString SRTSubtitleFormat::ConvertTags(const AssDialogue *diag) const { if (tag->IsValid() && tag->Name.size() == 2) { auto it = tag_states.find(tag->Name[1]); if (it != tag_states.end()) { - bool temp = tag->Params[0]->Get(false); + bool temp = tag->Params[0].Get(false); if (temp && !it->second) final += wxString::Format("<%c>", it->first); if (!temp && it->second) diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index 0d3a6703f..5db7098af 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -355,7 +355,7 @@ void VisualTool::RemoveSelection(feature_iterator feat) { //////// PARSERS -typedef const std::vector * param_vec; +typedef const std::vector * param_vec; // Find a tag's parameters in a line or return nullptr if it's not found static param_vec find_tag(boost::ptr_vector& blocks, wxString tag_name) { @@ -373,12 +373,12 @@ static param_vec find_tag(boost::ptr_vector& blocks, wxString static Vector2D vec_or_bad(param_vec tag, size_t x_idx, size_t y_idx) { if (!tag || tag->size() <= x_idx || tag->size() <= y_idx || - (*tag)[x_idx]->omitted || (*tag)[y_idx]->omitted || - (*tag)[x_idx]->GetType() == VARDATA_NONE || (*tag)[y_idx]->GetType() == VARDATA_NONE) + (*tag)[x_idx].omitted || (*tag)[y_idx].omitted || + (*tag)[x_idx].GetType() == VARDATA_NONE || (*tag)[y_idx].GetType() == VARDATA_NONE) { return Vector2D(); } - return Vector2D((*tag)[x_idx]->Get(), (*tag)[y_idx]->Get()); + return Vector2D((*tag)[x_idx].Get(), (*tag)[y_idx].Get()); } Vector2D VisualToolBase::GetLinePosition(AssDialogue *diag) { @@ -402,10 +402,10 @@ Vector2D VisualToolBase::GetLinePosition(AssDialogue *diag) { param_vec align_tag; int ovr_align = 0; - if ((align_tag = find_tag(blocks, "\\an")) && !(*align_tag)[0]->omitted) - ovr_align = (*align_tag)[0]->Get(); + if ((align_tag = find_tag(blocks, "\\an")) && !(*align_tag)[0].omitted) + ovr_align = (*align_tag)[0].Get(); else if ((align_tag = find_tag(blocks, "\\a"))) - ovr_align = AssStyle::SsaToAss((*align_tag)[0]->Get(2)); + ovr_align = AssStyle::SsaToAss((*align_tag)[0].Get(2)); if (ovr_align > 0 && ovr_align <= 9) align = ovr_align; @@ -448,8 +448,8 @@ bool VisualToolBase::GetLineMove(AssDialogue *diag, Vector2D &p1, Vector2D &p2, p1 = vec_or_bad(tag, 0, 1); p2 = vec_or_bad(tag, 2, 3); // VSFilter actually defaults to -1, but it uses <= 0 to check for default and 0 seems less bug-prone - t1 = (*tag)[4]->Get(0); - t2 = (*tag)[5]->Get(0); + t1 = (*tag)[4].Get(0); + t2 = (*tag)[5].Get(0); return p1 && p2; } @@ -463,13 +463,13 @@ void VisualToolBase::GetLineRotation(AssDialogue *diag, float &rx, float &ry, fl boost::ptr_vector blocks(diag->ParseTags()); if (param_vec tag = find_tag(blocks, "\\frx")) - rx = tag->front()->Get(rx); + rx = tag->front().Get(rx); if (param_vec tag = find_tag(blocks, "\\fry")) - ry = tag->front()->Get(ry); + ry = tag->front().Get(ry); if (param_vec tag = find_tag(blocks, "\\frz")) - rz = tag->front()->Get(rz); + rz = tag->front().Get(rz); else if ((tag = find_tag(blocks, "\\fr"))) - rz = tag->front()->Get(rz); + rz = tag->front().Get(rz); } void VisualToolBase::GetLineScale(AssDialogue *diag, Vector2D &scale) { @@ -483,9 +483,9 @@ void VisualToolBase::GetLineScale(AssDialogue *diag, Vector2D &scale) { boost::ptr_vector blocks(diag->ParseTags()); if (param_vec tag = find_tag(blocks, "\\fscx")) - x = tag->front()->Get(x); + x = tag->front().Get(x); if (param_vec tag = find_tag(blocks, "\\fscy")) - y = tag->front()->Get(y); + y = tag->front().Get(y); scale = Vector2D(x, y); } @@ -524,14 +524,14 @@ wxString VisualToolBase::GetLineVectorClip(AssDialogue *diag, int &scale, bool & if (tag && tag->size() == 4) { return wxString::Format("m %d %d l %d %d %d %d %d %d", - (*tag)[0]->Get(), (*tag)[1]->Get(), - (*tag)[2]->Get(), (*tag)[1]->Get(), - (*tag)[2]->Get(), (*tag)[3]->Get(), - (*tag)[0]->Get(), (*tag)[3]->Get()); + (*tag)[0].Get(), (*tag)[1].Get(), + (*tag)[2].Get(), (*tag)[1].Get(), + (*tag)[2].Get(), (*tag)[3].Get(), + (*tag)[0].Get(), (*tag)[3].Get()); } if (tag) { - scale = std::max((*tag)[0]->Get(scale), 1); - return (*tag)[1]->Get(""); + scale = std::max((*tag)[0].Get(scale), 1); + return (*tag)[1].Get(""); } return "";