c++11 tidying.
[libsub.git] / src / stl_text_reader.cc
index 3c60e4141422ba72f45248c34d136dadd115b227..c7b1fcfd91198d01c04d183afb2e55e40eb5d11b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
 #include <vector>
+#include <iostream>
 
 using std::list;
 using std::ostream;
@@ -38,9 +39,12 @@ using namespace sub;
 
 STLTextReader::STLTextReader (istream& in)
 {
+       /* This reader extracts no information about where the subtitle
+          should be on screen, so its reference is TOP_OF_SUBTITLE.
+       */
        _subtitle.vertical_position.line = 0;
-       _subtitle.vertical_position.reference = TOP_OF_SCREEN;
-       
+       _subtitle.vertical_position.reference = TOP_OF_SUBTITLE;
+
        while (in.good ()) {
                string line;
                getline (in, line);
@@ -75,7 +79,7 @@ STLTextReader::STLTextReader (istream& in)
                        if (divider[0] != string::npos) {
                                divider[1] = line.find_first_of (",", divider[0] + 1);
                        }
-                       
+
                        if (divider[0] == string::npos || divider[1] == string::npos || divider[0] <= 1 || divider[1] >= line.length() - 1) {
                                warn (String::compose ("Unrecognised line %1", line));
                                continue;
@@ -86,16 +90,16 @@ STLTextReader::STLTextReader (istream& in)
                        string to_string = line.substr (divider[0] + 1, divider[1] - divider[0] - 1);
                        trim (to_string);
 
-                       optional<FrameTime> from = time (from_string);
-                       optional<FrameTime> to = time (to_string);
+                       optional<Time> from = time (from_string);
+                       optional<Time> to = time (to_string);
 
                        if (!from || !to) {
                                warn (String::compose ("Unrecognised line %1", line));
                                continue;
                        }
 
-                       _subtitle.from.set_frame (from.get ());
-                       _subtitle.to.set_frame (to.get ());
+                       _subtitle.from = from.get ();
+                       _subtitle.to = to.get ();
 
                        /* Parse ^B/^I/^U */
                        string text = line.substr (divider[1] + 1);
@@ -129,17 +133,17 @@ STLTextReader::STLTextReader (istream& in)
        }
 }
 
-optional<FrameTime>
+optional<Time>
 STLTextReader::time (string t) const
 {
        vector<string> b;
        split (b, t, is_any_of (":"));
        if (b.size() != 4) {
                warn (String::compose ("Unrecognised time %1", t));
-               return optional<FrameTime> ();
+               return optional<Time> ();
        }
 
-       return FrameTime (lexical_cast<int> (b[0]), lexical_cast<int> (b[1]), lexical_cast<int> (b[2]), lexical_cast<int> (b[3]));
+       return sub::Time::from_hmsf (lexical_cast<int> (b[0]), lexical_cast<int> (b[1]), lexical_cast<int> (b[2]), lexical_cast<int> (b[3]));
 }
 
 void