diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-29 10:34:10 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-29 10:34:10 +0000 |
| commit | c8c3db36a4593e396681b4acd5e9d318a28b1648 (patch) | |
| tree | 7aafc5d61fce1f6971dde96a5e345a1670e115ea /src | |
| parent | 75aa6e480d998b29205c0eab328697a5d007986b (diff) | |
Time -> FrameTime.
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame_time.cc (renamed from src/sub_time.cc) | 8 | ||||
| -rw-r--r-- | src/frame_time.h (renamed from src/sub_time.h) | 18 | ||||
| -rw-r--r-- | src/stl_reader.cc | 14 | ||||
| -rw-r--r-- | src/stl_reader.h | 2 | ||||
| -rw-r--r-- | src/stl_writer.cc | 12 | ||||
| -rw-r--r-- | src/subtitle.h | 17 | ||||
| -rw-r--r-- | src/wscript | 4 |
7 files changed, 38 insertions, 37 deletions
diff --git a/src/sub_time.cc b/src/frame_time.cc index a8e3a31..0bf63ad 100644 --- a/src/sub_time.cc +++ b/src/frame_time.cc @@ -17,7 +17,7 @@ */ -#include "sub_time.h" +#include "frame_time.h" #include "compose.hpp" #include <iostream> @@ -26,20 +26,20 @@ using std::string; using namespace sub; bool -sub::operator== (Time const & a, Time const & b) +sub::operator== (FrameTime const & a, FrameTime const & b) { return a._hours == b._hours && a._minutes == b._minutes && a._seconds == b._seconds && a._frames == b._frames; } ostream& -sub::operator<< (ostream& s, Time const & t) +sub::operator<< (ostream& s, FrameTime const & t) { s << t._hours << ":" << t._minutes << ":" << t._seconds << ":" << t._frames; return s; } string -Time::timecode () const +FrameTime::timecode () const { return String::compose ("%1:%2:%3:%4", _hours, _minutes, _seconds, _frames); } diff --git a/src/sub_time.h b/src/frame_time.h index 5596970..891fbe1 100644 --- a/src/sub_time.h +++ b/src/frame_time.h @@ -17,24 +17,24 @@ */ -#ifndef LIBSUB_TIME_H -#define LIBSUB_TIME_H +#ifndef LIBSUB_FRAME_TIME_H +#define LIBSUB_FRAME_TIME_H #include <iostream> namespace sub { -class Time +class FrameTime { public: - Time () + FrameTime () : _hours (0) , _minutes (0) , _seconds (0) , _frames (0) {} - Time (int h, int m, int s, int f) + FrameTime (int h, int m, int s, int f) : _hours (h) , _minutes (m) , _seconds (s) @@ -44,8 +44,8 @@ public: std::string timecode () const; private: - friend bool operator== (Time const & a, Time const & b); - friend std::ostream& operator<< (std::ostream& s, Time const & t); + friend bool operator== (FrameTime const & a, FrameTime const & b); + friend std::ostream& operator<< (std::ostream& s, FrameTime const & t); int _hours; int _minutes; @@ -53,8 +53,8 @@ private: int _frames; }; -bool operator== (Time const & a, Time const & b); -std::ostream& operator<< (std::ostream&, Time const & t); +bool operator== (FrameTime const & a, FrameTime const & b); +std::ostream& operator<< (std::ostream&, FrameTime const & t); } diff --git a/src/stl_reader.cc b/src/stl_reader.cc index f40ba77..dcc9070 100644 --- a/src/stl_reader.cc +++ b/src/stl_reader.cc @@ -83,16 +83,16 @@ STLReader::STLReader (istream& in) string to_string = line.substr (divider[0] + 1, divider[1] - divider[0] - 1); trim (to_string); - optional<Time> from = time (from_string); - optional<Time> to = time (to_string); + optional<FrameTime> from = time (from_string); + optional<FrameTime> to = time (to_string); if (!from || !to) { warn (String::compose ("Unrecognised line %1", line)); continue; } - _current.from = from.get (); - _current.to = to.get (); + _current.frame_from = from.get (); + _current.frame_to = to.get (); /* Parse ^B/^I/^U */ string text = line.substr (divider[1] + 1); @@ -127,17 +127,17 @@ STLReader::STLReader (istream& in) } } -optional<Time> +optional<FrameTime> STLReader::time (string t) const { vector<string> b; split (b, t, is_any_of (":")); if (b.size() != 4) { warn (String::compose ("Unrecognised time %1", t)); - return optional<Time> (); + return optional<FrameTime> (); } - return Time (lexical_cast<int> (b[0]), lexical_cast<int> (b[1]), lexical_cast<int> (b[2]), lexical_cast<int> (b[3])); + return FrameTime (lexical_cast<int> (b[0]), lexical_cast<int> (b[1]), lexical_cast<int> (b[2]), lexical_cast<int> (b[3])); } void diff --git a/src/stl_reader.h b/src/stl_reader.h index 307992a..891bc6d 100644 --- a/src/stl_reader.h +++ b/src/stl_reader.h @@ -30,7 +30,7 @@ public: private: void set (std::string name, std::string value); void maybe_push (); - boost::optional<Time> time (std::string t) const; + boost::optional<FrameTime> time (std::string t) const; Subtitle _current; }; diff --git a/src/stl_writer.cc b/src/stl_writer.cc index 36c89e5..977f861 100644 --- a/src/stl_writer.cc +++ b/src/stl_writer.cc @@ -35,8 +35,8 @@ STLWriter::STLWriter (list<Subtitle> subtitles, ostream& out) bool italic = false; bool underline = false; int line = 0; - optional<Time> from; - optional<Time> to; + optional<FrameTime> from; + optional<FrameTime> to; for (list<Subtitle>::const_iterator i = subtitles.begin(); i != subtitles.end(); ++i) { bool started_new = false; @@ -66,16 +66,16 @@ STLWriter::STLWriter (list<Subtitle> subtitles, ostream& out) text += i->text; - if (from && from.get() == i->from && to && to.get() == i->to && !started_new) { + if (from && from.get() == i->frame_from && to && to.get() == i->frame_to && !started_new) { for (int j = line; j < i->line; ++j) { out << "|"; } out << text; line = i->line; } else { - out << "\n" << i->from.timecode() << "," << i->to.timecode() << "," << text; - from = i->from; - to = i->to; + out << "\n" << i->frame_from.get().timecode() << "," << i->frame_to.get().timecode() << "," << text; + from = i->frame_from; + to = i->frame_to; line = 0; } } diff --git a/src/subtitle.h b/src/subtitle.h index d12dfc1..3afd0f3 100644 --- a/src/subtitle.h +++ b/src/subtitle.h @@ -20,7 +20,8 @@ #ifndef LIBSUB_SUBTITLE_H #define LIBSUB_SUBTITLE_H -#include "sub_time.h" +#include "frame_time.h" +#include <boost/optional.hpp> #include <string> namespace sub { @@ -44,8 +45,8 @@ public: bool italic, bool underline, int line, - Time from, - Time to + FrameTime from, + FrameTime to ) : text (text) , font (font) @@ -54,10 +55,10 @@ public: , italic (italic) , underline (underline) , line (line) - , from (from) - , to (to) + , frame_from (from) + , frame_to (to) {} - + std::string text; std::string font; int font_size; @@ -65,8 +66,8 @@ public: bool italic; bool underline; int line; - Time from; - Time to; + boost::optional<FrameTime> frame_from; + boost::optional<FrameTime> frame_to; }; } diff --git a/src/wscript b/src/wscript index 7f00d20..400eb54 100644 --- a/src/wscript +++ b/src/wscript @@ -10,17 +10,17 @@ def build(bld): obj.target = 'sub' obj.export_includes = ['.'] obj.source = """ + frame_time.cc reader.cc stl_reader.cc stl_writer.cc - sub_time.cc """ headers = """ + frame_time.h reader.h stl_reader.h stl_writer.h - sub_time.h writer.h """ |
