From d49e59653fc10425b1fd4194bc0bd61535bacd62 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 28 Mar 2012 23:58:50 +0000 Subject: [PATCH] Add a version of ParseASSTags that returns the blocks rather than mutating the line Originally committed to SVN as r6626. --- aegisub/src/ass_dialogue.cpp | 13 ++++++++++--- aegisub/src/ass_dialogue.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/aegisub/src/ass_dialogue.cpp b/aegisub/src/ass_dialogue.cpp index a2331a1e1..a60133c51 100644 --- a/aegisub/src/ass_dialogue.cpp +++ b/aegisub/src/ass_dialogue.cpp @@ -233,13 +233,13 @@ wxString AssDialogue::GetSSAText () const { return GetData(true); } -void AssDialogue::ParseASSTags() { - ClearBlocks(); +std::vector AssDialogue::ParseTags() const { + std::vector Blocks; // Empty line, make an empty block if (Text.empty()) { Blocks.push_back(new AssDialogueBlockPlain); - return; + return Blocks; } int drawingLevel = 0; @@ -304,6 +304,13 @@ void AssDialogue::ParseASSTags() { } } } + + return Blocks; +} + +void AssDialogue::ParseASSTags() { + ClearBlocks(); + Blocks = ParseTags(); } void AssDialogue::StripTags () { diff --git a/aegisub/src/ass_dialogue.h b/aegisub/src/ass_dialogue.h index 2e209e658..b555c0422 100644 --- a/aegisub/src/ass_dialogue.h +++ b/aegisub/src/ass_dialogue.h @@ -178,8 +178,13 @@ public: /// @param version ASS version to try first (4, 4+, ASS2) /// @return Did it successfully parse? bool Parse(wxString data,int version=1); + /// Parse text as ASS to generate block information void ParseASSTags(); + + /// Parse text as ASS and return block information + std::vector ParseTags() const; + /// Clear all blocks, ALWAYS call this after you're done processing tags void ClearBlocks();