From: Arvin Schnell Date: Tue, 5 Apr 2016 15:15:12 +0000 (+0200) Subject: - added non-const version of functions X-Git-Tag: v0.3.3~12^2~8 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=cd08e1eda71f1dfa7c9e30b87695dad5e89563ee;p=thirdparty%2Fsnapper.git - added non-const version of functions --- diff --git a/client/types.cc b/client/types.cc index 42d8f057..9501435c 100644 --- a/client/types.cc +++ b/client/types.cc @@ -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 { diff --git a/client/types.h b/client/types.h index 856a6e6d..76162084 100644 --- a/client/types.h +++ b/client/types.h @@ -77,14 +77,21 @@ struct XSnapshot struct XSnapshots { + typedef list::iterator iterator; typedef list::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 entries;