diff --git a/src/lib/diff/record-content-mutator.hpp b/src/lib/diff/record-content-mutator.hpp index 05b79dfee..e0b93d109 100644 --- a/src/lib/diff/record-content-mutator.hpp +++ b/src/lib/diff/record-content-mutator.hpp @@ -119,6 +119,12 @@ namespace diff{ pos = attribs.begin(); } + void + jumpToChildScope() + { + pos = children.begin(); + } + void preAllocateStorage(size_t attribCnt, size_t childrenCnt) { diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index 7fe87d1e0..98633e32b 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -439,6 +439,14 @@ namespace diff{ return *this; } + Mutator& + appendAttrib (VAL const& newAttrib) + { + REQUIRE (Rec::isAttribute(newAttrib)); + record_.attribs_.push_back (newAttrib); + return *this; + } + Mutator& appendChild (VAL const& newChild) { diff --git a/src/lib/diff/tree-diff-application.hpp b/src/lib/diff/tree-diff-application.hpp index b782ad986..d5152beef 100644 --- a/src/lib/diff/tree-diff-application.hpp +++ b/src/lib/diff/tree-diff-application.hpp @@ -95,7 +95,14 @@ namespace diff{ void ins (GenNode const& n) override { - UNIMPLEMENTED("insert node"); + if (n.isNamed()) + target_.appendAttrib(n); + else + { + target_.appendChild(n); + if (content_.currIsAttrib()) + content_.jumpToChildScope(); + } } void diff --git a/tests/library/diff/generic-record-update-test.cpp b/tests/library/diff/generic-record-update-test.cpp index 582e210da..ea61e6ee5 100644 --- a/tests/library/diff/generic-record-update-test.cpp +++ b/tests/library/diff/generic-record-update-test.cpp @@ -147,6 +147,10 @@ namespace test{ CHECK (rawElm == & *content.pos); ++content; CHECK ("b = β" == *content.pos); + content.jumpToChildScope(); + CHECK ("γ" == *content.pos); + CHECK (!content.currIsAttrib()); + CHECK (content.currIsChild()); CHECK ( isnil (mut)); CHECK (!isnil (content));