From 8fd43fface7757bd0d7228ff0490a8c8ad074175 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 11 Feb 2016 11:46:13 +0000 Subject: Extract get_line_{file,stringstream} into standalone methods. --- src/subrip_reader.cc | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'src/subrip_reader.cc') diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc index ddaa112..6c0c63a 100644 --- a/src/subrip_reader.cc +++ b/src/subrip_reader.cc @@ -23,6 +23,7 @@ #include "subrip_reader.h" #include "exceptions.h" +#include "util.h" #include #include #include @@ -47,37 +48,13 @@ using namespace sub; SubripReader::SubripReader (string const & s) { stringstream str (s); - this->read (boost::bind (&SubripReader::get_line_stringstream, this, &str)); + this->read (boost::bind (&get_line_stringstream, &str)); } /** @param f Subtitle file encoded in UTF-8 */ SubripReader::SubripReader (FILE* f) { - this->read (boost::bind (&SubripReader::get_line_file, this, f)); -} - -optional -SubripReader::get_line_stringstream (stringstream* str) const -{ - string s; - getline (*str, s); - if (!str->good ()) { - return optional (); - } - - return s; -} - -optional -SubripReader::get_line_file (FILE* f) const -{ - char buffer[256]; - char* r = fgets (buffer, sizeof (buffer), f); - if (r == 0 || feof (f)) { - return optional (); - } - - return string (buffer); + this->read (boost::bind (&get_line_file, f)); } void -- cgit v1.2.3