* @brief SubripReader class.
*/
-#include "subrip_reader.h"
+
+#include "compose.hpp"
#include "exceptions.h"
-#include "util.h"
-#include "sub_assert.h"
#include "raw_convert.h"
#include "ssa_reader.h"
+#include "sub_assert.h"
+#include "subrip_reader.h"
+#include "util.h"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string_regex.hpp>
+#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
-#include <boost/bind.hpp>
#include <cstdio>
-#include <vector>
#include <iostream>
+#include <vector>
+
using std::string;
using std::vector;
}
string expected;
- auto from = convert_time(p[0], &expected);
+ auto from = convert_time(p[0], ",", &expected);
if (!from) {
throw SubripError(p[0], expected, _context);
}
rs.from = *from;
- auto to = convert_time(p[2], &expected);
+ auto to = convert_time(p[2], ",", &expected);
if (!to) {
throw SubripError(p[2], expected, _context);
}
}
optional<Time>
-SubripReader::convert_time(string t, string* expected)
+SubripReader::convert_time(string t, string milliseconds_separator, string* expected)
{
auto report_expected = [expected](string const& s) {
if (expected) {
}
vector<string> b;
- boost::algorithm::split (b, a[2], boost::is_any_of (","));
+ boost::algorithm::split(b, a[2], boost::is_any_of(milliseconds_separator));
if (b.size() != 2) {
- report_expected("time in the format h:m:s,ms");
+ report_expected(String::compose("time in the format h:m:s%1ms", milliseconds_separator));
return {};
}
BOOST_AUTO_TEST_CASE (subrip_reader_convert_time_test)
{
sub::SubripReader reader;
- auto t = reader.convert_time("00:03:10,500");
+ auto t = reader.convert_time("00:03:10,500", ",");
BOOST_REQUIRE(t);
BOOST_CHECK_EQUAL(*t, sub::Time::from_hms(0, 3, 10, 500));
- t = reader.convert_time("04:19:51,782");
+ t = reader.convert_time("04:19:51,782", ",");
BOOST_REQUIRE(t);
BOOST_CHECK_EQUAL(*t, sub::Time::from_hms(4, 19, 51, 782));
}