-namespace sub {
-
-class DCPFont;
-
-class DCPText
-{
-public:
- DCPText ()
- : v_position (0)
- , v_align (TOP)
- {}
-
- DCPText (shared_ptr<const cxml::Node> node)
- : v_align (CENTRE)
- {
- text = node->content ();
- v_position = node->number_attribute<float> ("VPosition");
- optional<string> v = node->optional_string_attribute ("VAlign");
- if (v) {
- v_align = string_to_vertical_reference (v.get ());
- }
-
- font_nodes = type_children<DCPFont> (node, "Font");
- }
-
- float v_position;
- VerticalReference v_align;
- string text;
- shared_ptr<DCPFont> foo;
- list<shared_ptr<DCPFont> > font_nodes;
-};
-
-class DCPSubtitle
-{
-public:
- DCPSubtitle () {}
- DCPSubtitle (shared_ptr<const cxml::Node> node)
- {
- in = MetricTime (time (node->string_attribute ("TimeIn")));
- out = MetricTime (time (node->string_attribute ("TimeOut")));
- font_nodes = type_children<DCPFont> (node, "Font");
- text_nodes = type_children<DCPText> (node, "Text");
- fade_up_time = fade_time (node, "FadeUpTime");
- fade_down_time = fade_time (node, "FadeDownTime");
- }
-
- MetricTime in;
- MetricTime out;
- MetricTime fade_up_time;
- MetricTime fade_down_time;
- list<shared_ptr<DCPFont> > font_nodes;
- list<shared_ptr<DCPText> > text_nodes;
-
-private:
- static MetricTime time (std::string time)
- {
- vector<string> b;
- split (b, time, is_any_of (":"));
- if (b.size() != 4) {
- boost::throw_exception (XMLError ("unrecognised time specification"));
- }
-
- return MetricTime (lexical_cast<int>(b[0]), lexical_cast<int> (b[1]), lexical_cast<int> (b[2]), lexical_cast<int> (b[3]) * 4);
- }
-
- MetricTime fade_time (shared_ptr<const cxml::Node> node, string name)
- {
- string const u = node->optional_string_attribute (name).get_value_or ("");
- MetricTime t;
-
- if (u.empty ()) {
- t = MetricTime (0, 0, 0, 80);
- } else if (u.find (":") != string::npos) {
- t = time (u);
- } else {
- t = MetricTime (0, 0, 0, lexical_cast<int>(u) * 4);
- }
-
- if (t > MetricTime (0, 0, 8, 0)) {
- t = MetricTime (0, 0, 8, 0);
- }
-
- return t;
- }
-};
-
-class DCPFont
-{
-public:
- DCPFont ()
- : size (0)
- {}
-
- DCPFont (shared_ptr<const cxml::Node> node)
- {
- text = node->content ();
-
- id = node->optional_string_attribute ("Id").get_value_or ("");
- 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) {
- colour = Colour (c.get ());
- }
- optional<string> const e = node->optional_string_attribute ("Effect");
- if (e) {
- effect = string_to_effect (e.get ());
- }
- c = node->optional_string_attribute ( "EffectColor");
- if (c) {
- effect_colour = Colour (c.get ());
- }
- subtitle_nodes = type_children<DCPSubtitle> (node, "Subtitle");
- font_nodes = type_children<DCPFont> (node, "Font");
- text_nodes = type_children<DCPText> (node, "Text");
- }
-
- DCPFont (list<shared_ptr<DCPFont> > const & font_nodes)
- : size (0)
- , italic (false)
- , colour ("FFFFFFFF")
- , effect_colour ("FFFFFFFF")
- {
- for (list<shared_ptr<DCPFont> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) {
- if (!(*i)->id.empty ()) {
- id = (*i)->id;
- }
- if ((*i)->size != 0) {
- size = (*i)->size;
- }
- if ((*i)->italic) {
- italic = (*i)->italic.get ();
- }
- if ((*i)->colour) {
- colour = (*i)->colour.get ();
- }
- if ((*i)->effect) {
- effect = (*i)->effect.get ();
- }
- if ((*i)->effect_colour) {
- effect_colour = (*i)->effect_colour.get ();
- }
- }
- }
-
- string text;
- string id;
- int size;
- optional<bool> italic;
- optional<Colour> colour;
- optional<Effect> effect;
- optional<Colour> effect_colour;
-
- list<shared_ptr<DCPSubtitle> > subtitle_nodes;
- list<shared_ptr<DCPFont> > font_nodes;
- list<shared_ptr<DCPText> > text_nodes;
-};
-
-class DCPLoadFont