improve the diagnositc representation for time values
- especially mark Offsets and Durations - fix possible number-overflow (time values are 64 bit!)
This commit is contained in:
parent
5e16431b44
commit
1dddbdaacc
2 changed files with 36 additions and 16 deletions
|
|
@ -126,18 +126,20 @@ namespace time {
|
|||
* @warning internal Lumiera time values refer to an
|
||||
* implementation dependent time origin/scale.
|
||||
* @return string rendering of the actual, underlying
|
||||
* implementation value, as \c h:m:s:ms
|
||||
* implementation value, as `h:m:s:ms`
|
||||
*/
|
||||
Time::operator string() const
|
||||
{
|
||||
return string (lumiera_tmpbuf_print_time (t_));
|
||||
}
|
||||
|
||||
/** @note recommendation to use TCode for external representation */
|
||||
/** @note recommendation is to use TCode for external representation
|
||||
* @remarks this is the most prevalent internal diagnostics display
|
||||
* of any "time-like" value, it is meant to be compact. */
|
||||
TimeValue::operator string() const
|
||||
{
|
||||
gavl_time_t time = t_;
|
||||
int millis, seconds;
|
||||
int64_t millis, seconds;
|
||||
bool negative = (time < 0);
|
||||
|
||||
if (negative) time = -time;
|
||||
|
|
@ -151,15 +153,37 @@ namespace time {
|
|||
;
|
||||
}
|
||||
|
||||
Offset::operator string() const
|
||||
{
|
||||
return (t_< 0? "" : "∆")
|
||||
+ TimeValue::operator string();
|
||||
}
|
||||
|
||||
Duration::operator string() const
|
||||
{
|
||||
return "≺"+TimeValue::operator string()+"≻";
|
||||
}
|
||||
|
||||
TimeSpan::operator string() const
|
||||
{
|
||||
return string (lumiera_tmpbuf_print_time (t_))
|
||||
+ "["+string(dur_)+"]";
|
||||
+ string (dur_);
|
||||
}
|
||||
|
||||
|
||||
/** visual framerate representation (for diagnostics) */
|
||||
FrameRate::operator string() const
|
||||
{
|
||||
return 1==denominator() ? lexical_cast<string> (numerator())+"FPS"
|
||||
: lexical_cast<string> (numerator())
|
||||
+ "/"
|
||||
+ lexical_cast<string> (denominator())
|
||||
+ "FPS";
|
||||
}
|
||||
|
||||
|
||||
/** @internal backdoor to sneak in a raw time value
|
||||
* bypassing any normalisation and limiting */
|
||||
* bypassing any normalisation and limiting */
|
||||
TimeValue
|
||||
TimeValue::buildRaw_ (gavl_time_t raw)
|
||||
{
|
||||
|
|
@ -186,17 +210,6 @@ namespace time {
|
|||
|
||||
return Duration (1, *this);
|
||||
}
|
||||
|
||||
|
||||
/** visual framerate representation (for diagnostics) */
|
||||
FrameRate::operator string() const
|
||||
{
|
||||
return 1==denominator() ? lexical_cast<string> (numerator())+"FPS"
|
||||
: lexical_cast<string> (numerator())
|
||||
+ "/"
|
||||
+ lexical_cast<string> (denominator())
|
||||
+ "FPS";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -315,6 +315,9 @@ namespace time {
|
|||
return TimeValue(std::llabs (t_));
|
||||
}
|
||||
|
||||
/** @internal diagnostics, indicating ∆ */
|
||||
operator std::string () const;
|
||||
|
||||
// Supporting sign flip
|
||||
Offset operator- () const;
|
||||
};
|
||||
|
|
@ -402,6 +405,10 @@ namespace time {
|
|||
|
||||
void accept (Mutation const&);
|
||||
|
||||
|
||||
/** @internal diagnostics */
|
||||
operator std::string () const;
|
||||
|
||||
/// Supporting backwards use as offset
|
||||
Offset operator- () const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue