void TTXTSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const& encoding) const { // Convert to TTXT AssFile copy(*src); ConvertToTTXT(copy); // Create XML structure wxXmlDocument doc; wxXmlNode *root = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "TextStream"); root->AddAttribute("version", "1.1"); doc.SetRoot(root); // Create header WriteHeader(root); // Create lines AssDialogue *prev = 0; for (LineList::iterator cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) { AssDialogue *current = dynamic_cast<AssDialogue*>(*cur); if (current && !current->Comment) { WriteLine(root, prev, current); prev = current; } else throw TTXTParseError("Unexpected line type in TTXT file", 0); } // Save XML doc.Save(filename); }
void TTXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { // Convert to TTXT AssFile copy(*src); ConvertToTTXT(copy); // Create XML structure wxXmlDocument doc; wxXmlNode *root = new wxXmlNode(nullptr, wxXML_ELEMENT_NODE, "TextStream"); root->AddAttribute("version", "1.1"); doc.SetRoot(root); // Create header WriteHeader(root); // Create lines const AssDialogue *prev = nullptr; for (auto current : copy.Line | agi::of_type<AssDialogue>()) { WriteLine(root, prev, current); prev = current; } // Save XML doc.Save(filename.wstring()); }