temporal: operator<< for Range and RangeList

This commit is contained in:
Paul Davis 2023-03-23 00:15:17 -06:00
parent 47416743fb
commit 5dbbac0bc2
2 changed files with 40 additions and 0 deletions

View File

@ -117,3 +117,18 @@ template<> OverlapType Temporal::coverage_exclusive_ends<int64_t> (int64_t sa, i
/* convert end positions to inclusive */
return coverage_inclusive_ends (sa, eaE-1, sb, ebE-1);
}
std::ostream&
std::operator<< (std::ostream & o, RangeList const & rl)
{
rl.dump (o);
return o;
}
std::ostream&
std::operator<< (std::ostream & o, Range const & r)
{
r.dump (o);
return o;
}

View File

@ -187,6 +187,10 @@ class LIBTEMPORAL_API Range {
return Temporal::coverage_exclusive_ends (_start, _end, s, e);
}
void dump (std::ostream& ostr) const {
ostr << "Range @ " << this << ' ' << _start << " .. " << _end;
}
private:
timepos_t _start; ///< start of the range
timepos_t _end; ///< end of the range (exclusive, see above)
@ -194,6 +198,15 @@ class LIBTEMPORAL_API Range {
typedef Range TimeRange;
}
namespace std {
LIBTEMPORAL_API std::ostream& operator<< (std::ostream & o, Temporal::Range const &);
}
namespace Temporal {
class LIBTEMPORAL_API RangeList {
public:
RangeList () : _dirty (false) {}
@ -239,6 +252,13 @@ public:
_dirty = false;
}
void dump (std::ostream& ostr) const {
ostr << "RangeList @ " << this << std::endl;
for (auto const & r : _list) {
ostr << r << std::endl;
}
}
private:
List _list;
@ -255,4 +275,9 @@ struct LIBTEMPORAL_API RangeMove {
}
namespace std {
LIBTEMPORAL_API std::ostream& operator<< (std::ostream & o, Temporal::RangeList const &);
}
#endif /* __libtemporal_range_hpp__ */