Remove use of boost foreach.
[libsub.git] / src / ssa_reader.cc
index e2b845e5babede06b61dd9cf377210987accbffe..4a9be0e28b0d4300aaa01b191cdfbb141103bc93 100644 (file)
@@ -25,7 +25,6 @@
 #include "compose.hpp"
 #include <boost/algorithm/string.hpp>
 #include <boost/bind.hpp>
-#include <boost/foreach.hpp>
 #include <iostream>
 #include <vector>
 
@@ -33,7 +32,6 @@ using std::string;
 using std::vector;
 using std::map;
 using std::cout;
-using std::list;
 using boost::optional;
 using boost::function;
 using namespace boost::algorithm;
@@ -214,11 +212,32 @@ SSAReader::parse_style (RawSubtitle& sub, string style, int play_res_x, int play
                sub.underline = true;
        } else if (style == "\\u0") {
                sub.underline = false;
-       } else if (style == "\\an1" || style == "\\an2" || style == "\\an3") {
+       } else if (style == "\\an1") {
+               sub.horizontal_position.reference = sub::LEFT_OF_SCREEN;
+               sub.vertical_position.reference = sub::BOTTOM_OF_SCREEN;
+       } else if (style == "\\an2") {
+               sub.horizontal_position.reference = sub::HORIZONTAL_CENTRE_OF_SCREEN;
+               sub.vertical_position.reference = sub::BOTTOM_OF_SCREEN;
+       } else if (style == "\\an3") {
+               sub.horizontal_position.reference = sub::RIGHT_OF_SCREEN;
                sub.vertical_position.reference = sub::BOTTOM_OF_SCREEN;
-       } else if (style == "\\an4" || style == "\\an5" || style == "\\an6") {
+       } else if (style == "\\an4") {
+               sub.horizontal_position.reference = sub::LEFT_OF_SCREEN;
+               sub.vertical_position.reference = sub::VERTICAL_CENTRE_OF_SCREEN;
+       } else if (style == "\\an5") {
+               sub.horizontal_position.reference = sub::HORIZONTAL_CENTRE_OF_SCREEN;
                sub.vertical_position.reference = sub::VERTICAL_CENTRE_OF_SCREEN;
-       } else if (style == "\\an7" || style == "\\an8" || style == "\\an9") {
+       } else if (style == "\\an6") {
+               sub.horizontal_position.reference = sub::RIGHT_OF_SCREEN;
+               sub.vertical_position.reference = sub::VERTICAL_CENTRE_OF_SCREEN;
+       } else if (style == "\\an7") {
+               sub.horizontal_position.reference = sub::LEFT_OF_SCREEN;
+               sub.vertical_position.reference = sub::TOP_OF_SCREEN;
+       } else if (style == "\\an8") {
+               sub.horizontal_position.reference = sub::HORIZONTAL_CENTRE_OF_SCREEN;
+               sub.vertical_position.reference = sub::TOP_OF_SCREEN;
+       } else if (style == "\\an9") {
+               sub.horizontal_position.reference = sub::RIGHT_OF_SCREEN;
                sub.vertical_position.reference = sub::TOP_OF_SCREEN;
        } else if (boost::starts_with(style, "\\pos")) {
                vector<string> bits;
@@ -244,7 +263,7 @@ SSAReader::parse_style (RawSubtitle& sub, string style, int play_res_x, int play
  *  @param line SSA line string (i.e. just the subtitle, possibly with embedded stuff)
  *  @return List of RawSubtitles to represent line with vertical reference TOP_OF_SUBTITLE.
  */
-list<RawSubtitle>
+vector<RawSubtitle>
 SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_res_y)
 {
        enum {
@@ -253,7 +272,7 @@ SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_r
                BACKSLASH
        } state = TEXT;
 
-       list<RawSubtitle> subs;
+       vector<RawSubtitle> subs;
        RawSubtitle current = base;
        string style;
 
@@ -419,7 +438,7 @@ SSAReader::read (function<optional<string> ()> get_line)
                case EVENTS:
                        if (type == "Format") {
                                split (event_format, body, is_any_of (","));
-                               BOOST_FOREACH (string& i, event_format) {
+                               for (auto& i: event_format) {
                                        trim (i);
                                }
                        } else if (type == "Dialogue") {
@@ -468,7 +487,7 @@ SSAReader::read (function<optional<string> ()> get_line)
                                        } else if (event_format[i] == "MarginV") {
                                                sub.vertical_position.proportional = raw_convert<float>(event[i]) / play_res_y;
                                        } else if (event_format[i] == "Text") {
-                                               BOOST_FOREACH (sub::RawSubtitle j, parse_line (sub, event[i], play_res_x, play_res_y)) {
+                                               for (auto j: parse_line (sub, event[i], play_res_x, play_res_y)) {
                                                        _subs.push_back (j);
                                                }
                                        }