for (list<shared_ptr<SubtitleNode> >::iterator j = font_node->subtitle_nodes.begin(); j != font_node->subtitle_nodes.end(); ++j) {
for (list<shared_ptr<TextNode> >::iterator k = (*j)->text_nodes.begin(); k != (*j)->text_nodes.end(); ++k) {
+ FontNode effective (current_font_nodes);
_subtitles.push_back (
shared_ptr<Subtitle> (
new Subtitle (
- font_id_to_name (id_from_font_nodes (current_font_nodes)),
- italic_from_font_nodes (current_font_nodes),
- size_from_font_nodes (current_font_nodes),
+ font_id_to_name (effective.id),
+ effective.italic.get(),
+ effective.size,
(*j)->in,
(*j)->out,
(*k)->v_position,
current_font_nodes.pop_back ();
}
-string
-SubtitleAsset::id_from_font_nodes (list<shared_ptr<FontNode> > const & font_nodes) const
+FontNode::FontNode (xmlpp::Node const * node)
+ : XMLNode (node)
{
- for (list<shared_ptr<FontNode> >::const_reverse_iterator i = font_nodes.rbegin(); i != font_nodes.rend(); ++i) {
- if (!(*i)->id.empty ()) {
- return (*i)->id;
- }
- }
-
- return "";
+ id = string_attribute ("Id");
+ size = optional_int64_attribute ("Size");
+ italic = optional_bool_attribute ("Italic");
+ subtitle_nodes = sub_nodes<SubtitleNode> ("Subtitle");
+ font_nodes = sub_nodes<FontNode> ("Font");
}
-int
-SubtitleAsset::size_from_font_nodes (list<shared_ptr<FontNode> > const & font_nodes) const
+FontNode::FontNode (list<shared_ptr<FontNode> > const & font_nodes)
+ : size (0)
+ , italic (false)
{
- for (list<shared_ptr<FontNode> >::const_reverse_iterator i = font_nodes.rbegin(); i != font_nodes.rend(); ++i) {
+ for (list<shared_ptr<FontNode> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) {
+ if (!(*i)->id.empty ()) {
+ id = (*i)->id;
+ }
if ((*i)->size != 0) {
- return (*i)->size;
+ size = (*i)->size;
}
- }
-
- return 0;
-
-}
-
-bool
-SubtitleAsset::italic_from_font_nodes (list<shared_ptr<FontNode> > const & font_nodes) const
-{
- for (list<shared_ptr<FontNode> >::const_reverse_iterator i = font_nodes.rbegin(); i != font_nodes.rend(); ++i) {
if ((*i)->italic) {
- return (*i)->italic.get ();
+ italic = (*i)->italic.get ();
}
}
-
- return false;
-
-}
-
-FontNode::FontNode (xmlpp::Node const * node)
- : XMLNode (node)
-{
- id = string_attribute ("Id");
- size = optional_int64_attribute ("Size");
- italic = optional_bool_attribute ("Italic");
- subtitle_nodes = sub_nodes<SubtitleNode> ("Subtitle");
- font_nodes = sub_nodes<FontNode> ("Font");
}
LoadFontNode::LoadFontNode (xmlpp::Node const * node)
public:
FontNode () {}
FontNode (xmlpp::Node const * node);
+ FontNode (std::list<boost::shared_ptr<FontNode> > const & font_nodes);
std::string id;
int size;
private:
std::string font_id_to_name (std::string id) const;
void examine_font_node (boost::shared_ptr<FontNode> font_node, std::list<boost::shared_ptr<FontNode> >& current_font_nodes);
- std::string id_from_font_nodes (std::list<boost::shared_ptr<FontNode> > const & font_nodes) const;
- int size_from_font_nodes (std::list<boost::shared_ptr<FontNode> > const & font_nodes) const;
- bool italic_from_font_nodes (std::list<boost::shared_ptr<FontNode> > const & font_nodes) const;
std::string _subtitle_id;
std::string _movie_title;