From c38366210643ef0956884531910d7ece3d6a4cac Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 9 Dec 2017 22:24:16 +0900 Subject: Introduce RoomEventsView Will be used in Room to work with ranges of events. --- events/event.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'events/event.h') diff --git a/events/event.h b/events/event.h index 20e7012d..8681f4db 100644 --- a/events/event.h +++ b/events/event.h @@ -156,6 +156,27 @@ namespace QMatrixClient }; using RoomEvents = EventsBatch; + /** + * Conceptually similar to QStringView (but much more primitive), it's a + * simple abstraction over a pair of RoomEvents::const_iterator values + * referring to the beginning and the end of a range in a RoomEvents + * container. + */ + struct RoomEventsView + { + RoomEvents::const_iterator from; + RoomEvents::const_iterator to; + + RoomEvents::size_type size() const + { + Q_ASSERT(std::distance(from, to) >= 0); + return RoomEvents::size_type(std::distance(from, to)); + } + bool empty() const { return from == to; } + RoomEvents::const_iterator begin() const { return from; } + RoomEvents::const_iterator end() const { return to; } + }; + template class StateEvent: public RoomEvent { -- cgit v1.2.3