implementation: simplest case (insert element)

...so now the stage is set. We can reimplement
the handling of the list diff cases here in the context
of tree diff application. The additional twist of course
being the distinction between attribute and child scope
This commit is contained in:
Fischlurch 2015-10-24 03:15:35 +02:00
parent 4356315021
commit 2882d78755
4 changed files with 26 additions and 1 deletions

View file

@ -119,6 +119,12 @@ namespace diff{
pos = attribs.begin();
}
void
jumpToChildScope()
{
pos = children.begin();
}
void
preAllocateStorage(size_t attribCnt, size_t childrenCnt)
{

View file

@ -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)
{

View file

@ -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

View file

@ -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));