Maybe this method should just be on its own somewhere now.
* @brief SubripReader class.
*/
* @brief SubripReader class.
*/
-#include "subrip_reader.h"
+
+#include "compose.hpp"
-#include "util.h"
-#include "sub_assert.h"
#include "raw_convert.h"
#include "ssa_reader.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/algorithm/string.hpp>
#include <boost/algorithm/string_regex.hpp>
+#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
-#include <boost/bind.hpp>
using std::string;
using std::vector;
using std::string;
using std::vector;
- 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;
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);
}
if (!to) {
throw SubripError(p[2], expected, _context);
}
-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) {
{
auto report_expected = [expected](string const& s) {
if (expected) {
- boost::algorithm::split (b, a[2], boost::is_any_of (","));
+ boost::algorithm::split(b, a[2], boost::is_any_of(milliseconds_separator));
- report_expected("time in the format h:m:s,ms");
+ report_expected(String::compose("time in the format h:m:s%1ms", milliseconds_separator));
SubripReader (FILE* f);
SubripReader (std::string subs);
SubripReader (FILE* f);
SubripReader (std::string subs);
- static boost::optional<Time> convert_time(std::string t, std::string* expected = nullptr);
+ static boost::optional<Time> convert_time(std::string t, std::string milliseconds_separator, std::string* expected = nullptr);
BOOST_AUTO_TEST_CASE (subrip_reader_convert_time_test)
{
sub::SubripReader reader;
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));
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));
}
BOOST_REQUIRE(t);
BOOST_CHECK_EQUAL(*t, sub::Time::from_hms(4, 19, 51, 782));
}