files in the program, then also delete it here.
*/
+
+/** @file src/interop_subtitle_asset.cc
+ * @brief InteropSubtitleAsset class
+ */
+
+
#include "interop_subtitle_asset.h"
#include "interop_load_font_node.h"
#include "subtitle_asset_internal.h"
#include <cmath>
#include <cstdio>
+
using std::list;
using std::string;
using std::cout;
using boost::optional;
using namespace dcp;
+
InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
: SubtitleAsset (file)
{
_raw_xml = dcp::file_to_string (file);
- shared_ptr<cxml::Document> xml (new cxml::Document ("DCSubtitle"));
+ auto xml = make_shared<cxml::Document>("DCSubtitle");
xml->read_file (file);
_id = xml->string_child ("SubtitleID");
_reel_number = xml->string_child ("ReelNumber");
/* Now we need to drop down to xmlpp */
vector<ParseState> ps;
- xmlpp::Node::NodeList c = xml->node()->get_children ();
- for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) {
- xmlpp::Element const * e = dynamic_cast<xmlpp::Element const *> (*i);
+ for (auto i: xml->node()->get_children()) {
+ auto e = dynamic_cast<xmlpp::Element const *>(i);
if (e && (e->get_name() == "Font" || e->get_name() == "Subtitle")) {
parse_subtitles (e, ps, optional<int>(), Standard::INTEROP);
}
}
}
+
InteropSubtitleAsset::InteropSubtitleAsset ()
{
}
+
string
InteropSubtitleAsset::xml_as_string () const
{
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("DCSubtitle");
+ auto root = doc.create_root_node ("DCSubtitle");
root->set_attribute ("Version", "1.0");
root->add_child("SubtitleID")->add_child_text (_id);
return doc.write_to_string ("UTF-8");
}
+
void
InteropSubtitleAsset::add_font (string load_id, dcp::ArrayData data)
{
_fonts.push_back (Font(load_id, make_uuid(), data));
- string const uri = String::compose("font_%1.ttf", _load_font_nodes.size());
+ auto const uri = String::compose("font_%1.ttf", _load_font_nodes.size());
_load_font_nodes.push_back (shared_ptr<InteropLoadFontNode>(new InteropLoadFontNode(load_id, uri)));
}
+
bool
InteropSubtitleAsset::equals (shared_ptr<const Asset> other_asset, EqualityOptions options, NoteHandler note) const
{
return false;
}
- shared_ptr<const InteropSubtitleAsset> other = dynamic_pointer_cast<const InteropSubtitleAsset> (other_asset);
+ auto other = dynamic_pointer_cast<const InteropSubtitleAsset> (other_asset);
if (!other) {
return false;
}
return true;
}
+
vector<shared_ptr<LoadFontNode>>
InteropSubtitleAsset::load_font_nodes () const
{
return lf;
}
-/** Write this content to an XML file with its fonts alongside */
+
void
InteropSubtitleAsset::write (boost::filesystem::path p) const
{
- FILE* f = fopen_boost (p, "w");
+ auto f = fopen_boost (p, "w");
if (!f) {
throw FileError ("Could not open file for writing", p, -1);
}
- string const s = xml_as_string ();
+ auto const s = xml_as_string ();
/* length() here gives bytes not characters */
fwrite (s.c_str(), 1, s.length(), f);
fclose (f);
}
}
+
/** Look at a supplied list of assets and find the fonts. Then match these
* fonts up with anything requested by a <LoadFont> so that _fonts contains
* a list of font ID, load ID and data.
}
}
+
void
InteropSubtitleAsset::add_font_assets (vector<shared_ptr<Asset>>& assets)
{
}
}
+
void
InteropSubtitleAsset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const
{
}
}
+
void
InteropSubtitleAsset::add_to_pkl (shared_ptr<PKL> pkl, boost::filesystem::path root) const
{