#include "subrip_reader.h"
#include "exceptions.h"
+#include "util.h"
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
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<string>
-SubripReader::get_line_stringstream (stringstream* str) const
-{
- string s;
- getline (*str, s);
- if (!str->good ()) {
- return optional<string> ();
- }
-
- return s;
-}
-
-optional<string>
-SubripReader::get_line_file (FILE* f) const
-{
- char buffer[256];
- char* r = fgets (buffer, sizeof (buffer), f);
- if (r == 0 || feof (f)) {
- return optional<string> ();
- }
-
- return string (buffer);
+ this->read (boost::bind (&get_line_file, f));
}
void
static Time convert_time (std::string t);
void convert_line (std::string t, int line_number, Time from, Time to);
void maybe_content (RawSubtitle& p);
- boost::optional<std::string> get_line_stringstream (std::stringstream* str) const;
- boost::optional<std::string> get_line_file (FILE* file) const;
void read (boost::function<boost::optional<std::string> ()> get_line);
};
*/
#include "util.h"
+#include <string>
+#include <sstream>
+#include <cstdio>
using std::string;
+using std::stringstream;
+using std::getline;
+using boost::optional;
/** @param s A string.
* @return true if the string contains only space, newline or tab characters, or is empty.
return true;
}
+
+optional<string>
+sub::get_line_stringstream (stringstream* str)
+{
+ string s;
+ getline (*str, s);
+ if (!str->good ()) {
+ return optional<string> ();
+ }
+
+ return s;
+}
+
+optional<string>
+sub::get_line_file (FILE* f)
+{
+ char buffer[256];
+ char* r = fgets (buffer, sizeof (buffer), f);
+ if (r == 0 || feof (f)) {
+ return optional<string> ();
+ }
+
+ return string (buffer);
+}
*/
+#include <boost/optional.hpp>
#include <string>
namespace sub {
extern bool empty_or_white_space (std::string s);
+extern boost::optional<std::string> get_line_stringstream (std::stringstream* str);
+extern boost::optional<std::string> get_line_file (FILE* f);
}