6 #include <yaml-cpp/yaml.h>
15 Automatic, Milliseconds, Seconds, Minutes
20 constexpr
explicit Interval(
unsigned long long ms)
36 : _duration(other._duration)
42 _duration = other._duration;
return *
this;
45 inline bool isNull()
const {
return 0 == _duration; }
47 return _duration == other._duration;
50 return _duration < other._duration;
53 inline unsigned long long milliseconds()
const {
return _duration; }
54 inline unsigned long long seconds()
const {
return _duration/1000ULL; }
55 inline unsigned long long minutes()
const {
return _duration/60000ULL; }
70 bool parse(
const QString &value);
74 unsigned long long _duration;
87 return Node(rhs.
format().toStdString());
94 return rhs.
parse(QString::fromStdString(node.as<std::string>()));
Represents a time interval.
Definition: interval.hh:11
constexpr Interval(const Interval &other)
Copy constructor.
Definition: interval.hh:35
unsigned long long milliseconds() const
Unit conversion.
Definition: interval.hh:53
unsigned long long minutes() const
Unit conversion.
Definition: interval.hh:55
Format
Possible formats.
Definition: interval.hh:14
bool operator<(const Interval &other) const
Definition: interval.hh:49
QString format(Format f=Format::Automatic) const
Format the frequency.
Definition: interval.cc:5
static constexpr Interval fromMinutes(unsigned long long min)
Definition: interval.hh:63
Interval & operator=(const Interval &other)
Definition: interval.hh:41
static constexpr Interval fromSeconds(unsigned long long s)
Definition: interval.hh:60
bool operator==(const Interval &other) const
Definition: interval.hh:46
Interval()
Default constructor.
Definition: interval.hh:28
unsigned long long seconds() const
Unit conversion.
Definition: interval.hh:54
bool parse(const QString &value)
Parses a frequency.
Definition: interval.cc:26
constexpr Interval(unsigned long long ms)
Constructor from milliseconds.
Definition: interval.hh:20
static constexpr Interval fromMilliseconds(unsigned long long ms)
Definition: interval.hh:57
bool isNull() const
Test for 0.
Definition: interval.hh:45
static bool decode(const Node &node, Interval &rhs)
Parses the interval.
Definition: interval.hh:91
static Node encode(const Interval &rhs)
Serializes the interval.
Definition: interval.hh:86