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:
parent
4356315021
commit
2882d78755
4 changed files with 26 additions and 1 deletions
|
|
@ -119,6 +119,12 @@ namespace diff{
|
|||
pos = attribs.begin();
|
||||
}
|
||||
|
||||
void
|
||||
jumpToChildScope()
|
||||
{
|
||||
pos = children.begin();
|
||||
}
|
||||
|
||||
void
|
||||
preAllocateStorage(size_t attribCnt, size_t childrenCnt)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue