add explicit handling to change the typeID
the type is the only meta attribute supported by now, thus the decision was to handle this manually, instead of introducing a full scope for meta attributes. Unfortunately this leads to an assymetry: while it is possible to send an attribute named "type", which will be intercepted and used as a new type ID, the type will not show up when iterating or searching through attributes. When applying a diff, the only possibility is to *insert* a new type attribute, and we need to check and handle this likewise manually.
This commit is contained in:
parent
e231a51dc6
commit
0e769601b7
2 changed files with 13 additions and 4 deletions
|
|
@ -276,6 +276,12 @@ namespace diff{
|
|||
return not util::startsWith (idi.getSym(), "_CHILD_");
|
||||
}
|
||||
|
||||
bool
|
||||
isTypeID() const
|
||||
{
|
||||
return "type" == idi.getSym();
|
||||
}
|
||||
|
||||
template<typename X>
|
||||
bool contains (X const& elm) const;
|
||||
|
||||
|
|
@ -624,9 +630,9 @@ namespace diff{
|
|||
|
||||
template<>
|
||||
inline bool
|
||||
Rec::isTypeID (GenNode const& v)
|
||||
Rec::isTypeID (GenNode const& attrib)
|
||||
{
|
||||
return "type" == v.idi.getSym();
|
||||
return attrib.isTypeID();
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ namespace diff{
|
|||
void
|
||||
__expect_end_of_scope (GenNode::ID const& idi)
|
||||
{
|
||||
if (!endOfData())
|
||||
if (not endOfData())
|
||||
throw error::State(_Fmt("Incomplete diff: when about to leave scope %s, "
|
||||
"not all previously existing elements have been confirmed by the diff. "
|
||||
"At least one spurious element %s was left over") % idi.getSym() % *srcPos()
|
||||
|
|
@ -213,7 +213,10 @@ namespace diff{
|
|||
ins (GenNode const& n) override
|
||||
{
|
||||
if (n.isNamed())
|
||||
out().appendAttrib(n);
|
||||
if (n.isTypeID())
|
||||
out().setType (n.data.get<string>());
|
||||
else
|
||||
out().appendAttrib(n);
|
||||
else
|
||||
{
|
||||
out().appendChild(n);
|
||||
|
|
|
|||
Loading…
Reference in a new issue