diff options
Diffstat (limited to 'src/sub_time.h')
| -rw-r--r-- | src/sub_time.h | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/sub_time.h b/src/sub_time.h index 22178e9..93088cb 100644 --- a/src/sub_time.h +++ b/src/sub_time.h @@ -20,25 +20,10 @@ #ifndef LIBSUB_SUB_TIME_H #define LIBSUB_SUB_TIME_H +#include "rational.h" #include <boost/optional.hpp> namespace sub { - -class Rational -{ -public: - Rational (int numerator_, int denominator_) - : numerator (numerator_) - , denominator (denominator_) - {} - - int numerator; - int denominator; - - double fraction () const { - return double (numerator) / denominator; - } -}; class Time { @@ -57,9 +42,13 @@ public: double all_as_seconds () const; + void add (Time t); + void scale (float f); + static Time from_hmsf (int h, int m, int s, int f, boost::optional<Rational> rate = boost::optional<Rational> ()); static Time from_hms (int h, int m, int s, int ms); - + static Time from_frames (int frames, Rational rate); + private: friend bool operator< (Time const & a, Time const & b); friend bool operator> (Time const & a, Time const & b); @@ -71,7 +60,7 @@ private: , _frames (frames) , _rate (rate) {} - + int _seconds; int _frames; boost::optional<Rational> _rate; @@ -82,7 +71,7 @@ bool operator> (Time const & a, Time const & b); bool operator== (Time const & a, Time const & b); bool operator!= (Time const & a, Time const & b); std::ostream& operator<< (std::ostream& s, Time const & t); - + } #endif |
