aboutsummaryrefslogtreecommitdiff
path: root/events/event.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-09 22:24:16 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-10 16:18:35 +0900
commitc38366210643ef0956884531910d7ece3d6a4cac (patch)
treeb45090fd84b475e7992a0b2d3525fd9ffd251ea9 /events/event.h
parent6572b4836231597de6a340296ee07fbeb13ebece (diff)
downloadlibquotient-c38366210643ef0956884531910d7ece3d6a4cac.tar.gz
libquotient-c38366210643ef0956884531910d7ece3d6a4cac.zip
Introduce RoomEventsView
Will be used in Room to work with ranges of events.
Diffstat (limited to 'events/event.h')
-rw-r--r--events/event.h21
1 files changed, 21 insertions, 0 deletions
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<RoomEvent>;
+ /**
+ * 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 <typename ContentT>
class StateEvent: public RoomEvent
{