From 1a20505c4f0f5cdcf023b03eb0e80e6f1de7eadb Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 4 Mar 2016 21:38:39 +0100 Subject: [PATCH] implement src position and simple match operation --- src/lib/diff/test-mutation-target.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lib/diff/test-mutation-target.hpp b/src/lib/diff/test-mutation-target.hpp index 5866e35db..e41140efc 100644 --- a/src/lib/diff/test-mutation-target.hpp +++ b/src/lib/diff/test-mutation-target.hpp @@ -274,15 +274,20 @@ namespace diff{ } + using iterator = typename iter_stl::_SeqT::Range; using const_iterator = typename iter_stl::_SeqT::Range; const_iterator begin() const { return iter_stl::eachElm(content_); } const_iterator end() const { return const_iterator(); } + iterator srcIter() {return iter_stl::eachElm(prev_content_); } + + friend const_iterator begin (TestMutationTarget const& target) { return target.begin(); } friend const_iterator end (TestMutationTarget const& target) { return target.end(); } + private: }; @@ -314,12 +319,16 @@ namespace diff{ : renderChild(n)); } - /** ensure the next source element matches with given spec */ + /** ensure the next recorded source element + * matches on a formal level with given spec */ virtual bool - matchSrc (GenNode const&) + matchSrc (GenNode const& n) { - UNIMPLEMENTED(); - return false; + if (target_.emptySrc()) + return false; + string spec{n.isNamed()? renderAttribute(n) + : renderChild(n) }; + return spec == *pos_; } /** accept existing element, when matching the given spec */ @@ -342,12 +351,15 @@ namespace diff{ TestWireTap(TestMutationTarget& dummy, PAR const& chain) : PAR(chain) , target_(dummy) + , pos_() { target_.initMutation (identify(this)); + pos_ = target_.srcIter(); } private: TestMutationTarget& target_; + TestMutationTarget::iterator pos_; };