]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added non-const version of functions
authorArvin Schnell <aschnell@suse.de>
Tue, 5 Apr 2016 15:15:12 +0000 (17:15 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 5 Apr 2016 15:15:12 +0000 (17:15 +0200)
client/types.cc
client/types.h

index 42d8f057a4a636885ed2c489ab76f4900715e70e..9501435c04843cfa47efeb0be8fde61a7c4b456c 100644 (file)
@@ -40,6 +40,22 @@ XSnapshots::find(unsigned int num) const
 }
 
 
+XSnapshots::iterator
+XSnapshots::findPre(iterator post)
+{
+    if (post == entries.end() || post->isCurrent() || post->getType() != POST)
+       SN_THROW(IllegalSnapshotException());
+
+    for (iterator it = begin(); it != end(); ++it)
+    {
+       if (it->getType() == PRE && it->getNum() == post->getPreNum())
+           return it;
+    }
+
+    return end();
+}
+
+
 XSnapshots::const_iterator
 XSnapshots::findPre(const_iterator post) const
 {
@@ -56,6 +72,22 @@ XSnapshots::findPre(const_iterator post) const
 }
 
 
+XSnapshots::iterator
+XSnapshots::findPost(iterator pre)
+{
+    if (pre == entries.end() || pre->isCurrent() || pre->getType() != PRE)
+       SN_THROW(IllegalSnapshotException());
+
+    for (iterator it = begin(); it != end(); ++it)
+    {
+       if (it->getType() == POST && it->getPreNum() == pre->getNum())
+           return it;
+    }
+
+    return end();
+}
+
+
 XSnapshots::const_iterator
 XSnapshots::findPost(const_iterator pre) const
 {
index 856a6e6da9dd518336538218dfb933e91e0faaba..761620846c140ffd752bc0d2e82af2ee9d66c12b 100644 (file)
@@ -77,14 +77,21 @@ struct XSnapshot
 
 struct XSnapshots
 {
+    typedef list<XSnapshot>::iterator iterator;
     typedef list<XSnapshot>::const_iterator const_iterator;
 
+    iterator begin() { return entries.begin(); }
     const_iterator begin() const { return entries.begin(); }
+
+    iterator end() { return entries.end(); }
     const_iterator end() const { return entries.end(); }
 
     const_iterator find(unsigned int num) const;
 
+    iterator findPre(iterator post);
     const_iterator findPre(const_iterator post) const;
+
+    iterator findPost(iterator pre);
     const_iterator findPost(const_iterator pre) const;
 
     list<XSnapshot> entries;