Some OS X build fixes.
[libdcp.git] / src / font.cc
index 52996a73ec470ce776315fa81f832d1aa3916882..8656e9090e0cf13c5eb1fe6e00242a7766667ede 100644 (file)
 
 */
 
+#include "types.h"
+#include "raw_convert.h"
 #include "font.h"
 #include "xml.h"
 #include "text.h"
 #include <libcxml/cxml.h>
+#include <boost/foreach.hpp>
 
 using std::string;
 using std::list;
@@ -28,16 +31,16 @@ using boost::shared_ptr;
 using boost::optional;
 using namespace dcp;
 
-Font::Font (boost::shared_ptr<const cxml::Node> node)
+Font::Font (cxml::ConstNodePtr node, int tcr)
 {
        text = node->content ();
        
-       id = node->optional_string_attribute ("Id").get_value_or ("");
+       id = node->optional_string_attribute ("Id");
        size = node->optional_number_attribute<int64_t> ("Size").get_value_or (0);
        italic = node->optional_bool_attribute ("Italic");
        optional<string> c = node->optional_string_attribute ("Color");
        if (c) {
-               color = Color (c.get ());
+               colour = Colour (c.get ());
        }
        optional<string> const e = node->optional_string_attribute ("Effect");
        if (e) {
@@ -45,21 +48,33 @@ Font::Font (boost::shared_ptr<const cxml::Node> node)
        }
        c = node->optional_string_attribute ( "EffectColor");
        if (c) {
-               effect_color = Color (c.get ());
+               effect_colour = Colour (c.get ());
+       }
+
+       list<cxml::NodePtr> s = node->node_children ("Subtitle");
+       BOOST_FOREACH (cxml::NodePtr& i, s) {
+               subtitle_nodes.push_back (shared_ptr<Subtitle> (new Subtitle (i, tcr)));
+       }
+
+       list<cxml::NodePtr> f = node->node_children ("Font");
+       BOOST_FOREACH (cxml::NodePtr& i, f) {
+               font_nodes.push_back (shared_ptr<Font> (new Font (i, tcr)));
+       }
+       
+       list<cxml::NodePtr> t = node->node_children ("Text");
+       BOOST_FOREACH (cxml::NodePtr& i, t) {
+               text_nodes.push_back (shared_ptr<Text> (new Text (i, tcr)));
        }
-       subtitle_nodes = type_children<Subtitle> (node, "Subtitle");
-       font_nodes = type_children<Font> (node, "Font");
-       text_nodes = type_children<Text> (node, "Text");
 }
 
 Font::Font (std::list<boost::shared_ptr<Font> > const & font_nodes)
        : size (0)
        , italic (false)
-       , color ("FFFFFFFF")
-       , effect_color ("FFFFFFFF")
+       , colour ("FFFFFFFF")
+       , effect_colour ("FFFFFFFF")
 {
        for (list<shared_ptr<Font> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) {
-               if (!(*i)->id.empty ()) {
+               if ((*i)->id) {
                        id = (*i)->id;
                }
                if ((*i)->size != 0) {
@@ -68,14 +83,14 @@ Font::Font (std::list<boost::shared_ptr<Font> > const & font_nodes)
                if ((*i)->italic) {
                        italic = (*i)->italic.get ();
                }
-               if ((*i)->color) {
-                       color = (*i)->color.get ();
+               if ((*i)->colour) {
+                       colour = (*i)->colour.get ();
                }
                if ((*i)->effect) {
                        effect = (*i)->effect.get ();
                }
-               if ((*i)->effect_color) {
-                       effect_color = (*i)->effect_color.get ();
+               if ((*i)->effect_colour) {
+                       effect_colour = (*i)->effect_colour.get ();
                }
        }
 }