summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-24 12:12:23 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-24 12:12:23 +0100
commitdb536bd9f9f16b79286c5f0bb54d0f283050f7dd (patch)
treefafae4349032739326592dfaa18d6b499c743f6c
parenta5bf0e4edbdbf7a0818666313b1d3909986342f1 (diff)
Express standard differences in FontNode more neatly.
-rw-r--r--src/font_node.cc14
-rw-r--r--src/font_node.h2
-rw-r--r--src/interop_subtitle_asset.cc4
-rw-r--r--src/smpte_subtitle_asset.cc4
-rw-r--r--src/subtitle_node.cc6
-rw-r--r--src/subtitle_node.h2
-rw-r--r--src/text_node.cc4
-rw-r--r--src/text_node.h2
-rw-r--r--test/text_test.cc4
9 files changed, 23 insertions, 19 deletions
diff --git a/src/font_node.cc b/src/font_node.cc
index 6dd6e58f..c24c29d6 100644
--- a/src/font_node.cc
+++ b/src/font_node.cc
@@ -45,11 +45,15 @@ using boost::shared_ptr;
using boost::optional;
using namespace dcp;
-FontNode::FontNode (cxml::ConstNodePtr node, optional<int> tcr, string font_id_attribute)
+FontNode::FontNode (cxml::ConstNodePtr node, optional<int> tcr, Standard standard)
{
text = node->content ();
- id = node->optional_string_attribute (font_id_attribute);
+ if (standard == INTEROP) {
+ id = node->optional_string_attribute ("Id");
+ } else {
+ id = node->optional_string_attribute ("ID");
+ }
size = node->optional_number_attribute<int64_t> ("Size").get_value_or (0);
aspect_adjust = node->optional_number_attribute<float> ("AspectAdjust");
italic = node->optional_bool_attribute ("Italic");
@@ -69,17 +73,17 @@ FontNode::FontNode (cxml::ConstNodePtr node, optional<int> tcr, string font_id_a
list<cxml::NodePtr> s = node->node_children ("Subtitle");
BOOST_FOREACH (cxml::NodePtr& i, s) {
- subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, tcr, font_id_attribute)));
+ subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, tcr, standard)));
}
list<cxml::NodePtr> f = node->node_children ("Font");
BOOST_FOREACH (cxml::NodePtr& i, f) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr, font_id_attribute)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr, standard)));
}
list<cxml::NodePtr> t = node->node_children ("Text");
BOOST_FOREACH (cxml::NodePtr& i, t) {
- text_nodes.push_back (shared_ptr<TextNode> (new TextNode (i, tcr, font_id_attribute)));
+ text_nodes.push_back (shared_ptr<TextNode> (new TextNode (i, tcr, standard)));
}
}
diff --git a/src/font_node.h b/src/font_node.h
index 8f7cc2aa..656c0264 100644
--- a/src/font_node.h
+++ b/src/font_node.h
@@ -54,7 +54,7 @@ public:
: size (0)
{}
- FontNode (cxml::ConstNodePtr node, boost::optional<int> tcr, std::string font_id_attribute);
+ FontNode (cxml::ConstNodePtr node, boost::optional<int> tcr, Standard standard);
explicit FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes);
std::string text;
diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc
index b32ac790..b0b94995 100644
--- a/src/interop_subtitle_asset.cc
+++ b/src/interop_subtitle_asset.cc
@@ -68,12 +68,12 @@ InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file)
list<shared_ptr<dcp::FontNode> > font_nodes;
BOOST_FOREACH (cxml::NodePtr const & i, xml->node_children ("Font")) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, optional<int>(), "Id")));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, optional<int>(), INTEROP)));
}
list<shared_ptr<dcp::SubtitleNode> > subtitle_nodes;
BOOST_FOREACH (cxml::NodePtr const & i, xml->node_children ("Subtitle")) {
- subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, optional<int>(), "Id")));
+ subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, optional<int>(), INTEROP)));
}
parse_subtitles (xml, font_nodes, subtitle_nodes);
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index 685b4fc7..2a6a5093 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -134,12 +134,12 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
list<shared_ptr<dcp::FontNode> > font_nodes;
BOOST_FOREACH (cxml::NodePtr const & i, subtitle_list->node_children ("Font")) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, _time_code_rate, "ID")));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, _time_code_rate, SMPTE)));
}
list<shared_ptr<dcp::SubtitleNode> > subtitle_nodes;
BOOST_FOREACH (cxml::NodePtr const & i, subtitle_list->node_children ("Subtitle")) {
- subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, _time_code_rate, "ID")));
+ subtitle_nodes.push_back (shared_ptr<SubtitleNode> (new SubtitleNode (i, _time_code_rate, SMPTE)));
}
parse_subtitles (xml, font_nodes, subtitle_nodes);
diff --git a/src/subtitle_node.cc b/src/subtitle_node.cc
index 44c32e26..82c11401 100644
--- a/src/subtitle_node.cc
+++ b/src/subtitle_node.cc
@@ -46,19 +46,19 @@ using boost::lexical_cast;
using namespace dcp;
/** @param tcr Timecode rate for SMPTE, or empty for Interop */
-SubtitleNode::SubtitleNode (boost::shared_ptr<const cxml::Node> node, optional<int> tcr, string font_id_attribute)
+SubtitleNode::SubtitleNode (boost::shared_ptr<const cxml::Node> node, optional<int> tcr, Standard standard)
{
in = Time (node->string_attribute ("TimeIn"), tcr);
out = Time (node->string_attribute ("TimeOut"), tcr);
list<cxml::NodePtr> f = node->node_children ("Font");
for (list<cxml::NodePtr>::iterator i = f.begin(); i != f.end(); ++i) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (*i, tcr, font_id_attribute)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (*i, tcr, standard)));
}
list<cxml::NodePtr> t = node->node_children ("Text");
for (list<cxml::NodePtr>::iterator i = t.begin(); i != t.end(); ++i) {
- text_nodes.push_back (shared_ptr<TextNode> (new TextNode (*i, tcr, font_id_attribute)));
+ text_nodes.push_back (shared_ptr<TextNode> (new TextNode (*i, tcr, standard)));
}
fade_up_time = fade_time (node, "FadeUpTime", tcr);
diff --git a/src/subtitle_node.h b/src/subtitle_node.h
index 37d41f01..e08ecfd4 100644
--- a/src/subtitle_node.h
+++ b/src/subtitle_node.h
@@ -52,7 +52,7 @@ class SubtitleNode
{
public:
SubtitleNode () {}
- SubtitleNode (boost::shared_ptr<const cxml::Node> node, boost::optional<int> tcr, std::string font_id_attribute);
+ SubtitleNode (boost::shared_ptr<const cxml::Node> node, boost::optional<int> tcr, Standard standard);
Time in;
Time out;
diff --git a/src/text_node.cc b/src/text_node.cc
index cfd0557f..6a48470d 100644
--- a/src/text_node.cc
+++ b/src/text_node.cc
@@ -51,7 +51,7 @@ using namespace dcp;
* in this object's member variables.
* @param node Node to read.
*/
-TextNode::TextNode (boost::shared_ptr<const cxml::Node> node, optional<int> tcr, string font_id_attribute)
+TextNode::TextNode (boost::shared_ptr<const cxml::Node> node, optional<int> tcr, Standard standard)
: h_position (0)
, h_align (HALIGN_CENTER)
, v_position (0)
@@ -99,6 +99,6 @@ TextNode::TextNode (boost::shared_ptr<const cxml::Node> node, optional<int> tcr,
list<cxml::NodePtr> f = node->node_children ("Font");
BOOST_FOREACH (cxml::NodePtr& i, f) {
- font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr, font_id_attribute)));
+ font_nodes.push_back (shared_ptr<FontNode> (new FontNode (i, tcr, standard)));
}
}
diff --git a/src/text_node.h b/src/text_node.h
index 313bdbcb..21246cb2 100644
--- a/src/text_node.h
+++ b/src/text_node.h
@@ -63,7 +63,7 @@ public:
, direction (DIRECTION_LTR)
{}
- TextNode (boost::shared_ptr<const cxml::Node> node, boost::optional<int> tcr, std::string font_id_attribute);
+ TextNode (boost::shared_ptr<const cxml::Node> node, boost::optional<int> tcr, Standard standard);
float h_position;
HAlign h_align;
diff --git a/test/text_test.cc b/test/text_test.cc
index 23a3ae77..1c0cf9c4 100644
--- a/test/text_test.cc
+++ b/test/text_test.cc
@@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE (text_test1)
text->set_attribute("VAlign", "top");
text->add_child_text("Hello world");
- dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, "Id");
+ dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, dcp::INTEROP);
BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
BOOST_CHECK_EQUAL (t.v_align, dcp::VALIGN_TOP);
BOOST_CHECK_EQUAL (t.text, "Hello world");
@@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE (text_test2)
text->set_attribute("Valign", "top");
text->add_child_text("Hello world");
- dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, "Id");
+ dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, dcp::INTEROP);
BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
BOOST_CHECK_EQUAL (t.v_align, dcp::VALIGN_TOP);
BOOST_CHECK_EQUAL (t.text, "Hello world");