diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-10-10 16:07:44 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-10-10 16:07:44 +0100 |
| commit | e30c30ef7bbd8413ac0c8390abe574d5dd1cf5f7 (patch) | |
| tree | f67b4a9364264d433535dbc24a19b6df6ac59049 /src/subtitle_content.cc | |
| parent | 863ff8cced5b7d1d36ad6761fa1f6e2dbeafcad6 (diff) | |
Adapt to new libcxml ARI. Compiles but does not pass tests.1.0-new-cxml
Diffstat (limited to 'src/subtitle_content.cc')
| -rw-r--r-- | src/subtitle_content.cc | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/subtitle_content.cc b/src/subtitle_content.cc index 4f83d5bd..d79cf864 100644 --- a/src/subtitle_content.cc +++ b/src/subtitle_content.cc @@ -44,7 +44,7 @@ using namespace dcp; SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf) : Content (file) { - shared_ptr<cxml::Document> xml; + cxml::NodePtr xml (new cxml::Node); if (mxf) { ASDCP::TimedText::MXFReader reader; @@ -55,10 +55,7 @@ SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf) string s; reader.ReadTimedTextResource (s, 0, 0); - xml.reset (new cxml::Document ("SubtitleReel")); - stringstream t; - t << s; - xml->read_stream (t); + xml = cxml::read_string (s); ASDCP::WriterInfo info; reader.FillWriterInfo (info); @@ -68,8 +65,7 @@ SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf) _id = buffer; } else { - xml.reset (new cxml::Document ("DCSubtitle")); - xml->read_file (file); + xml = cxml::read_file (file); _id = xml->string_child ("SubtitleID"); } @@ -88,7 +84,7 @@ SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf) in a sane way. */ - shared_ptr<cxml::Node> subtitle_list = xml->optional_node_child ("SubtitleList"); + cxml::NodePtr subtitle_list = xml->optional_child ("SubtitleList"); if (subtitle_list) { list<shared_ptr<dcp::Font> > font = type_children<dcp::Font> (subtitle_list, "Font"); copy (font.begin(), font.end(), back_inserter (font_nodes)); @@ -108,7 +104,7 @@ SubtitleContent::SubtitleContent (string movie_title, string language) void SubtitleContent::examine_font_nodes ( - shared_ptr<const cxml::Node> xml, + cxml::ConstNodePtr xml, list<shared_ptr<dcp::Font> > const & font_nodes, ParseState& parse_state ) @@ -134,7 +130,7 @@ SubtitleContent::examine_font_nodes ( void SubtitleContent::examine_text_nodes ( - shared_ptr<const cxml::Node> xml, + cxml::ConstNodePtr xml, list<shared_ptr<dcp::Text> > const & text_nodes, ParseState& parse_state ) @@ -249,23 +245,23 @@ SubtitleContent::write_xml (boost::filesystem::path p) const Glib::ustring SubtitleContent::xml_as_string () const { - xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("DCSubtitle"); + cxml::NodePtr root (new cxml::Node); + root->set_name ("DCSubtitle"); root->set_attribute ("Version", "1.0"); - root->add_child("SubtitleID")->add_child_text (_id); + root->add_child("SubtitleID")->set_content (_id); if (_movie_title) { - root->add_child("MovieTitle")->add_child_text (_movie_title.get ()); + root->add_child("MovieTitle")->set_content (_movie_title.get ()); } - root->add_child("ReelNumber")->add_child_text (raw_convert<string> (_reel_number)); - root->add_child("Language")->add_child_text (_language); + root->add_child("ReelNumber")->set_content (raw_convert<string> (_reel_number)); + root->add_child("Language")->set_content (_language); if (_load_font_nodes.size() > 1) { boost::throw_exception (MiscError ("multiple LoadFont nodes not supported")); } if (!_load_font_nodes.empty ()) { - xmlpp::Element* load_font = root->add_child("LoadFont"); + cxml::NodePtr load_font = root->add_child("LoadFont"); load_font->set_attribute ("Id", _load_font_nodes.front()->id); if (_load_font_nodes.front()->uri) { load_font->set_attribute ("URI", _load_font_nodes.front()->uri.get ()); @@ -289,8 +285,8 @@ SubtitleContent::xml_as_string () const Time last_fade_up_time; Time last_fade_down_time; - xmlpp::Element* font = 0; - xmlpp::Element* subtitle = 0; + cxml::NodePtr font; + cxml::NodePtr subtitle; for (list<SubtitleString>::iterator i = sorted.begin(); i != sorted.end(); ++i) { @@ -351,13 +347,13 @@ SubtitleContent::xml_as_string () const last_fade_down_time = i->fade_down_time (); } - xmlpp::Element* text = subtitle->add_child ("Text"); + cxml::NodePtr text = subtitle->add_child ("Text"); text->set_attribute ("VAlign", valign_to_string (i->v_align())); text->set_attribute ("VPosition", raw_convert<string> (i->v_position())); - text->add_child_text (i->text()); + text->set_content (i->text()); } - return doc.write_to_string_formatted ("UTF-8"); + return cxml::write_to_string_formatted (root); } Time |
