39 #ifndef LIB_DIFF_LIST_DIFF_APPLICATION_H 40 #define LIB_DIFF_LIST_DIFF_APPLICATION_H 71 template<
typename E,
typename...ARGS>
75 using Vec = vector<E,ARGS...>;
76 using Iter =
typename Vec::iterator;
85 return pos_ == orig_.end();
89 __expect_in_target (E
const& elm,
Literal oper)
93 "no (further) elements in target sequence") % oper % elm
94 , LERR_(DIFF_CONFLICT));
97 "found element %s on current target position instead")
99 , LERR_(DIFF_CONFLICT));
103 __expect_further_elements (E
const& elm)
106 throw error::State(
_Fmt(
"Premature end of target sequence, still expecting element %s; " 107 "unable to apply diff further.") % elm
108 , LERR_(DIFF_CONFLICT));
112 __expect_found (E
const& elm, Iter
const& targetPos)
114 if (targetPos == orig_.end())
116 "element %s in the remainder of the target.") % elm
117 , LERR_(DIFF_CONFLICT));
124 ins (E
const& elm)
override 130 del (E
const& elm)
override 132 __expect_in_target(elm,
"remove");
137 pick (E
const& elm)
override 139 __expect_in_target(elm,
"pick");
140 seq_.push_back (move(*pos_));
145 skip (E
const& elm)
override 147 __expect_further_elements (elm);
152 find (E
const& elm)
override 154 __expect_further_elements (elm);
155 Iter found = std::find(pos_, orig_.end(), elm);
156 __expect_found (elm, found);
157 seq_.push_back (move(*found));
168 initDiffApplication()
171 seq_.reserve (orig_.size() * 120 / 100);
172 pos_ = orig_.begin();
176 completeDiffApplication()
178 if (not end_of_target())
179 throw error::State(
_Fmt(
"Not all source data consumed after diff application. " 180 "Element %s waiting to be consumed") % *pos_
181 , LERR_(DIFF_STRUCTURE));
A token language to represent changes in a list of elements.
Interpreter interface to define the operations ("verbs"), which describe differences or changes in a ...
inline string literal This is a marker type to indicate that
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Derived specific exceptions within Lumiera's exception hierarchy.
Extension point: define how a specific diff language can be applied to elements in a concrete contain...