From e3c66895937d334ceb6d9c310941e2fbeae0e6dc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 13 Nov 2022 19:46:18 +0100 Subject: Make SubripReader::convert_time usable by other classes. --- src/subrip_reader.cc | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'src/subrip_reader.cc') diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc index f0fe07f..926511a 100644 --- a/src/subrip_reader.cc +++ b/src/subrip_reader.cc @@ -124,8 +124,18 @@ SubripReader::read (function ()> get_line) throw SubripError (*line, "a time/position line", _context); } - rs.from = convert_time (p[0]); - rs.to = convert_time (p[2]); + string 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); + if (!to) { + throw SubripError(p[2], expected, _context); + } + rs.to = *to; /* XXX: should not ignore coordinate specifications */ @@ -152,19 +162,27 @@ SubripReader::read (function ()> get_line) } } -Time -SubripReader::convert_time (string t) +optional