Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/diff/tree-diff.hpp"
Interpreter interface to define the operations ("verbs"), which describe differences or changes in hierarchical data structure.
The meaning of the verbs is as follows:
ins
prompts to insert the given argument element at the current processing position into the target sequence. This operation allows to inject new datadel
requires to delete the next element at current position. For sake of verification, the ID of the argument payload is required to match the ID of the element about to be discarded.pick
just accepts the next element at current position into the resulting altered sequence. Again, the ID of the argument has to match the ID of the element to be picked, for sake of verification.find
effect a re-ordering of the target scope contents: it requires to search for the (next respective single occurrence of the) given element further down into the remainder of the current record scope (but not into nested child scopes). The designated element is to be retrieved and inserted as the next element at current position.skip
processing hint, emitted at the position where an element previously extracted by a find
verb happened to sit within the old order. This allows an optimising implementation to “fetch” a copy and just drop or skip the original, thereby avoiding to shift any other elements.after
shortcut to pick
existing elements up to the designated point. As a special notation, after(Ref::ATTRIBUTES)
allows to fast forward to the first child element, while after(Ref::END)
means to accept all of the existing data contents as-is (presumably to append further elements beyond that point).set
assign a new value to the designated element. This is primarily intended for primitive data values and requires the payload type to be assignable, without changing the element's identity. The element is identified by the payload's ID and needs to be present already, i.e. it has to be mentioned by preceding order defining verbs (the list diff verbs, pick
, or find
).mut
bracketing construct to open a nested sub scope, for mutation. The element designated by the ID of the argument needs to be a Recordnested child object"". Moreover, this element must have been mentioned with the preceding diff verbs at that level, which means that the element as such must already be present in the altered target structure. The mut(ID)
verb then opens this nested record for diff handling, and all subsequent diff verbs are to be interpreted relative to this scope, until the corresponding emu(ID)
verb is encountered.emu
bracketing construct and counterpart to mut(ID)
. This verb must be given precisely at the end of the nested scope (it is not allowed to "return" from the middle of a scope, for sake of sanity). At this point, this child scope is left and the parent scope with all existing diff state is popped from an internal stack Definition at line 125 of file tree-diff.hpp.
Public Types | |
using | Val = GenNode |
Public Member Functions | |
virtual | ~TreeDiffInterpreter () |
this is an interface | |
virtual void | after (GenNode const &n)=0 |
virtual void | del (GenNode const &n)=0 |
virtual void | emu (GenNode const &n)=0 |
virtual void | find (GenNode const &n)=0 |
virtual void | ins (GenNode const &n)=0 |
virtual void | mut (GenNode const &n)=0 |
virtual void | pick (GenNode const &n)=0 |
virtual void | set (GenNode const &n)=0 |
virtual void | skip (GenNode const &n)=0 |